4

Is it possible to have some code let the compiler generate a compile warning or error?

Maybe with Attributes?

** Having the first answer and a few comments I realize my question is not as a clear as I expected and wanted it to be. I apologize. Hopefully all contributers are still with us.
**

So I am more looking towards an internal DSL.

S.Th. like

[MustAssign]
public string Val {get; set;]
Martin Meeser
  • 2,784
  • 2
  • 28
  • 41

1 Answers1

7

Do you mean #warning ?

#warning lets you generate a level one warning from a specific location in your code. For example:

#warning Deprecated code in this method.

And for errors, there is (you would never guess), #error.

CompuChip
  • 9,143
  • 4
  • 24
  • 48
  • This is great and I did not know about that (+1). However - I edited my question - I would like to have some logic behind it - code that runs during compilation - and then creates Compiler Error – Martin Meeser Jul 17 '14 at 12:40
  • @MartinMeeser Did u find any solution?? – nucleons Nov 28 '14 at 10:28