当前位置: 首页>>代码示例>>C#>>正文


C# Binder.BindXmlNameAttribute方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Binder.BindXmlNameAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.BindXmlNameAttribute方法的具体用法?C# Binder.BindXmlNameAttribute怎么用?C# Binder.BindXmlNameAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.CSharp.Binder的用法示例。


在下文中一共展示了Binder.BindXmlNameAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindName

        /// <summary>
        /// Bind an XmlNameAttributeSyntax and update the sets of documented parameters and type parameters.
        /// </summary>
        /// <remarks>
        /// Does not respect DocumentationMode, so do not call unless diagnostics are desired.
        /// </remarks>
        private static void BindName(
            XmlNameAttributeSyntax syntax,
            Binder binder,
            Symbol memberSymbol,
            ref HashSet<ParameterSymbol> documentedParameters,
            ref HashSet<TypeParameterSymbol> documentedTypeParameters,
            DiagnosticBag diagnostics)
        {
            XmlNameAttributeElementKind elementKind = syntax.GetElementKind();

            // NOTE: We want the corresponding hash set to be non-null if we saw
            // any <param>/<typeparam> elements, even if they didn't bind (for
            // WRN_MissingParamTag and WRN_MissingTypeParamTag).
            if (elementKind == XmlNameAttributeElementKind.Parameter)
            {
                if (documentedParameters == null)
                {
                    documentedParameters = new HashSet<ParameterSymbol>();
                }
            }
            else if (elementKind == XmlNameAttributeElementKind.TypeParameter)
            {
                if (documentedTypeParameters == null)
                {
                    documentedTypeParameters = new HashSet<TypeParameterSymbol>();
                }
            }

            IdentifierNameSyntax identifier = syntax.Identifier;

            if (identifier.ContainsDiagnostics)
            {
                return;
            }

            HashSet<DiagnosticInfo> useSiteDiagnostics = null;
            ImmutableArray<Symbol> referencedSymbols = binder.BindXmlNameAttribute(syntax, ref useSiteDiagnostics);
            diagnostics.Add(syntax, useSiteDiagnostics);

            if (referencedSymbols.IsEmpty)
            {
                switch (elementKind)
                {
                    case XmlNameAttributeElementKind.Parameter:
                        diagnostics.Add(ErrorCode.WRN_UnmatchedParamTag, identifier.Location, identifier);
                        break;
                    case XmlNameAttributeElementKind.ParameterReference:
                        diagnostics.Add(ErrorCode.WRN_UnmatchedParamRefTag, identifier.Location, identifier, memberSymbol);
                        break;
                    case XmlNameAttributeElementKind.TypeParameter:
                        diagnostics.Add(ErrorCode.WRN_UnmatchedTypeParamTag, identifier.Location, identifier);
                        break;
                    case XmlNameAttributeElementKind.TypeParameterReference:
                        diagnostics.Add(ErrorCode.WRN_UnmatchedTypeParamRefTag, identifier.Location, identifier, memberSymbol);
                        break;
                    default:
                        Debug.Assert(false, "Unknown element kind " + syntax.GetElementKind());
                        break;
                }
            }
            else
            {
                foreach (Symbol referencedSymbol in referencedSymbols)
                {
                    if (elementKind == XmlNameAttributeElementKind.Parameter)
                    {
                        Debug.Assert(referencedSymbol.Kind == SymbolKind.Parameter);
                        Debug.Assert(documentedParameters != null);

                        // Restriction preserved from dev11: don't report this for the "value" parameter.
                        // Here, we detect that case by checking the containing symbol - only "value"
                        // parameters are contained by accessors, others are on the corresponding property/event.
                        ParameterSymbol parameter = (ParameterSymbol)referencedSymbol;
                        if (!parameter.ContainingSymbol.IsAccessor() && !documentedParameters.Add(parameter))
                        {
                            diagnostics.Add(ErrorCode.WRN_DuplicateParamTag, syntax.Location, identifier);
                        }
                    }
                    else if (elementKind == XmlNameAttributeElementKind.TypeParameter)
                    {
                        Debug.Assert(referencedSymbol.Kind == SymbolKind.TypeParameter);
                        Debug.Assert(documentedTypeParameters != null);

                        if (!documentedTypeParameters.Add((TypeParameterSymbol)referencedSymbol))
                        {
                            diagnostics.Add(ErrorCode.WRN_DuplicateTypeParamTag, syntax.Location, identifier);
                        }
                    }
                }
            }
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:97,代码来源:DocumentationCommentCompiler.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Binder.BindXmlNameAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。