question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create [WarningAttribute] and [ErrorAttribute] that triggers compiler warnings/errors the way [ObsoleteAttribute] does.

See original GitHub issue

FEATUREREQUEST 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.

[WarningAttribute] on UserVoice

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:4
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jmarolfcommented, Jul 13, 2020

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.

1reaction
TwoRedCellscommented, Jan 30, 2015

Understandable, more often than not in practice I notice that warnings (such as [Obsolete]) go ignored by developers as they just consider it “noise”.

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. 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found