2

Is anyone aware of any attribute (analogous to [Obsolete]) or similar mechanism to ask the compiler to raise a warning if a particular class is referenced (at design-time) by other projects? Note I cannot make it 'internal' because I'm databinding to System.* (or 3rd-party) controls so they have to be public.

Note I use [Obsolete] as an analogy, the class is not obsolete. I just want compiler warnings for out-of-project design-time references.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
AlanR
  • 1,162
  • 4
  • 14
  • 26
  • possible duplicate of [Custom Compiler Warnings](http://stackoverflow.com/questions/154109/custom-compiler-warnings) – Robert Levy Dec 28 '11 at 20:33
  • please show some examples of references that are ok and references that are not... – Yahia Dec 28 '11 at 20:34
  • @RobertLevy Not a duplicate. I want the warning to be raised based on whether the reference is internal or from other user projects. – AlanR Dec 28 '11 at 20:45
  • @AlanR Apparently this is doable using PostSharp. Take a look at this question: http://stackoverflow.com/questions/1420143/generating-a-custom-compile-time-warning-c-sharp – M.Babcock Dec 28 '11 at 20:46
  • @M.Babcock very interesting. put it as an answer and I'll accept it. – AlanR Dec 28 '11 at 20:57

2 Answers2

1

Based on the answer to this question, it looks like it would be doable using PostSharp. Here is a link from the answer that describes some detail which might help.

Community
  • 1
  • 1
M.Babcock
  • 18,753
  • 6
  • 54
  • 84
0

This is the closest thing I could find -- http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx

AlanR
  • 1,162
  • 4
  • 14
  • 26