Skip to content

Commit 4ccc201

Browse files
NN---RussKie
authored andcommitted
Update packages
Adjust code with the newer code analyzers rules. (cherry picked from commit 584a6b3)
1 parent a265b92 commit 4ccc201

File tree

10 files changed

+73
-60
lines changed

10 files changed

+73
-60
lines changed

GitCommands/StringPool.cs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -178,44 +178,46 @@ internal static unsafe bool EqualsAtIndex(string source, int index, string compa
178178
}
179179

180180
fixed (char* pc = comparand)
181-
fixed (char* ps = source)
182181
{
183-
// Create writeable pointers to equivalent positions in each string
184-
var c = pc;
185-
var s = &ps[index];
186-
187-
// Loop every 10 characters (20 bytes each loop)
188-
while (len >= 10)
182+
fixed (char* ps = source)
189183
{
190-
// Compare an int by int, 5 times
191-
if (*(int*)c != *(int*)s ||
192-
*(int*)(c + 2) != *(int*)(s + 2) ||
193-
*(int*)(c + 4) != *(int*)(s + 4) ||
194-
*(int*)(c + 6) != *(int*)(s + 6) ||
195-
*(int*)(c + 8) != *(int*)(s + 8))
184+
// Create writeable pointers to equivalent positions in each string
185+
var c = pc;
186+
var s = &ps[index];
187+
188+
// Loop every 10 characters (20 bytes each loop)
189+
while (len >= 10)
196190
{
197-
return false;
191+
// Compare an int by int, 5 times
192+
if (*(int*)c != *(int*)s ||
193+
*(int*)(c + 2) != *(int*)(s + 2) ||
194+
*(int*)(c + 4) != *(int*)(s + 4) ||
195+
*(int*)(c + 6) != *(int*)(s + 6) ||
196+
*(int*)(c + 8) != *(int*)(s + 8))
197+
{
198+
return false;
199+
}
200+
201+
// Update the pointers.
202+
// We delay this (rather than using ++ inline) to avoid
203+
// CPU stall on flushing writes.
204+
c += 10;
205+
s += 10;
206+
len -= 10;
198207
}
199208

200-
// Update the pointers.
201-
// We delay this (rather than using ++ inline) to avoid
202-
// CPU stall on flushing writes.
203-
c += 10;
204-
s += 10;
205-
len -= 10;
206-
}
209+
// Loop every 2 characters (4 bytes)
210+
while (len > 1 && *(int*)c == *(int*)s)
211+
{
212+
// Compare int by int (4 bytes each loop)
213+
c += 2;
214+
s += 2;
215+
len -= 2;
216+
}
207217

208-
// Loop every 2 characters (4 bytes)
209-
while (len > 1 && *(int*)c == *(int*)s)
210-
{
211-
// Compare int by int (4 bytes each loop)
212-
c += 2;
213-
s += 2;
214-
len -= 2;
218+
// If last byte has odd index, check it too
219+
return len == 0 || (len == 1 && *c == *s);
215220
}
216-
217-
// If last byte has odd index, check it too
218-
return len == 0 || (len == 1 && *c == *s);
219221
}
220222
}
221223

@@ -269,4 +271,4 @@ internal static unsafe int GetSubstringHashCode(string str, int index, int lengt
269271

270272
#endregion
271273
}
272-
}
274+
}

GitUI/GitUIExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ static string GetSelectedPatch(
110110
if (file.IsSubmodule && file.GetSubmoduleStatusAsync() != null)
111111
{
112112
// Patch already evaluated
113+
#pragma warning disable VSTHRD103 // Call async methods when in an async method (this is intentional for the test)
113114
var status = ThreadHelper.JoinableTaskFactory.Run(file.GetSubmoduleStatusAsync);
115+
#pragma warning restore VSTHRD103 // Call async methods when in an async method
114116
return status != null
115117
? LocalizationHelpers.ProcessSubmoduleStatus(fileViewer.Module, status)
116118
: $"Failed to get status for submodule \"{file.Name}\"";

GitUI/Interops/UxTheme/SetWindowTheme.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ internal static partial class NativeMethods
1010
public static unsafe int SetWindowTheme(IntPtr hWnd, string subAppName, string subIdList)
1111
{
1212
fixed (char* pszSubAppName = subAppName)
13-
fixed (char* pszSubIdList = subIdList)
1413
{
15-
return SetWindowTheme(hWnd, pszSubAppName, pszSubIdList);
14+
fixed (char* pszSubIdList = subIdList)
15+
{
16+
return SetWindowTheme(hWnd, pszSubAppName, pszSubIdList);
17+
}
1618
}
1719
}
1820
}

Plugins/BuildServerIntegration/TeamCityIntegration/TeamCityAdapter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ private void NotifyObserverOfBuilds(string[] buildIds, IObserver<BuildInfo> obse
275275

276276
try
277277
{
278+
#pragma warning disable VSTHRD002
278279
Task.WaitAll(batchTasks, cancellationToken);
280+
#pragma warning restore VSTHRD002
279281
}
280282
catch (Exception e)
281283
{

Plugins/GitUIPluginInterfaces/CredentialsManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static bool SaveCredentials(string target, string userName, string passwo
104104
return false;
105105
}
106106

107-
return CredentialManager.SaveCredentials(GetTarget(target), new NetworkCredential(userName.Trim(), password));
107+
return CredentialManager.SaveCredentials(GetTarget(target), new NetworkCredential(userName.Trim(), password)) != null;
108108
}
109109

110110
private static bool RemoveCredentials(string target)
@@ -128,4 +128,4 @@ public static bool UpdateCredentials(string target, string userName, string pass
128128
}
129129
}
130130
}
131-
}
131+
}

Solution.Versions.props

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
<Project>
22
<PropertyGroup>
33
<!-- Solution dependencies -->
4-
<AdysTechCredentialManagerVersion>1.7.0</AdysTechCredentialManagerVersion>
5-
<AppInsightsWindowsDesktopVersion>2.10.42-preview</AppInsightsWindowsDesktopVersion>
6-
<BenDemystifierVersion>0.1.4</BenDemystifierVersion>
7-
<JetBrainsAnnotationsVersion>2018.2.1</JetBrainsAnnotationsVersion>
8-
<LibGit2SharpVersion>0.25.0</LibGit2SharpVersion>
9-
<MicrosoftVisualStudioCompositionVersion>15.6.36</MicrosoftVisualStudioCompositionVersion>
10-
<MicrosoftVisualStudioThreadingVersion>16.5.132</MicrosoftVisualStudioThreadingVersion>
11-
<NewtonsoftJsonVersion>10.0.3</NewtonsoftJsonVersion>
4+
<AdysTechCredentialManagerVersion>2.1.1</AdysTechCredentialManagerVersion>
5+
<AppInsightsWindowsDesktopVersion>2.13.1</AppInsightsWindowsDesktopVersion>
6+
<BenDemystifierVersion>0.1.6</BenDemystifierVersion>
7+
<JetBrainsAnnotationsVersion>2020.1.0 </JetBrainsAnnotationsVersion>
8+
<LibGit2SharpVersion>0.26.2</LibGit2SharpVersion>
9+
<MicrosoftVisualStudioCompositionVersion>16.4.11 </MicrosoftVisualStudioCompositionVersion>
10+
<MicrosoftVisualStudioThreadingVersion>16.6.13 </MicrosoftVisualStudioThreadingVersion>
11+
<NewtonsoftJsonVersion>12.0.3</NewtonsoftJsonVersion>
1212
<RestSharpVersion>106.11.4</RestSharpVersion>
13-
<SmartFormatNETVersion>2.0.0</SmartFormatNETVersion>
14-
<StyleCopAnalyzersVersion>1.2.0-beta.113</StyleCopAnalyzersVersion>
15-
<SystemCollectionsImmutableVersion>1.5.0</SystemCollectionsImmutableVersion>
16-
<SystemIOAbstractionsVersion>2.0.0.144</SystemIOAbstractionsVersion>
17-
<SystemIOAbstractionsTestingHelpersVersion>2.0.0.143</SystemIOAbstractionsTestingHelpersVersion>
18-
<SystemReactiveVersion>4.2.0</SystemReactiveVersion>
13+
<SmartFormatNETVersion>2.5.0</SmartFormatNETVersion>
14+
<StyleCopAnalyzersVersion>1.2.0-beta.164</StyleCopAnalyzersVersion>
15+
<SystemCollectionsImmutableVersion>1.7.1</SystemCollectionsImmutableVersion>
16+
<SystemIOAbstractionsVersion>11.0.6</SystemIOAbstractionsVersion>
17+
<SystemIOAbstractionsTestingHelpersVersion>11.0.6 </SystemIOAbstractionsTestingHelpersVersion>
18+
<SystemReactiveVersion>4.4.1</SystemReactiveVersion>
1919
<SystemRuntimeInteropServicesRuntimeInformationVersion>4.3.0</SystemRuntimeInteropServicesRuntimeInformationVersion>
2020
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
2121

2222
<!-- Test infra -->
2323
<ApprovalTestsVersion Condition="'$(ApprovalTestsVersion)' == ''">4.4.0</ApprovalTestsVersion>
24-
<FluentAssertionsVersion Condition="'$(FluentAssertionsVersion)' == ''">5.2.0</FluentAssertionsVersion>
25-
<MicrosoftNETTestSdkVersion Condition="'$(MicrosoftNETTestSdkVersion)' == ''">15.9.0</MicrosoftNETTestSdkVersion>
26-
<NSubstituteVersion Condition="'$(NSubstituteVersion)' == ''">3.1.0</NSubstituteVersion>
24+
<FluentAssertionsVersion Condition="'$(FluentAssertionsVersion)' == ''">5.10.3</FluentAssertionsVersion>
25+
<MicrosoftNETTestSdkVersion Condition="'$(MicrosoftNETTestSdkVersion)' == ''">16.6.1</MicrosoftNETTestSdkVersion>
26+
<NSubstituteVersion Condition="'$(NSubstituteVersion)' == ''">4.2.1 </NSubstituteVersion>
2727
<OpenCoverVersion Condition="'$(OpenCoverVersion)' == ''">4.7.922</OpenCoverVersion>
28-
<NUnitConsoleRunnerVersion Condition="'$(NUnitConsoleRunnerVersion)' == ''">3.10.0</NUnitConsoleRunnerVersion>
28+
<NUnitConsoleRunnerVersion Condition="'$(NUnitConsoleRunnerVersion)' == ''">3.11.1</NUnitConsoleRunnerVersion>
2929
<NUnitTestAdapterVersion Condition="'$(NUnitTestAdapterVersion)' == ''">3.16.1</NUnitTestAdapterVersion>
3030
<NUnitVersion Condition="'$(NUnitVersion)' == ''">3.12.0</NUnitVersion>
3131
<UsingToolNUnit Condition="'$(UsingToolNUnit)' == ''">true</UsingToolNUnit>
@@ -34,7 +34,7 @@
3434
<WiXVersion Condition="'$(WiXVersion)' == ''">3.11.2</WiXVersion>
3535

3636
<!-- Build infra -->
37-
<VSWhereVersion Condition="'$(VSWhereVersion)' == ''">2.6.7</VSWhereVersion>
37+
<VSWhereVersion Condition="'$(VSWhereVersion)' == ''">2.8.4</VSWhereVersion>
3838

3939
</PropertyGroup>
4040
</Project>

UnitTests/GitUI.Tests/UserControls/BlameControlTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public void SetUp()
5353
_gitBlameLine = new GitBlameLine(blameCommit1, 1, 1, "line1");
5454

5555
_blameControl = new BlameControl();
56-
_blameControl.GetTestAccessor().Blame = new GitBlame(new GitBlameLine[]
56+
57+
var blameControlTestAccessor = _blameControl.GetTestAccessor();
58+
blameControlTestAccessor.Blame = new GitBlame(new GitBlameLine[]
5759
{
5860
_gitBlameLine,
5961
new GitBlameLine(blameCommit1, 2, 2, "line2"),

UnitTests/GitUI.Tests/UserControls/RevisionGrid/Graph/RevisionGraphMultiThreadingTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public void ShouldReorderInTopoOrder()
5959
buildCacheTask.Start();
6060
renderTask.Start();
6161

62+
#pragma warning disable VSTHRD002
6263
Task.WaitAll(loadRevisionsTask, buildCacheTask, renderTask);
64+
#pragma warning restore VSTHRD002
6365

6466
// One last 'cache to', in case the loading of the revisions was finished after building the cache (unlikely)
6567
_revisionGraph.CacheTo(_revisionGraph.Count, _revisionGraph.Count);
@@ -118,4 +120,4 @@ private void Render()
118120
}
119121
}
120122
}
121-
}
123+
}

UnitTests/ResourceManager.Tests/CommitDataRenders/CommitDataHeaderRendererTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace ResourceManagerTests.CommitDataRenders
1616
[TestFixture]
1717
public class CommitDataHeaderRendererTests
1818
{
19+
private const int MultipleCommits = 2;
1920
private IHeaderLabelFormatter _labelFormatter;
2021
private IHeaderRenderStyleProvider _headerRendererStyleProvider;
2122
private ILinkFactory _linkFactory;
@@ -47,9 +48,9 @@ public void Setup()
4748
_labelFormatter.FormatLabel(ResourceManager.Strings.CommitDate, Arg.Any<int>()).Returns(x => "Commit date: ");
4849
_labelFormatter.FormatLabel(ResourceManager.Strings.CommitHash, Arg.Any<int>()).Returns(x => "Commit hash: ");
4950
_labelFormatter.FormatLabel(ResourceManager.Strings.GetParents(1), Arg.Any<int>()).Returns(x => "Parent: ");
50-
_labelFormatter.FormatLabel(ResourceManager.Strings.GetParents(Arg.Any<int>()), Arg.Any<int>()).Returns(x => "Parents: ");
51+
_labelFormatter.FormatLabel(ResourceManager.Strings.GetParents(MultipleCommits), Arg.Any<int>()).Returns(x => "Parents: ");
5152
_labelFormatter.FormatLabel(ResourceManager.Strings.GetChildren(1), Arg.Any<int>()).Returns(x => "Child: ");
52-
_labelFormatter.FormatLabel(ResourceManager.Strings.GetChildren(Arg.Any<int>()), Arg.Any<int>()).Returns(x => "Children: ");
53+
_labelFormatter.FormatLabel(ResourceManager.Strings.GetChildren(MultipleCommits), Arg.Any<int>()).Returns(x => "Children: ");
5354

5455
_headerRendererStyleProvider = Substitute.For<IHeaderRenderStyleProvider>();
5556
_linkFactory = Substitute.For<ILinkFactory>();

0 commit comments

Comments
 (0)