-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Move formatting analyzer to Analyzers
layer
#60549
Conversation
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be fine, @sharwell to confirm
@@ -28,12 +26,14 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context) | |||
{ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving to SyntaxEditorBasedCodeFixProvider
is preferable if possible, and you don't see any breaking changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Yeah sorry for that.
There were two versions of formatting analyzer. One in
Features
and the other is inCodeStyle
. This PR makes a single analyzer inAnalyzers
layer, which is shared between bothCodeStyle
andFeatures
.