Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit d4734e5

Browse files
committed
Fix string culture warnings.
Fixes CA1304, CA1305, CA1307, CA1308 and CA1309.
1 parent aa3e3b9 commit d4734e5

File tree

14 files changed

+45
-26
lines changed

14 files changed

+45
-26
lines changed

src/GitHub.App/Services/PullRequestEditorService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ await pullRequestService.ExtractToTempFile(
232232

233233
var leftText = diffViewer.LeftView.TextBuffer.CurrentSnapshot.GetText();
234234
var rightText = diffViewer.RightView.TextBuffer.CurrentSnapshot.GetText();
235-
if (leftText == string.Empty)
235+
if (leftText.Length == 0)
236236
{
237237
// Don't show LeftView when empty.
238238
diffViewer.ViewMode = DifferenceViewMode.RightViewOnly;
239239
}
240-
else if (rightText == string.Empty)
240+
else if (rightText.Length == 0)
241241
{
242242
// Don't show RightView when empty.
243243
diffViewer.ViewMode = DifferenceViewMode.LeftViewOnly;

src/GitHub.App/ViewModels/GitHubPane/GitHubPaneViewModel.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.ComponentModel.Composition;
33
using System.ComponentModel.Design;
4+
using System.Globalization;
45
using System.Linq;
56
using System.Reactive;
67
using System.Reactive.Linq;
@@ -253,29 +254,29 @@ public async Task NavigateTo(Uri uri)
253254
{
254255
var owner = match.Groups["owner"].Value;
255256
var repo = match.Groups["repo"].Value;
256-
var number = int.Parse(match.Groups["number"].Value);
257+
var number = int.Parse(match.Groups["number"].Value, CultureInfo.InvariantCulture);
257258
await ShowPullRequest(owner, repo, number);
258259
}
259260
else if ((match = pullNewReviewUri.Match(uri.AbsolutePath))?.Success == true)
260261
{
261262
var owner = match.Groups["owner"].Value;
262263
var repo = match.Groups["repo"].Value;
263-
var number = int.Parse(match.Groups["number"].Value);
264+
var number = int.Parse(match.Groups["number"].Value, CultureInfo.InvariantCulture);
264265
await ShowPullRequestReviewAuthoring(owner, repo, number);
265266
}
266267
else if ((match = pullUserReviewsUri.Match(uri.AbsolutePath))?.Success == true)
267268
{
268269
var owner = match.Groups["owner"].Value;
269270
var repo = match.Groups["repo"].Value;
270-
var number = int.Parse(match.Groups["number"].Value);
271+
var number = int.Parse(match.Groups["number"].Value, CultureInfo.InvariantCulture);
271272
var login = match.Groups["login"].Value;
272273
await ShowPullRequestReviews(owner, repo, number, login);
273274
}
274275
else if ((match = pullCheckRunsUri.Match(uri.AbsolutePath))?.Success == true)
275276
{
276277
var owner = match.Groups["owner"].Value;
277278
var repo = match.Groups["repo"].Value;
278-
var number = int.Parse(match.Groups["number"].Value);
279+
var number = int.Parse(match.Groups["number"].Value, CultureInfo.InvariantCulture);
279280
var id = match.Groups["id"].Value;
280281

281282
await ShowPullRequestCheckRun(owner, repo, number, id);

src/GitHub.App/ViewModels/GitHubPane/IssueListViewModelBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4+
using System.Globalization;
45
using System.IO;
56
using System.Linq;
67
using System.Reactive;
@@ -252,7 +253,7 @@ void FilterChanged()
252253

253254
if (numberFilter == 0)
254255
{
255-
stringFilter = SearchQuery.ToUpper();
256+
stringFilter = SearchQuery.ToUpper(CultureInfo.CurrentCulture);
256257
}
257258
}
258259
else
@@ -280,7 +281,7 @@ bool FilterItem(object o)
280281
}
281282
else
282283
{
283-
result = item.Title.ToUpper().Contains(stringFilter);
284+
result = item.Title.ToUpper(CultureInfo.InvariantCulture).Contains(stringFilter);
284285
}
285286
}
286287
}

src/GitHub.App/ViewModels/GitHubPane/PullRequestDetailViewModel.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ public async Task Load(PullRequestDetailModel pullRequest)
370370
if (pullEnabled)
371371
{
372372
pullToolTip = string.Format(
373+
CultureInfo.InvariantCulture,
373374
Resources.PullRequestDetailsPullToolTip,
374375
IsFromFork ? Resources.Fork : Resources.Remote,
375376
SourceBranchDisplayName);
@@ -382,6 +383,7 @@ public async Task Load(PullRequestDetailModel pullRequest)
382383
if (pushEnabled)
383384
{
384385
pushToolTip = string.Format(
386+
CultureInfo.InvariantCulture,
385387
Resources.PullRequestDetailsPushToolTip,
386388
IsFromFork ? Resources.Fork : Resources.Remote,
387389
SourceBranchDisplayName);
@@ -396,16 +398,22 @@ public async Task Load(PullRequestDetailModel pullRequest)
396398
}
397399

398400
var submodulesToSync = await pullRequestsService.CountSubmodulesToSync(LocalRepository);
399-
var syncSubmodulesToolTip = string.Format(Resources.SyncSubmodules, submodulesToSync);
401+
var syncSubmodulesToolTip = string.Format(CultureInfo.InvariantCulture, Resources.SyncSubmodules, submodulesToSync);
400402

401403
UpdateState = new UpdateCommandState(divergence, pullEnabled, pushEnabled, pullToolTip, pushToolTip, syncSubmodulesToolTip, submodulesToSync);
402404
CheckoutState = null;
403405
}
404406
else
405407
{
406408
var caption = localBranches.Count > 0 ?
407-
string.Format(Resources.PullRequestDetailsCheckout, localBranches.First().DisplayName) :
408-
string.Format(Resources.PullRequestDetailsCheckoutTo, await pullRequestsService.GetDefaultLocalBranchName(LocalRepository, Model.Number, Model.Title));
409+
string.Format(
410+
CultureInfo.InvariantCulture,
411+
Resources.PullRequestDetailsCheckout,
412+
localBranches.First().DisplayName) :
413+
string.Format(
414+
CultureInfo.InvariantCulture,
415+
Resources.PullRequestDetailsCheckoutTo,
416+
await pullRequestsService.GetDefaultLocalBranchName(LocalRepository, Model.Number, Model.Title));
409417
var clean = await pullRequestsService.IsWorkingDirectoryClean(LocalRepository);
410418
string disabled = null;
411419

src/GitHub.App/ViewModels/UserFilterViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ public int Compare(object x, object y)
146146
{
147147
if (x == owner.ersatzUser) return -1;
148148
if (y == owner.ersatzUser) return 1;
149-
return ((IActorViewModel)x).Login.CompareTo(((IActorViewModel)y).Login);
149+
return string.Compare(
150+
((IActorViewModel)x).Login,
151+
((IActorViewModel)y).Login,
152+
StringComparison.Ordinal);
150153
}
151154
}
152155
}

src/GitHub.Exports/Models/CommitMessage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public bool Equals(CommitMessage other)
3939
return false;
4040
}
4141

42-
return string.Equals(Summary, other.Summary)
43-
&& string.Equals(Details, other.Details);
42+
return string.Equals(Summary, other.Summary, StringComparison.Ordinal)
43+
&& string.Equals(Details, other.Details, StringComparison.Ordinal);
4444
}
4545

4646
public override bool Equals(object obj)

src/GitHub.Exports/Models/DiffUtilities.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text.RegularExpressions;
55
using System.Diagnostics.CodeAnalysis;
66
using GitHub.Extensions;
7+
using System.Globalization;
78

89
#pragma warning disable CA1034 // Nested types should not be visible
910

@@ -39,8 +40,8 @@ public static IEnumerable<DiffChunk> ParseFragment(string diff)
3940

4041
chunk = new DiffChunk
4142
{
42-
OldLineNumber = oldLine = int.Parse(headerMatch.Groups[1].Value),
43-
NewLineNumber = newLine = int.Parse(headerMatch.Groups[2].Value),
43+
OldLineNumber = oldLine = int.Parse(headerMatch.Groups[1].Value, CultureInfo.InvariantCulture),
44+
NewLineNumber = newLine = int.Parse(headerMatch.Groups[2].Value, CultureInfo.InvariantCulture),
4445
DiffLine = diffLine,
4546
};
4647
}

src/GitHub.Exports/Models/LocalRepositoryModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public bool Equals(LocalRepositoryModel other)
5555
if (ReferenceEquals(this, other))
5656
return true;
5757
return other != null &&
58-
string.Equals(Name, other.Name) &&
59-
string.Equals(Owner, other.Owner) &&
60-
string.Equals(CloneUrl, other.CloneUrl) &&
58+
string.Equals(Name, other.Name, StringComparison.Ordinal) &&
59+
string.Equals(Owner, other.Owner, StringComparison.Ordinal) &&
60+
string.Equals(CloneUrl, other.CloneUrl, StringComparison.Ordinal) &&
6161
string.Equals(LocalPath?.TrimEnd('\\'), other.LocalPath?.TrimEnd('\\'), StringComparison.CurrentCultureIgnoreCase);
6262
}
6363

src/GitHub.InlineReviews/Services/PullRequestSessionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async Task<PullRequestSession> GetSessionInternal(string owner, string name, int
236236

237237
PullRequestSession session = null;
238238
WeakReference<PullRequestSession> weakSession;
239-
var key = Tuple.Create(owner.ToLowerInvariant(), number);
239+
var key = Tuple.Create(owner.ToUpperInvariant(), number);
240240

241241
if (sessions.TryGetValue(key, out weakSession))
242242
{

src/GitHub.TeamFoundation.14/Base/EnsureLoggedInSection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async Task CheckLogin()
5454
bool loggedIn = await ConnectionManager.IsLoggedIn(add);
5555
if (!loggedIn)
5656
{
57-
var msg = string.Format(CultureInfo.CurrentUICulture, Resources.NotLoggedInMessage, add.Title, add.Title);
57+
var msg = string.Format(CultureInfo.CurrentCulture, Resources.NotLoggedInMessage, add.Title, add.Title);
5858
teServices.ShowMessage(
5959
msg,
6060
new Primitives.RelayCommand(_ => dialogService.ShowLoginDialog())

0 commit comments

Comments
 (0)