字段的详细 XML 文档。有可能吗?

发布于 2024-10-02 07:52:32 字数 922 浏览 0 评论 0原文

我已经为其定义了一个回调字段和事件属性:

private Action<int, int, TaskCallbackArgs> _callbackEvent    
/// <summary>
/// Provides a callback event for task.
/// </summary>
public event Action<int, int, TaskCallbackArgs> CallbackEvent
{
  add
  {
    _callbackEvent += value;
  }
  remove
  {
    _callbackEvent -= value;
  }
}

在我的代码中,我调用了 _callbackEvent。好吧,但是当我输入 _callbackEvent( VS 向我显示 IntelliSense,我的方法需要 (int arg1, int arg2, TaskCallbackArgs arg3) 参数。 当我稍后打开这段代码时,我不记得arg1、arg2和arg3是什么。

有没有办法在字段中使用 XML 文档,如下所示?

/// <summary>
/// Description
/// </summary>
/// <param name="current">Param description...</param>
/// <param name="total">Param description...</param>
/// <param name="additional">Param description...</param>

谢谢!

I have define a callback field and event property for it:

private Action<int, int, TaskCallbackArgs> _callbackEvent    
/// <summary>
/// Provides a callback event for task.
/// </summary>
public event Action<int, int, TaskCallbackArgs> CallbackEvent
{
  add
  {
    _callbackEvent += value;
  }
  remove
  {
    _callbackEvent -= value;
  }
}

In my code I have invoke the _callbackEvent. All right, but when I type _callbackEvent( VS show me IntelliSense that my method want (int arg1, int arg2, TaskCallbackArgs arg3) arguments.
When I open this code some time later I don't remember what is arg1, arg2 and arg3.

Is there a way to use XML Documentation for field as following?

/// <summary>
/// Description
/// </summary>
/// <param name="current">Param description...</param>
/// <param name="total">Param description...</param>
/// <param name="additional">Param description...</param>

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相思故 2024-10-09 07:52:32

Action 是一个带有三个参数的委托类型。
您可以为该字段编写 XML 文档注释,但这仅适用于该字段本身。

要为委托参数添加参数名称和文档注释,您需要创建自己的委托类型。

例如:

/// <summary>
/// Description
/// </summary>
/// <param name="current">Param description...</param>
/// <param name="total">Param description...</param>
/// <param name="additional">Param description...</param>
public delegate void CallbackHandler(int current, int total, TaskCallbackArgs additional);

Action<int, int, TaskCallbackArgs> is a delegate type that takes three parameters.
You can write an XML doc comment for the field, but that will only apply to the field itself.

To add parameter names and doc comments for the delegate parameters, you need to create your own delegate type.

For example:

/// <summary>
/// Description
/// </summary>
/// <param name="current">Param description...</param>
/// <param name="total">Param description...</param>
/// <param name="additional">Param description...</param>
public delegate void CallbackHandler(int current, int total, TaskCallbackArgs additional);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文