Exemplo n.º 1
0
        // This can be removed once changes in https://github.com/dotnet/roslyn/pull/15494 are merged and deployed
        private string GetNamespaceDocumentationCommentXml(INamespaceSymbol symbol)
        {
            // Try and get comments applied to the namespace
            TextWriter        writer = new StringWriter();
            CancellationToken ct     = new CancellationToken();
            object            documentationCompiler = Activator.CreateInstance(_documentationCommentCompiler, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[]
            {
                (string)null,
                _compilation,
                writer,
                (SyntaxTree)null,
                (TextSpan?)null,
                true,
                true,
                null,
                ct
            }, null);

            _documentationCommentCompilerDefaultVisit.Invoke(documentationCompiler, new object[] { symbol });
            string docs = writer.ToString();

            // Fall back to looking for a NamespaceDoc class
            if (string.IsNullOrEmpty(docs))
            {
                INamespaceOrTypeSymbol namespaceDoc = symbol.GetMembers("NamespaceDoc").FirstOrDefault();
                if (namespaceDoc != null)
                {
                    return(namespaceDoc.GetDocumentationCommentXml(expandIncludes: true));
                }
            }

            return(docs ?? string.Empty);
        }