在C#用户定义的编译器警告或错误 [英] User defined compiler warning or error in C#

查看:104
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆