在C#用户定义的编译器警告或错误 [英] User defined compiler warning or error in C#
问题描述
是否有可能有一些代码让编译器生成编译警告或错误?
也许与属性?
**
有了第一个答案和一些意见,我知道我的问题是不是作为一个明确的如我所料,并希望它是。我道歉。希望所有的贡献者仍然伴随着我们。结果
**
因此,我更期待对内部DSL。
S.Th。像
[MustAssign]
公共字符串的Val {获得;设置]
你的意思的#警告?
指令#warning 可以生成从一个特定的位置,在你的代码中的一级预警。例如:
块引用>
在这个方法已过时指令#warning代码。
和错误,有(你永远不会猜到)的#错误。
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;]
解决方案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.
这篇关于在C#用户定义的编译器警告或错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!