#message This shows up in the Error List as a Message #1736
Replies: 8 comments
-
Can't you achieve this with a custom analyser that looks for comments beginning with "// MESSAGE:" or similar? |
Beta Was this translation helpful? Give feedback.
-
Visual Studio already supports this out of the box: |
Beta Was this translation helpful? Give feedback.
-
@HaloFour I assumed that was covered under:
Not that I necessarily agree. |
Beta Was this translation helpful? Give feedback.
-
Also, as this can be integrated into the compiler, people without IDEs can use them too. |
Beta Was this translation helpful? Give feedback.
-
There's a reasonable argument that that's true :)
You are conflating two things:
The language does not care what it was hosted in. It didn't make #error and #warning to map to the error list. Similarly, the error list wasn't created to support these particular c# preprocessor directives. |
Beta Was this translation helpful? Give feedback.
-
That's why Analyzers would be a good solution here. One of their core purposes is to allow for this sort of thing, at literally orders of magnitude less cost than actually creating a language feature here. |
Beta Was this translation helpful? Give feedback.
-
Ok, so do I create an issue over at dotnet/roslyn for a proposal about an analyzer for this? |
Beta Was this translation helpful? Give feedback.
-
@Happypig375 I would just go write the analyzer yourself. it would be really trivial to do :) Take a look here for more info! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In C#, we have #error, which produces an error (useful for preventing others from compiling extremely unfinished code), and #warning, which produces a warning (useful for alerting others about problems in code), but there is currently no way to add a Message in the Error List.
The problem this is intended to solve is placing TODOs in code but not forget about them. Most people would place TODOs in a comment and then forget about it. Sure, searching for TODOs once in a while could be a partial solution, but that is not what normal people would remember to do.
Using #warnings would mix compiler-generated warnings with lesser-priority TODOs. Warnings should be fixed as soon as possible, but general TODOs. This is also not an option for 'Treat warnings as errors'.
Putting down all TODOs in some external storage would lose information about the specific locations of code that for example needs to be rewritten, plus losing the help of the IDE to locate the specific location of code that the TODO is referencing.
Having a custom analyzer for this is like saying #errors and #warnings should not be there in the first place. But these are already in the language, so why not enable defining all three types of issues in source and have them show up in the Error List and not leave out one of them?
Using the method of Visual Studio for Mac and listing all TODOs inside a window takes up more screen space than integrating this into the Error List.
Currently the messages that will appear in the Error List already are some kind of TODOs that are analyzed automatically. Having the ability to add a custom one right in the source code would be even better.
Possible other syntaxes:
Beta Was this translation helpful? Give feedback.
All reactions