我正在编写一个 C# 类库,其中包含许多类,这些类的功能几乎相同。我需要提供关于每个类中的函数参数的 XML 注释,这些注释非常详细但在大多数情况下是相同的。有没有一种方法可以重用 XML 注释,这样我就不必在整个程序集中重复这些 XML 参数定义?
这是我的类(class)示例:
public class IsodoseControl : TestModule
{
/// <summary>
/// Verify a control on Isodose dialog
/// </summary>
/// <param name="args"> **<-- WHAT I DON'T WANT TO KEEP REPEATING**
/// Arguments: [Property, Condition, Expected Value, Tolerance]
/// Properties: STATE, VALUE, LABEL
/// Conditions: Exists, DoesNotExist, IsEnabled, IsDisabled, ...
/// Expected Value (optional): blah blah
/// Tolerance (optional): blah blah blah
/// </param>
public VerifResult VerifyIsodoseControl(string[] args)
{
...
}
}
public class BeamControl : TestModule
{
/// <summary>
/// Verify a control on Beam dialog
/// </summary>
/// <param name="args"> **<-- WHAT I DON'T WANT TO KEEP REPEATING**
/// Arguments: [Property, Condition, Expected Value, Tolerance]
/// Properties: STATE, VALUE, LABEL
/// Conditions: Exists, DoesNotExist, IsEnabled, IsDisabled, ...
/// Expected Value (optional): blah blah
/// Tolerance (optional): blah blah blah
/// </param>
public VerifResult VerifyBeamControl(string[] args)
{
...
}
}
谢谢
最佳答案
“
您可以使用
/// <include file='comments.xml' path='MyDocs/MyMembers[@name="test"]/*' />
class OneClass {}
/// <include file='comments.xml' path='MyDocs/MyMembers[@name="test"]/*' />
class DifferentClassWithTheSameFunctionality {}
此链接提供了一些使用
关于C# XML 注释重用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17172342/