Create [WarningAttribute] and [ErrorAttribute] that triggers compiler warnings/errors the way [ObsoleteAttribute] does.
See original GitHub issueFEATUREREQUEST COMPILER
Add a [WarningAttribute]
or [CompilerWarningAttribute]
and [CompilerErrorAttribute]
that works the same way as [ObsoleteAttribute]
; it would trigger a compiler warning or error with a customized message. Ideally it would not be sealed
. You could do things like:
[Warning("This class uses PInvoke and will prevent ARM compatibility.")]
[Experimental("This method has not completed Quality Assurance, and should not be used in a production environment.")]
This feature would be particularly useful for component creators.
This would be the bees’ knees.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:4
- Comments:11 (4 by maintainers)
Top Results From Across the Web
c# - Custom Compiler Warnings
Specifically, the compiler issues a warning if no error parameter is provided, or if the error parameter is provided and has the value...
Read more >[Solved] How to throw a compiler warning/error like ...
The compiler service looks for this attribute and displays the warnings in the dialog box. However, you can raise warnings yourself, like: C#....
Read more >Warning Options (Using the GNU Compiler Collection (GCC))
Warn if the compiler detects paths that trigger erroneous or undefined behavior due to dereferencing a null pointer. This option is only active...
Read more >ObsoleteAttribute Class (System)
Accessing the value of the OldProperty property in code generates a compiler warning, but calling the CallOldMethod method generates a compiler error. The ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am here to say, as someone actively working on analyzers for Microsoft, that they are not deprecated. Just trying to understand what was said to give this impression out there in the blog-o-sphere.
Good point. That’s part of the issue I’m trying to address. Attributes subclassing
[CompilerErrorAttribute]
simply would not compile. Warnings of course could be ignored (at their peril). I’m one of those jerks who forces my programmers in submission by checking Treat errors as warnings, and enabling XML comments. 😃