public static void ProcessIncludes( string unprocessed, Symbol memberSymbol, ImmutableArray <CSharpSyntaxNode> sourceIncludeElementNodes, CSharpCompilation compilation, ref HashSet <ParameterSymbol> documentedParameters, ref HashSet <TypeParameterSymbol> documentedTypeParameters, ref DocumentationCommentIncludeCache includedFileCache, TextWriter writer, BindingDiagnosticBag diagnostics, CancellationToken cancellationToken) { // If there are no include elements, then there's nothing to expand. // NOTE: By skipping parsing and re-writing, we avoid slightly // modifying the whitespace, as we would if we let the XmlWriter // do the writing. This saves us a lot of work in the common case // but slightly reduces consistency when include elements are // present. if (sourceIncludeElementNodes.IsEmpty) { if (writer != null) { writer.Write(unprocessed); } return; } XDocument doc; try { // NOTE: XDocument.Parse seems to do a better job of preserving whitespace // than XElement.Parse. doc = XDocument.Parse(unprocessed, LoadOptions.PreserveWhitespace); } catch (XmlException e) { // If one of the trees wasn't diagnosing doc comments, then an error might have slipped through. // Otherwise, we shouldn't see exceptions from XDocument.Parse. Debug.Assert(sourceIncludeElementNodes.All(syntax => syntax.SyntaxTree.Options.DocumentationMode < DocumentationMode.Diagnose), "Why didn't our parser catch this exception? " + e); if (writer != null) { writer.Write(unprocessed); } return; } cancellationToken.ThrowIfCancellationRequested(); IncludeElementExpander expander = new IncludeElementExpander( memberSymbol, sourceIncludeElementNodes, compilation, documentedParameters, documentedTypeParameters, includedFileCache, diagnostics, cancellationToken); foreach (XNode node in expander.Rewrite(doc, currentXmlFilePath: null, originatingSyntax: null)) { cancellationToken.ThrowIfCancellationRequested(); if (writer != null) { writer.Write(node); } } Debug.Assert(expander._nextSourceIncludeElementIndex == expander._sourceIncludeElementNodes.Length); documentedParameters = expander._documentedParameters; documentedTypeParameters = expander._documentedTypeParameters; includedFileCache = expander._includedFileCache; }
public static void ProcessIncludes( string unprocessed, Symbol memberSymbol, ImmutableArray<CSharpSyntaxNode> sourceIncludeElementNodes, CSharpCompilation compilation, ref HashSet<ParameterSymbol> documentedParameters, ref HashSet<TypeParameterSymbol> documentedTypeParameters, ref DocumentationCommentIncludeCache includedFileCache, TextWriter writer, DiagnosticBag diagnostics, CancellationToken cancellationToken) { // If there are no include elements, then there's nothing to expand. // NOTE: By skipping parsing and re-writing, we avoid slightly // modifying the whitespace, as we would if we let the XmlWriter // do the writing. This saves us a lot of work in the common case // but slightly reduces consistency when include elements are // present. if (sourceIncludeElementNodes.IsEmpty) { if (writer != null) { writer.Write(unprocessed); } return; } XDocument doc; try { // NOTE: XDocument.Parse seems to do a better job of preserving whitespace // than XElement.Parse. doc = XDocument.Parse(unprocessed, LoadOptions.PreserveWhitespace); } catch (XmlException e) { // If one of the trees wasn't diagnosing doc comments, then an error might have slipped through. // Otherwise, we shouldn't see exceptions from XDocument.Parse. Debug.Assert(sourceIncludeElementNodes.All(syntax => syntax.SyntaxTree.Options.DocumentationMode < DocumentationMode.Diagnose), "Why didn't our parser catch this exception? " + e); if (writer != null) { writer.Write(unprocessed); } return; } cancellationToken.ThrowIfCancellationRequested(); IncludeElementExpander expander = new IncludeElementExpander( memberSymbol, sourceIncludeElementNodes, compilation, documentedParameters, documentedTypeParameters, includedFileCache, diagnostics, cancellationToken); foreach (XNode node in expander.Rewrite(doc, currentXmlFilePath: null, originatingSyntax: null)) { cancellationToken.ThrowIfCancellationRequested(); if (writer != null) { writer.Write(node); } } Debug.Assert(expander.nextSourceIncludeElementIndex == expander.sourceIncludeElementNodes.Length); documentedParameters = expander.documentedParameters; documentedTypeParameters = expander.documentedTypeParameters; includedFileCache = expander.includedFileCache; }