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,146
  • 19
  • 100
  • 163

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
  • 110,157
  • 37
  • 194
  • 282
1

This has been discussed here:

Custom Compiler Warnings

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