Move formatting analyzer to Analyzers layer#60549
Move formatting analyzer to Analyzers layer#60549CyrusNajmabadi merged 14 commits intodotnet:mainfrom
Analyzers layer#60549Conversation
| #if CODE_STYLE | ||
| using Formatter = Microsoft.CodeAnalysis.Formatting.FormatterHelper; | ||
| using FormattingProvider = Microsoft.CodeAnalysis.Formatting.ISyntaxFormatting; | ||
| #else | ||
| using FormattingProvider = Microsoft.CodeAnalysis.Host.HostWorkspaceServices; | ||
| #endif |
There was a problem hiding this comment.
Previously, Features was using Mef and CodeStyle was using ISyntaxFormatting. Now both are using ISyntaxFormatting. @mavasani Can you confirm this is the right action?
There was a problem hiding this comment.
I think it should be fine, @sharwell to confirm
| foreach (var diagnostic in context.Diagnostics) | ||
| { | ||
| #pragma warning disable RS0005 // Do not use generic 'CodeAction.Create' to create 'CodeAction' | ||
| context.RegisterCodeFix( |
There was a problem hiding this comment.
@mavasani The one that used to live in Features was inheriting SyntaxEditorBasedCodeFixProvider. While the one that lived in CodeStyle was inheriting CodeFixProvider directly. Does it matter what do I inherit when merging both in Analyzers layer?
There was a problem hiding this comment.
Moving to SyntaxEditorBasedCodeFixProvider is preferable if possible, and you don't see any breaking changes.
|
@mavasani Is this ready to merge? |
|
@Youssef1313 There are merge conflicts |
|
@mavasani I resolved the conflicts. |
src/Analyzers/Core/CodeFixes/Formatting/FormattingCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
...eStyle/CSharp/Tests/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_OptionHelpers.cs
Show resolved
Hide resolved
src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj
Outdated
Show resolved
Hide resolved
...nosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj
Show resolved
Hide resolved
|
This is AWESOME. Thanks so much @Youssef1313 ! |
|
Can someone restart the failing tests please? |
|
Done! |
Head branch was pushed to by a user without write access
|
@CyrusNajmabadi I fixed merge conflicts so auto merge got disabled. Can you enable it again? Thanks! |
|
Done! |
| <ProjectReference Include="..\..\..\Compilers\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj" /> | ||
| <ProjectReference Include="..\..\..\Workspaces\CoreTestUtilities\Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj" /> | ||
| </ItemGroup> | ||
| <Import Project="..\..\..\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems" Label="Shared" /> |
There was a problem hiding this comment.
@Youssef1313 My bad that I did not notice that your change actually deletes a bunch of test projects. C# and VB CodeStyle unit test projects test the analyzers that ship as part of respective CodeStyle NuGet package. I am going to file an issue to restore these projects back.
There was a problem hiding this comment.
Oops. Yeah sorry for that.
There were two versions of formatting analyzer. One in
Featuresand the other is inCodeStyle. This PR makes a single analyzer inAnalyzerslayer, which is shared between bothCodeStyleandFeatures.