dotnet / roslynator

Roslynator is a set of code analysis tools for C#, powered by Roslyn.
https://josefpihrt.github.io/docs/roslynator
Other
3.09k stars 256 forks source link

Quick start guide #754

Open marcospgp opened 3 years ago

marcospgp commented 3 years ago

I installed the VSCode extension after looking for something that would enforce a style for my project's code, but I have found the documentation to be lacking in terms of how to get started with the package.

It seems that rules are being enforced by default? How do I see which? The file roslynator.ruleset doesn't seem to specify any.

What is the difference between the different possible values for Action? `"None,Hidden,Info,Warning,Error"

I've checked the documentation and still am not sure how to configure the rules for my project, or where to look for a list of these rules, or how to apply refactors, etc.

Thanks!

Edit: Since the line <!-- <Include Path="" Action="Default,None,Hidden,Info,Warning,Error" /> --> is commented out below, shouldn't there be no active rules by default??

image

Yet I am getting warnings:

image

marcospgp commented 3 years ago

Another question: Is there a way to enable these analyzers?

https://github.com/microsoft/Microsoft.Unity.Analyzers

josefpihrt commented 3 years ago

Documentation related to Roslynator is here: https://github.com/JosefPihrt/Roslynator/blob/master/docs/AnalyzersVsRefactorings.md https://github.com/JosefPihrt/Roslynator/blob/master/docs/HowToConfigureAnalyzers.md https://github.com/JosefPihrt/Roslynator/blob/master/docs/HowToConfigureRulesetFile.md https://github.com/JosefPihrt/Roslynator/blob/master/docs/HowToCustomizeRulesForProject.md

List of analyzers is here ('None' means that the analyzer is disabled by default): https://github.com/JosefPihrt/Roslynator/tree/master/src/Analyzers https://github.com/JosefPihrt/Roslynator/tree/master/src/CodeAnalysis.Analyzers https://github.com/JosefPihrt/Roslynator/tree/master/src/Formatting.Analyzers

Documentation related to code analysis generally is here (I used Google to find it): https://docs.microsoft.com/en-us/visualstudio/code-quality/roslyn-analyzers-overview?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2019

To your second comment: please ask them.

marcospgp commented 3 years ago

The issue is that, as you showed, the documentation is a little scattered - and it's not easy to get a quick start with the package.

The comments in the configuration file are not very clear, especially since at first sight it would seem that no analyzers would be enabled by default, which isn't the case.

In my opinion it would be better to have a tutorial on how to set up Roslynator on Visual Studio Code without using the extension, so that it is easier to have it working alongside other sets of analyzers - such as the Unity one I mentioned above.

I believe the idea is basically what I wrote here, except one would download Roslynator's .dlls instead of Microsoft's.