XML注释中的filterpriority标记有什么作用?

Sco*_*man 28 .net xml-comments

我已经在.NET Framework BCL中的类的许多XML注释中看到了这一点,但是从来没有找到解释它的功能的文档.

例如,查看System.Object会显示以下注释:

namespace System   
{
    /// <summary>Supports all classes in the .NET Framework class hierarchy 
    /// and provides low-level services to derived classes. This is the 
    /// ultimate base class of all classes in the .NET Framework; it is the
    /// root of the type hierarchy.</summary>
    /// <filterpriority>1</filterpriority> 
    [System.Runtime.InteropServices.ClassInterfaceAttribute(2)]
    public class Object    
    {    
        /// <summary>Determines whether the specified 
        /// <see cref="T:System.Object" /> 
        /// instances are considered equal.</summary>  
        /// <returns>true if objA is the same instance as objB or
        /// if both are null
        /// references or if objA.Equals(objB) returns true; 
        /// otherwise, false.</returns>
        /// <param name="objB">The second <see cref="T:System.Object" /> 
        /// to compare. </param>
        /// <param name="objA">The first <see cref="T:System.Object" /> 
        /// to compare. </param>
        /// <filterpriority>2</filterpriority>
        public static bool Equals(object objA, object objB);
     }
 }
Run Code Online (Sandbox Code Playgroud)

Joe*_*orn 16

只是一个猜测:intellisense中的All vs Common选项卡?

  • 好的...博客文章位于:http://geekswithblogs.net/sdorman/archive/2009/01/08/xml-comments-filterpriority.aspx (8认同)
  • 原来你是对的,这是一个仅VB的功能.filterpriority = 2与EditorBrowsable(EditorBrowsableState.Advanced)等价,并且该方法仅显示在"All"选项卡上.您需要生成一个XML注释文件才能使其生效.C#似乎忽略了评论. (4认同)
  • 您和Øyvind的评论与http://issuu.com/pchew/docs/xml_document_guide/31相关联.在VB和C#项目中添加了一些实际测试,让我完成剩下的工作.在撰写关于此的完整博客文章的过程中.完成后会发布链接. (2认同)

Øyv*_*aar 8

它与使用EditorBrowsableAttribute装饰您的成员相同.我猜测值0,1和2对应于Always,Advanced和Never.

  • 事实证明Joel是正确的,并且这确定了该方法在VB.NET中显示的“智能”选项卡。您也是正确的,因为它在智能感知上提供了与EditorBrowsable(EditorBrowsableState.Advanced)属性相同的行为。 (2认同)