0

Duplicate

Custom Compiler Warnings in .NET

I'd like to be able to tag my code with a NotImplementedAttribute and have the compiler either give a warning or an error at build time if the method is used.

I know there is the ObsoleteAttribute, but that communicates something very different.

Community
  • 1
  • 1
ilivewithian
  • 19,476
  • 19
  • 103
  • 165

2 Answers2

1

There's no way you can do anything similar to ObsoleteAttribute. Howerver, you can add #warning directive to your code, so that compiler will emit a warning. However, it will be there until you remove the directive.

Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
1

This has been discussed here:

Custom Compiler Warnings

Community
  • 1
  • 1
Jim Harte
  • 2,593
  • 3
  • 23
  • 20