Any way to customize the exceptions section?
Example Code:
public class MyClass
{
public MyClass(Object obj)
{
Contract.Requires<ArgumentNullException>(obj != null);
}
}
Resulting output (in my documentation):
| Exception | Condition |
|---------------------------------|---------------------------------|
| System.ArgumentNullException | obj == null |
This isn't that bad, however I wonder if there is a way to customize the text of the Condition? I attempted to add a user message Contract.Requires<ArgumentNullException>(obj != null, "obj is null.");
, however this did not solve anything.
In the past I had to write my own xml documentation section for exceptions. Am I going to have to do that again to get what I need?
Disclaimer: Since Code Contracts is (currently) a DevLabs project, this could change, but I'm wondering if it's already available right now... if not, I'll be sure to suggest it.
With Code Contracts 1.4.51019.0 you may use the overload:
Requires<TException>(bool condition, string userMessage)
However, your message will be appended after "Precondition failed" followed by the unmatched condition. If Sandcastle doesn't recognize it, I believe that it's not a fault in Code Contracts, since the message appears correctly to me.
链接地址: http://www.djcxy.com/p/10226.html上一篇: c ++ / cli接口头文件
下一篇: 任何方式来定制异常部分?