Skip to content

Commit 1de8c60

Browse files
authored
Merge pull request #572 from jamill/stylecopanalyzer
Move to Roslyn-based StyleCopAnalyzer
2 parents 2fc0a49 + a650fb7 commit 1de8c60

64 files changed

Lines changed: 254 additions & 536 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

GVFS.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1010
nuget.config = nuget.config
1111
Protocol.md = Protocol.md
1212
Readme.md = Readme.md
13-
Settings.StyleCop = Settings.StyleCop
1413
EndProjectSection
1514
EndProject
1615
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GVFS", "GVFS", "{2EF2EC94-3A68-4ED7-9A58-B7057ADBA01C}"

GVFS/FastFetch/FastFetch.csproj

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@
1818
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
1919
<DebugSymbols>true</DebugSymbols>
2020
<DefineConstants>DEBUG;TRACE</DefineConstants>
21-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2221
<DebugType>full</DebugType>
2322
<PlatformTarget>x64</PlatformTarget>
2423
<ErrorReport>prompt</ErrorReport>
25-
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
2624
<Prefer32Bit>true</Prefer32Bit>
2725
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
2826
</PropertyGroup>
2927
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
3028
<DefineConstants>TRACE</DefineConstants>
3129
<Optimize>true</Optimize>
32-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
3330
<DebugType>pdbonly</DebugType>
3431
<PlatformTarget>x64</PlatformTarget>
3532
<ErrorReport>prompt</ErrorReport>
36-
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
3733
<Prefer32Bit>true</Prefer32Bit>
3834
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
3935
</PropertyGroup>
@@ -86,17 +82,17 @@
8682
<Name>GVFS.Virtualization</Name>
8783
</ProjectReference>
8884
</ItemGroup>
85+
<ItemGroup>
86+
<Analyzer Include="..\..\..\packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
87+
<Analyzer Include="..\..\..\packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
88+
</ItemGroup>
8989
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
9090
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
9191
<PropertyGroup>
9292
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
9393
</PropertyGroup>
94-
<Error Condition="!Exists('..\..\..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets'))" />
9594
<Error Condition="!Exists('..\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\LibGit2Sharp.NativeBinaries.props'))" />
96-
<Error Condition="!Exists('..\..\..\packages\StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets'))" />
9795
</Target>
98-
<Import Project="..\..\..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets" Condition="Exists('..\..\..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets')" />
99-
<Import Project="..\..\..\packages\StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets" Condition="Exists('..\..\..\packages\StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets')" />
10096
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
10197
Other similar extension points exist, see Microsoft.Common.targets.
10298
<Target Name="BeforeBuild">

GVFS/FastFetch/Index.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private bool UpdateFileInformationFromDiskForFiles(MemoryMappedViewAccessor inde
217217
long offset;
218218
if (this.indexEntryOffsets.TryGetValue(gitPath, out offset))
219219
{
220-
if (TryUpdateEntryFromDisk(indexView, localPath, offset))
220+
if (this.TryUpdateEntryFromDisk(indexView, localPath, offset))
221221
{
222222
Interlocked.Increment(ref updatedEntriesFromDisk);
223223
}
@@ -265,7 +265,7 @@ private bool UpdateFileInformationForAllEntries(MemoryMappedViewAccessor indexVi
265265
else if (shouldAlsoTryPopulateFromDisk)
266266
{
267267
string localPath = FromGitRelativePathToWindowsFullPath(currentIndexFilename, this.repoRoot);
268-
if (TryUpdateEntryFromDisk(indexView, localPath, entry.Value))
268+
if (this.TryUpdateEntryFromDisk(indexView, localPath, entry.Value))
269269
{
270270
Interlocked.Increment(ref updatedEntriesFromDisk);
271271
}

GVFS/FastFetch/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
<packages>
33
<package id="CommandLineParser" version="2.1.1-beta" targetFramework="net461" />
44
<package id="LibGit2Sharp.NativeBinaries" version="1.0.165" targetFramework="net461" />
5-
<package id="StyleCop.Error.MSBuild" version="1.0.0" targetFramework="net461" />
6-
<package id="StyleCop.MSBuild" version="5.0.0" targetFramework="net461" developmentDependency="true" />
5+
<package id="StyleCop.Analyzers" version="1.0.2" targetFramework="net461" developmentDependency="true" />
76
</packages>

GVFS/GVFS.Build/GVFS.PreBuild.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<PlatformTarget>x64</PlatformTarget>
1919
<ErrorReport>prompt</ErrorReport>
2020
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
21-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2221
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
2322
</PropertyGroup>
2423
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
@@ -28,7 +27,6 @@
2827
<PlatformTarget>x64</PlatformTarget>
2928
<ErrorReport>prompt</ErrorReport>
3029
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
31-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
3230
</PropertyGroup>
3331
<ItemGroup>
3432
<Compile Include="GenerateApplicationManifests.cs" />

GVFS/GVFS.Build/GVFS.cs.props

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
3+
44
<Import Project="GVFS.props" />
5-
5+
66
<PropertyGroup>
77
<OutputPath>$(BuildOutputDir)\$(MSBuildProjectName)\bin\$(Platform)\$(Configuration)\</OutputPath>
8-
<IntermediateOutputPath>$(BuildOutputDir)\$(MSBuildProjectName)\obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
8+
<IntermediateOutputPath>$(BuildOutputDir)\$(MSBuildProjectName)\obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
99
<IntDir>$(BuildOutputDir)\$(MSBuildProjectName)\intermediate\$(Platform)\$(Configuration)\</IntDir>
1010
</PropertyGroup>
11+
12+
<PropertyGroup>
13+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
14+
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\GVFS.ruleset</CodeAnalysisRuleSet>
15+
</PropertyGroup>
1116

1217
<PropertyGroup>
1318
<DefaultItemExcludes>$(DefaultItemExcludes);StyleCop.Cache;TestResults.xml</DefaultItemExcludes>
1419
</PropertyGroup>
15-
20+
1621
</Project>

GVFS/GVFS.Build/GVFS.ruleset

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Rules for GVFS" Description="Code analysis rules for GVFS projects" ToolsVersion="15.0">
3+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
4+
<Rule Id="SA1003" Action="None" />
5+
<Rule Id="SA1024" Action="None" />
6+
<Rule Id="SA1025" Action="None" />
7+
<Rule Id="SA1028" Action="None" />
8+
<Rule Id="SA1100" Action="None" />
9+
<Rule Id="SA1107" Action="None" />
10+
<Rule Id="SA1115" Action="None" />
11+
<Rule Id="SA1118" Action="None" />
12+
<Rule Id="SA1119" Action="None" />
13+
<Rule Id="SA1120" Action="None" />
14+
<Rule Id="SA1127" Action="None" />
15+
<Rule Id="SA1128" Action="None" />
16+
<Rule Id="SA1129" Action="None" />
17+
<Rule Id="SA1130" Action="None" />
18+
<Rule Id="SA1131" Action="None" />
19+
<Rule Id="SA1133" Action="None" />
20+
<Rule Id="SA1200" Action="None" />
21+
<Rule Id="SA1208" Action="None" />
22+
<Rule Id="SA1300" Action="None" />
23+
<Rule Id="SA1310" Action="None" />
24+
<Rule Id="SA1401" Action="None" />
25+
<Rule Id="SA1512" Action="None" />
26+
<Rule Id="SA1516" Action="None" />
27+
<Rule Id="SA1600" Action="None" />
28+
<Rule Id="SA1601" Action="None" />
29+
<Rule Id="SA1602" Action="None" />
30+
<Rule Id="SA1604" Action="None" />
31+
<Rule Id="SA1605" Action="None" />
32+
<Rule Id="SA1606" Action="None" />
33+
<Rule Id="SA1607" Action="None" />
34+
<Rule Id="SA1608" Action="None" />
35+
<Rule Id="SA1610" Action="None" />
36+
<Rule Id="SA1611" Action="None" />
37+
<Rule Id="SA1612" Action="None" />
38+
<Rule Id="SA1613" Action="None" />
39+
<Rule Id="SA1614" Action="None" />
40+
<Rule Id="SA1615" Action="None" />
41+
<Rule Id="SA1616" Action="None" />
42+
<Rule Id="SA1617" Action="None" />
43+
<Rule Id="SA1618" Action="None" />
44+
<Rule Id="SA1619" Action="None" />
45+
<Rule Id="SA1620" Action="None" />
46+
<Rule Id="SA1621" Action="None" />
47+
<Rule Id="SA1622" Action="None" />
48+
<Rule Id="SA1623" Action="None" />
49+
<Rule Id="SA1624" Action="None" />
50+
<Rule Id="SA1625" Action="None" />
51+
<Rule Id="SA1626" Action="None" />
52+
<Rule Id="SA1627" Action="None" />
53+
<Rule Id="SA1633" Action="None" />
54+
<Rule Id="SA1634" Action="None" />
55+
<Rule Id="SA1635" Action="None" />
56+
<Rule Id="SA1636" Action="None" />
57+
<Rule Id="SA1637" Action="None" />
58+
<Rule Id="SA1638" Action="None" />
59+
<Rule Id="SA1640" Action="None" />
60+
<Rule Id="SA1641" Action="None" />
61+
<Rule Id="SA1642" Action="None" />
62+
<Rule Id="SA1643" Action="None" />
63+
<Rule Id="SA1648" Action="None" />
64+
<Rule Id="SA1649" Action="None" />
65+
<Rule Id="SA1651" Action="None" />
66+
<Rule Id="SA1652" Action="None" />
67+
</Rules>
68+
</RuleSet>

GVFS/GVFS.Common/FileSystem/PhysicalFileSystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public bool TryWaitForDelete(
348348
metadata.Add("path", path);
349349
metadata.Add("failureCount", failureCount + 1);
350350
metadata.Add("maxRetries", maxRetries);
351-
tracer.RelatedWarning(metadata, $"{nameof(TryWaitForDelete)}: Failed to delete file.");
351+
tracer.RelatedWarning(metadata, $"{nameof(this.TryWaitForDelete)}: Failed to delete file.");
352352
}
353353

354354
return false;
@@ -362,7 +362,7 @@ public bool TryWaitForDelete(
362362
metadata.Add("path", path);
363363
metadata.Add("failureCount", failureCount + 1);
364364
metadata.Add("maxRetries", maxRetries);
365-
tracer.RelatedWarning(metadata, $"{nameof(TryWaitForDelete)}: Failed to delete file, retrying ...");
365+
tracer.RelatedWarning(metadata, $"{nameof(this.TryWaitForDelete)}: Failed to delete file, retrying ...");
366366
}
367367
}
368368

GVFS/GVFS.Common/GVFS.Common.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
<ItemGroup>
2323
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="1.0.165" />
2424
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
25-
<PackageReference Include="StyleCop.Error.MSBuild" Version="1.0.0" Condition="'$(OS)' == 'Windows_NT'" />
26-
<PackageReference Include="StyleCop.MSBuild" Version="5.0.0" Condition="'$(OS)' == 'Windows_NT'" />
25+
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
26+
<PrivateAssets>all</PrivateAssets>
27+
</PackageReference>
2728
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
2829
</ItemGroup>
2930
</Project>

GVFS/GVFS.Common/InstallerPreRunChecker.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public bool TryRunPreUpgradeChecks(out string consoleError)
3131
if (this.IsUnattended())
3232
{
3333
consoleError = $"{GVFSConstants.UpgradeVerbMessages.GVFSUpgrade} is not supported in unattended mode";
34-
this.tracer.RelatedError($"{nameof(TryRunPreUpgradeChecks)}: {consoleError}");
34+
this.tracer.RelatedError($"{nameof(this.TryRunPreUpgradeChecks)}: {consoleError}");
3535
return false;
3636
}
3737

3838
if (!this.IsGVFSUpgradeAllowed(out consoleError))
3939
{
40-
this.tracer.RelatedError($"{nameof(TryRunPreUpgradeChecks)}: {consoleError}");
40+
this.tracer.RelatedError($"{nameof(this.TryRunPreUpgradeChecks)}: {consoleError}");
4141
return false;
4242
}
4343

@@ -65,7 +65,7 @@ public bool TryUnmountAllGVFSRepos(out string consoleError)
6565
{
6666
if (!this.TryRunGVFSWithArgs("service --unmount-all", out consoleError))
6767
{
68-
this.tracer.RelatedError($"{nameof(TryUnmountAllGVFSRepos)}: {consoleError}");
68+
this.tracer.RelatedError($"{nameof(this.TryUnmountAllGVFSRepos)}: {consoleError}");
6969
return false;
7070
}
7171

@@ -94,7 +94,7 @@ public bool TryUnmountAllGVFSRepos(out string consoleError)
9494
Environment.NewLine,
9595
"Blocking processes are running.",
9696
$"Run {this.CommandToRerun} again after quitting these processes - " + string.Join(", ", processList.ToArray()));
97-
this.tracer.RelatedError($"{nameof(TryUnmountAllGVFSRepos)}: {consoleError}");
97+
this.tracer.RelatedError($"{nameof(this.TryUnmountAllGVFSRepos)}: {consoleError}");
9898
return false;
9999
}
100100

0 commit comments

Comments
 (0)