Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run naming style analyzer #720

Merged
merged 3 commits into from Jul 6, 2020
Merged

Conversation

JoeRobich
Copy link
Member

No description provided.

@JoeRobich JoeRobich marked this pull request as ready for review July 4, 2020 00:54
@JoeRobich JoeRobich requested a review from jmarolf July 4, 2020 00:55
@JoeRobich JoeRobich changed the title Run naming style analyzer and fixer Run naming style analyzer Jul 4, 2020
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/dotnet-format/Debug/netcoreapp2.1/publish/dotnet-format.dll",
"program": "${workspaceFolder}/artifacts/bin/dotnet-format/Debug/netcoreapp2.1/dotnet-format.dll",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the dotnet-format project to copy package assemblies into build folder. This is needed for finding the Feature assemblies.

@@ -165,5 +173,42 @@ static void LogDiagnosticLocations(Solution solution, IEnumerable<Diagnostic> di

return solution;
}

internal static async Task<ImmutableDictionary<Project, ImmutableArray<DiagnosticAnalyzer>>> FilterBySeverityAsync(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from the AnalyzerFinderHelpers.

@@ -47,7 +49,7 @@ internal partial class AnalyzerRunner : IAnalyzerRunner
foreach (var diagnostic in diagnostics)
{
if (!diagnostic.IsSuppressed &&
diagnostic.Severity >= DiagnosticSeverity.Warning &&
diagnostic.Severity >= severity &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to filter on the correct severity.

{
private static readonly string s_executingPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

private readonly string _featuresPath = Path.Combine(s_executingPath, "Microsoft.CodeAnalysis.Features.dll");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some analyzers and fixers are language agnostic.

@@ -13,6 +13,9 @@
<NoWarn>$(NoWarn);8002</NoWarn>
<Description>Command line tool for formatting C# and Visual Basic code files based on .editorconfig settings.</Description>

<!-- Copy nuget assemblies to build directory. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes running debug builds easier.

@@ -44,7 +44,7 @@ public async Task TestFilterError()
var allAnalyzers = await GetAnalyzersAsync();
var formattablePaths = ImmutableHashSet.Create(projects.First().Documents.First().FilePath);
var minimumSeverity = DiagnosticSeverity.Error;
var result = await AnalyzerFinderHelpers.FilterBySeverityAsync(projects,
var result = await AnalyzerFormatter.FilterBySeverityAsync(projects,
allAnalyzers,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alight with line above

@@ -28,7 +28,7 @@ public async Task TestFilterWarning()
var allAnalyzers = await GetAnalyzersAsync();
var formattablePaths = ImmutableHashSet.Create(projects.First().Documents.First().FilePath);
var minimumSeverity = DiagnosticSeverity.Warning;
var result = await AnalyzerFinderHelpers.FilterBySeverityAsync(projects,
var result = await AnalyzerFormatter.FilterBySeverityAsync(projects,
allAnalyzers,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alight with line above

Copy link
Contributor

@jmarolf jmarolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@JoeRobich JoeRobich merged commit c4c3ca0 into dotnet:master Jul 6, 2020
@JoeRobich JoeRobich deleted the naming-style branch March 5, 2021 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants