Skip to content

Commit

Permalink
Remove FxCop (#118)
Browse files Browse the repository at this point in the history
* Replace FxCop with NetAnalyzers

* Address analyzer items

* Remove old ruleset files
  • Loading branch information
pharring committed Apr 24, 2023
1 parent 21234c6 commit 909c73a
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 47 deletions.
9 changes: 2 additions & 7 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

<PropertyGroup>
<Company>Paul Harrington</Company>
<Copyright>Copyright © 2022 Paul Harrington</Copyright>
<Copyright>Copyright © 2023 Paul Harrington</Copyright>
<Version>2.2.9</Version>
<LangVersion>7.3</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnlistmentRoot>$(MSBuildThisFileDirectory)</EnlistmentRoot>
<IsTestProject>$([MSBuild]::MakeRelative($(EnlistmentRoot), $(MSBuildProjectDirectory)).StartsWith('test\'))</IsTestProject>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
Expand All @@ -27,10 +28,4 @@
</AssemblyOriginatorKeyFile>
</PropertyGroup>

<!-- CodeAnalysis Rules-->
<PropertyGroup>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == '' AND ('$(IsTestProject)' == 'true' OR '$(NonShipping)' == 'true')">$(MSBuildThisFileDirectory)\NonShipping.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(MSBuildThisFileDirectory)\Shipping.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

</Project>
4 changes: 0 additions & 4 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@
</PropertyGroup>
</Target>

<ItemGroup Condition="'$(RestoreProjectStyle)' == 'PackageReference'">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="all" />
</ItemGroup>

</Project>
16 changes: 0 additions & 16 deletions NonShipping.ruleset

This file was deleted.

3 changes: 0 additions & 3 deletions Shipping.ruleset

This file was deleted.

4 changes: 0 additions & 4 deletions src/ColumnGuide/ColumnGuideFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ public void TextViewCreated(IWpfTextView textView)
{
// Always create the adornment, even if there are no guidelines, since we
// respond to dynamic changes.
#pragma warning disable IDE0067 // Dispose objects before losing scope
#pragma warning disable CA2000 // Dispose objects before losing scope
var _ = new ColumnGuideAdornment(textView, TextEditorGuidesSettings, GuidelineBrush, CodingConventionsManager);
#pragma warning restore CA2000 // Dispose objects before losing scope
#pragma warning restore IDE0067 // Dispose objects before losing scope
}

public void OnImportsSatisfied()
Expand Down
8 changes: 4 additions & 4 deletions src/ColumnGuide/EditorGuidelinesPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public EditorGuidelinesPackage()
}

/////////////////////////////////////////////////////////////////////////////
// Overriden Package Implementation
// Overridden Package Implementation
#region Package Members

/// <summary>
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initilaization code that rely on services provided by VisualStudio.
/// where you can put all the initialization code that rely on services provided by VisualStudio.
/// </summary>
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
Expand All @@ -95,8 +95,7 @@ protected override async System.Threading.Tasks.Task InitializeAsync(Cancellatio
private string GetShellVersion()
{
ThreadHelper.ThrowIfNotOnUIThread();
var shell = GetService(typeof(SVsShell)) as IVsShell;
if (shell != null)
if (GetService(typeof(SVsShell)) is IVsShell shell)
{
if (ErrorHandler.Succeeded(shell.GetProperty((int)__VSSPROPID5.VSSPROPID_ReleaseVersion, out var obj)) && obj != null)
{
Expand Down Expand Up @@ -215,6 +214,7 @@ private static IVsTextView GetActiveView(IVsWindowFrame windowFrame)
ErrorHandler.ThrowOnFailure(codeWin.GetLastActiveView(out textView));
}
}

return textView;
}

Expand Down
2 changes: 0 additions & 2 deletions src/ColumnGuide/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public static EventTelemetry CreateInitializeTelemetryItem(string name)

private static TelemetryClient CreateClient()
{
#pragma warning disable CA2000 // Dispose objects before losing scope. The TelemetryClient will own it.
var configuration = new TelemetryConfiguration
{
InstrumentationKey = c_instrumentationKey,
Expand All @@ -44,7 +43,6 @@ private static TelemetryClient CreateClient()
#endif
}
};
#pragma warning restore CA2000 // Dispose objects before losing scope

// Keep this context as small as possible since it's sent with every event.
var client = new TelemetryClient(configuration);
Expand Down
4 changes: 4 additions & 0 deletions src/ColumnGuide/TextEditorGuidesSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private int GetCountOfGuidelines()
{
i++;
}

return i;
}

Expand All @@ -186,6 +187,7 @@ private string GuidelinesConfiguration
{
_guidelinesConfiguration = GetUserSettingsString(c_textEditor, "Guides").Trim();
}

return _guidelinesConfiguration;
}

Expand Down Expand Up @@ -227,6 +229,7 @@ public Color GuidelinesColor
}
}
}

return Colors.DarkRed;
}

Expand All @@ -243,6 +246,7 @@ public IEnumerable<int> GuideLinePositionsInChars
{
yield break;
}

if (!config.StartsWith("RGB(", StringComparison.Ordinal))
{
yield break;
Expand Down
12 changes: 5 additions & 7 deletions src/Editor Guidelines.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\Directory.Build.props = ..\Directory.Build.props
..\Directory.Build.targets = ..\Directory.Build.targets
..\global.json = ..\global.json
..\NonShipping.ruleset = ..\NonShipping.ruleset
..\NuGet.Config = ..\NuGet.Config
..\Shipping.ruleset = ..\Shipping.ruleset
EndProjectSection
ProjectSection(FolderGlobals) = preProject
D_5_4EditorGuidelines_4global_1json__JsonSchema =
Expand Down Expand Up @@ -40,11 +38,6 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VSIX_Dev17", "VSIX_Dev17\VSIX_Dev17.csproj", "{FEB7F80E-E565-4119-A18E-D2B9F5E95383}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
ColumnGuide\ColumnGuide.projitems*{5ade1b3f-bc61-42f3-a467-f782d4eff07e}*SharedItemsImports = 5
ColumnGuide\ColumnGuide.projitems*{61d4b2d7-4433-4c71-be24-57a36758ed99}*SharedItemsImports = 13
ColumnGuide\ColumnGuide.projitems*{feb7f80e-e565-4119-a18e-d2b9f5e95383}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -72,4 +65,9 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {64E283A2-5918-46A4-9D2B-83B601BBEBBD}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
ColumnGuide\ColumnGuide.projitems*{5ade1b3f-bc61-42f3-a467-f782d4eff07e}*SharedItemsImports = 5
ColumnGuide\ColumnGuide.projitems*{61d4b2d7-4433-4c71-be24-57a36758ed99}*SharedItemsImports = 13
ColumnGuide\ColumnGuide.projitems*{feb7f80e-e565-4119-a18e-d2b9f5e95383}*SharedItemsImports = 5
EndGlobalSection
EndGlobal

0 comments on commit 909c73a

Please sign in to comment.