Resharper 避免 "Parameter has no matching param in the XML comment" 扩展方法

Resharper avoid "Parameter has no matching param in the XML comment" for extention methods

我有 class 种扩展方法,我希望得到 XML 的好评。

示例函数如下所示

/// <summary>
/// Does something cool and assigns the result to <paramref name="componentVariable"/>.
/// Logs if component cannot be flooped.
/// </summary>
/// <param name="componentVariable">The variable to hold the component</param>
/// <typeparam name="T">The type of the component to be flooped</typeparam>
/// <exception cref="NullReferenceException">Throws if component cannot be found.</exception>
public static void FloopMeTo<T>(this Foo extendedObject, out T componentVariable) where T : Component
{
   ...
}

这一切都很好,除了我收到警告抱怨

Parameter extendedObject has no matching param in the XML comment for [FloopMeTo] (but other parameters do)

这并不理想。

现在我可以评论这个参数,但是,它是一个 this 参数,所以我的方法的使用者永远不会看到它,所以将它添加到 XML 只会让调用者感到困惑。

我还可以添加一个 // ReSharper disable once InvalidXmlDocComment(我将 Rider 用作 IDE),但我不是很喜欢这个解决方案。它并没有很好地捕捉到我的意图,也没有指定我想禁用这个非常具体的警告,但想要关于 XML.

的其他警告

我的问题是,这里有没有更简洁的解决方案。当然,不想记录扩展方法的 this 参数是一个非常常见的用例?

我认为为 extendedObject 添加适当的文档会更清晰,因为在 99% 的情况下,您可能会调用 FloopMeTo<T>() 作为扩展方法,但您不会 必须。你也可以这样写:

var myExtendedObject = new Foo();
YourClass.FloopMeTo<string>(myExtendedObject, out string temp);

总的来说,我认为跟随平台的领导者是一个很好的做法,我。 e.微软在 .NET 的情况下。他们也倾向于记录 this 参数,例如 here.