-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Implement FixAllProvider for RCS1014 #1070
Implement FixAllProvider for RCS1014 #1070
Conversation
Hi, it would be better to open a new issue first and then open a PR. I used your code sample (+ I used
|
I am surprised that you didn't run into the same issue. But I have opened an Issue as requested that contains a more full description of how to reproduce the issue. #1075 |
src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayFixAllProvider.cs
Outdated
Show resolved
Hide resolved
src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayFixAllProvider.cs
Outdated
Show resolved
Hide resolved
…itlyTypedArrayFixAllProvider.cs Co-authored-by: Josef Pihrt <josef@pihrt.net>
…itlyTypedArrayCodeFixProvider.cs Co-authored-by: Josef Pihrt <josef@pihrt.net>
…itlyTypedArrayCodeFixProvider.cs Co-authored-by: Josef Pihrt <josef@pihrt.net>
src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Josef Pihrt <josef@pihrt.net>
This PR introduces a new FixAllProvider for RCS1014, designed to apply code fixes sequentially in reverse order by location within the document. This approach is safe because applying a given code fix for RCS1014 will not impact the text prior to it.
The FixAllProvider is constructed to minimize its coupling to any RCS1014-specific logic, making it easier to extend for other code fixes that satisfy the following property:
As an aside, when first looking at this, I tried using WellKnownFixAllProviders.BatchFixAll rather than implementing something new. On occasion, this produced garbage code. For example:
Gets converted to the following:
This is an issue within the merge algorithm of WellKnownFixAllProviders.BatchFixAll. After reviewing related issues on the Roslyn GitHub, it became evident that this FixAllProvider is not expected to work in all scenarios, and implementing a custom solution is preferred.