-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Command line way to apply code fixes #48561
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
Comments
The ASP.NET team would really like this feature. Using the roslyn analyzer to track public API changes is made a lot more difficult for us and external contributors since it requires VS. What would it take to get his out of the backlog? |
Is this something that should be part of dotnet-format? |
@mavasani @sharwell @jaredpar @Pilchie this issue is one that comes up too frequently in dotnet/aspnetcore PRs, especially those from external contributors. The extremely limited ways available to update the Side note: Part of the pain here relates to dotnet/roslyn-analyzers#3901 because the current |
+1 here. I'm adding nullable annotations to a library and almost every public API is complaining. Applying Roslyn fixes from VS an API at a time is tedious. |
@masachs @sharwell @jaredpar if it's possible for the solution to be part of |
@JamesNK I would suggest running the fixer 1 project at a type using the "Fix all in project" link on the preview of an individual fix. That's what I did when I was getting the files set up in the first place. |
@jmarolf and @JoeRobich doesn't dotnet-format already support this scenario and has the ability to apply third party analyzer fixers? |
@mikadumont dotnet-format does support running 3rd party analyzers in the nightly builds. Not sure whether we persist changes to AdditionalFiles properly, but this would be a good test for it. |
Does |
For some reason I thought "Fix all in project" was a context menu option. I forgot it was in the preview window 😮 Doing that does clean up most related errors quickly. |
@dougbu When running analyzers dotnet-format will open your solution/project in a MSBuildWorkspace, so it will have semantic information available to it. |
@JoeRobich Okay, I spent some time playing with this today, and it doesn't seem to work, at least for PublicAPIAnalyzers (maybe because the files they change are not sources)? I put a little repro together at https://github.com/Pilchie/DotNetFormatTest, and was testing by running
|
Side note - why not diagnostics in the output the way that csc does so that existing regexes will find them? |
Yeah, it as I expected. We will need to take extra steps to persist changes to these additional files. Opened dotnet/format#952 to track.
We can look into formatting our output to match csc. Opened dotnet/format#953 to track. |
Roslynator CLI has functionality to analyze project/solution and to apply code fixes automatically.
|
@josefpihrt, maybe I missed something, but I tried using Roslynator to fix the aforementioned public api warnings (RS0016), and got this:
I guess this is happening since to apply the fix, Roslynator would have to change the correct Currently stuck in this, since Rider also has not implemented this. Ppl running on Linux have no automatic way to fix this, it seems :( https://youtrack.jetbrains.com/issue/RIDER-38610 |
@joaopgrassi This seems to be the limitation of MSBuildWorkspace 3.9.0: Good news is that I found the commit which should allow to change additional documents so I hope that it will work as soon as I publish a new version of Roslynator CLI that references Roslyn 3.10.0. |
Just wanted to respond back that dotnet-format global tool currently supports applying code fixes from the commandline including those for the PublicApi analyzer. |
@jmarolf should we close this now that |
yeah, I think this work is done now |
see docs here for how to run analyzers from the commandline |
No description provided.
The text was updated successfully, but these errors were encountered: