【问题标题】:What does the filterpriority tag in an XML comment do?XML 注释中的 filterpriority 标记有什么作用?
【发布时间】:2008-11-11 16:19:06
【问题描述】:

我在 .NET Framework BCL 中的许多类的 XML cmets 中看到了这一点,但从未找到解释其作用的文档。

例如,查看 System.Object 会发现以下 cmets:

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);
     }
 }

【问题讨论】:

    标签: .net xml-comments


    【解决方案1】:

    只是猜测:智能感知中的 All 与 Common 选项卡?

    【讨论】:

    • 可能是这样,但这些选项卡仅在 IDE 中适用于 VB 项目而不是 C#。所以,如果这真的是一个仅适用于 C# 的功能,则不适用。
    • 事实证明你是对的,这是 VB 独有的功能。 filterpriority = 2 等效于 EditorBrowsable(EditorBrowsableState.Advanced) 并且该方法仅显示在“全部”选项卡上。您确实需要生成一个 XML 注释文件才能使其正常工作。 C# 似乎忽略了注释。
    • 你能发一个链接到你找到那个的地方吗?我很好奇,因为我想知道如果 xml 不同意该属性会如何表现。
    • 您和 Øyvind 的 cmets 与 issuu.com/pchew/docs/xml_document_guide/31 结合。在 VB 和 C# 项目中添加了一些实际测试让我完成了剩下的工作。在撰写有关此的完整博客文章的过程中。完成后会发布链接。
    【解决方案2】:

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

    【讨论】:

    • XML 注释与使用 EditorBrowsableAttribute 进行装饰有何相同之处?
    • 更准确地说;它在 Visual Studio 中具有相同的效果。它控制不显示在 Intellisense 下拉列表中的成员。
    • 事实证明 Joel 是正确的,这决定了该方法在 VB.NET 中出现的智能感知选项卡。您也是正确的,因为它在智能感知上提供了与 EditorBrowsable(EditorBrowsableState.Advanced) 属性相同的行为。
    • 而且 EditorBrowsable 在 VS2013 中仍然有效,而 filterpriority 被忽略了。
    猜你喜欢
    • 2023-02-01
    • 1970-01-01
    • 2011-02-14
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-23
    • 1970-01-01
    相关资源
    最近更新 更多