roslyn
roslyn copied to clipboard
Add IDE analyzer for invalid .editorconfig files
Version Used: N/A
Steps to Reproduce:
Add an invalid .editorconfig (cannot be parsed).
Expected Behavior:
A warning appears in the IDE that the .editorconfig file is ignored due to errors parsing it.
This error cannot occur during builds (compat issue), so it needs to be an IDE analyzer only.
Sadly, this editorconfig work isn't going to fit for 15.3, but we're going to continue targeting the next foundation update.
👍 on this. I have hit multiple issues now (typos, forgetting to add the capitalization option for a naming style, etc).
Not getting any output indicating this badness and having to debug into this is a major pain.
This should be added for naming styles if for no other reason.
@sharwell @mavasani @CyrusNajmabadi My initial thoughts on this is it will be divided into two parts:
- Compiler: Reports a hidden diagnostic for parsing/syntax errors. This diagnostic will be used the same way as the unused using one. This is because the compiler is what's responsible for parsing the editorconfig.
- IDE side: Reports the hidden diagnostic and also diagnostics for invalid option names/values. This is because the compiler doesn't know anything about the code-style options available.
What do you think on that?
I was initially all for this, but now that VS2022 comes with a GUI-based .editorconfig editor, I wonder how relevant this is.
Even when my .editorconfig file contains rules for non-.cs files, VS still opens it in the GUI-based editor, so I have to edit .editorconfig files via notepad. (Is that a bug that I should file?)
Given this, then I if my .editorconfig file only contains rules for .cs files, I'm not sure how helpful this analyzer would be, since the GUI-based .editorconfig editor ensures that the resulting .editorconfig file is always correct. If my .editorconfig file contains rules for non-.cs files, then the analyzer still might not be too helpful, because I can't easily use VS to edit these types of .editorconfig files anyway 🙂
I guess the main use case would be that if I edited my .editorconfig file via an external editor and got the syntax wrong, then VS would show a warning, which would be nice 🙂
Ah, NVM, I just found https://github.com/dotnet/roslyn/issues/53120, so it sounds like this analyzer is still relevant 🙂
There is also a need to include check for conflicts and duplicate entries, the current GUI adds missing entries that duplicate dedicated entries below. I entered as separate issue on that and the fact that it adds missing entries that can conflict.
the current GUI adds missing entries that duplicate dedicated entries below
This is caused by #59325. The UI is expected to only ever add items that the user has changed.
Here's a case where the same property was defined multiple times, but the user was not aware: https://developercommunity.visualstudio.com/t/editorconfig-and-IDE0160/10727150