Move few CodeFixProviders to Analyzers layer#60524
Conversation
685eb2e to
603e64f
Compare
|
Making a draft for now since it doesn't yet build successfully. I'll be force-pushing so you can wait on reviewing until it builds. |
92d4545 to
e8c0ca8
Compare
CodeFixProviders to Analyzers layer
47ac429 to
ece3473
Compare
|
@mavasani One of the codefixes I'm moving in this PR is using |
ece3473 to
62f628a
Compare
62f628a to
087bc2c
Compare
|
@mavasani I attempted to move those
This is very confusing :( |
| var options = _document.Project.AnalyzerOptions.GetAnalyzerOptionSet(_node.SyntaxTree, cancellationToken); | ||
| #else | ||
| var options = await _document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); | ||
| #endif |
There was a problem hiding this comment.
man, i would love an extension for this.
| CodeFixesResources.Add_explicit_cast, | ||
| actions.ToImmutable(), isInlinable: false), | ||
| context.Diagnostics); | ||
| #pragma warning restore RS0005 // Do not use generic 'CodeAction.Create' to create 'CodeAction' |
| var groupingTitle = string.Format(CodeFixesResources.Alias_ambiguous_type_0, diagnosticNode.ToString()); | ||
| #pragma warning disable RS0005 // Do not use generic 'CodeAction.Create' to create 'CodeAction' | ||
| var groupingCodeAction = CodeAction.Create(groupingTitle, codeActionsBuilder.ToImmutable(), isInlinable: true); | ||
| #pragma warning restore RS0005 // Do not use generic 'CodeAction.Create' to create 'CodeAction' |
There was a problem hiding this comment.
@CyrusNajmabadi I don't think there is a problem regarding the suppression.
The analyzer will be removed soon anyway when @mavasani PR that fixes telemetry is merged.
There are already few suppressions also anyway.
Source link the generator code |
@CyrusNajmabadi I ended up with the same compile errors after adding some needed files using <ItemGroup>
<Compile Include="..\..\..\Workspaces\CSharp\Portable\CodeGeneration\ExpressionGenerator.cs" Link="CodeGeneration\CSharp\ExpressionGenerator.cs" />
<Compile Include="..\..\..\Workspaces\CSharp\Portable\CodeGeneration\CSharpFlagsEnumGenerator.cs" Link="CodeGeneration\CSharp\CSharpFlagsEnumGenerator.cs" />
<Compile Include="..\..\..\Workspaces\CSharp\Portable\CodeGeneration\CSharpSyntaxGenerator.cs" Link="CodeGeneration\CSharp\CSharpSyntaxGenerator.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\CodeGenerationHelpers.cs" Link="CodeGeneration\Core\ExpressionGenerator.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\CodeGenerationOptions.cs" Link="CodeGeneration\Core\CodeGenerationOptions.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\CodeGenerationContext.cs" Link="CodeGeneration\Core\CodeGenerationContext.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\LiteralSpecialValues.cs" Link="CodeGeneration\Core\LiteralSpecialValues.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\AbstractFlagsEnumGenerator.cs" Link="CodeGeneration\Core\AbstractFlagsEnumGenerator.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\CodeGenerator.cs" Link="CodeGeneration\Core\CodeGenerator.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\ICodeGenerationService.cs" Link="CodeGeneration\Core\ICodeGenerationService.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\Symbols\CodeGenerationSymbol.cs" Link="CodeGeneration\Core\Symbols\CodeGenerationContext.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\CodeGeneration\CodeGenerationDestination.cs" Link="CodeGeneration\Core\CodeGenerationDestination.cs" />
</ItemGroup> |
|
@CyrusNajmabadi I think I understood why it doesn't compile. The members that have the errors I mentioned above are I tried adding |
|
@mavasani @CyrusNajmabadi I'm going to move the specific problematic |
|
@CyrusNajmabadi @mavasani This is ready for review. |
|
I believe we have SyntaxGenerator and SyntaxGeneratorInternal for this reason. |
|
@CyrusNajmabadi I'll take a look into that in another PR. There are lots of work to move everything to |
|
@Youssef1313 I had taken a stab at moving CodeGeneration pieces down to the shared layer, and just as you disccovered, it leads to a lot of cascading changes. I also filed #43056 for making relevant APIs public, but that would need a design proposal and discussion. If you are interested, feel free to take a stab at coming up with the API proposal. Additionally, this issue tracks bunch more cleanup/porting/follow-up items for the move down to the shared analyzers/fixes layer. Feel free to pick up anything from there if you are interested. Thank you again for your efforts here! |
...haredUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/IAddImportsService.cs
Outdated
Show resolved
Hide resolved
mavasani
left a comment
There was a problem hiding this comment.
Mostly LGTM - have a code refactoring suggestion. Once you address/respond, I can merge the PR. Thanks!
|
@mavasani Thanks for review! Can you take another look? |
...haredUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/IAddImportsService.cs
Show resolved
Hide resolved
|
@Youssef1313 You also have merge conflicts. |
This doesn't move everything. I may open follow up PRs.
@mavasani Can you take a look please?