public void RemoveDocCommentNode() { var oldSource = @" /// <see cref='C'/> class C { } "; var expectedNewSource = @" /// class C { } "; var oldTree = CSharpTestBase.Parse( oldSource, options: TestOptions.RegularWithDocumentationComments ); var oldRoot = oldTree.GetRoot(); var xmlNode = oldRoot .DescendantNodes(descendIntoTrivia: true) .OfType <XmlEmptyElementSyntax>() .Single(); var newRoot = oldRoot.RemoveNode(xmlNode, SyntaxRemoveOptions.KeepDirectives); Assert.Equal(expectedNewSource, newRoot.ToFullString()); }
protected override SyntaxTree ParseSyntaxTree(string content, string fileName, SourceHashAlgorithm hashAlgorithm, CSharpParseOptions?parseOptions) => CSharpTestBase.Parse( content, filename: fileName, checksumAlgorithm: hashAlgorithm, encoding: Encoding.UTF8, options: parseOptions);
public static CSharpCompilation CreateStandardCompilation( string text, IEnumerable <MetadataReference> references = null, CSharpCompilationOptions options = null, CSharpParseOptions parseOptions = null, string assemblyName = "", string sourceFileName = "") { return(CreateStandardCompilation( new[] { CSharpTestBase.Parse(text, sourceFileName, parseOptions) }, references: references, options: options, assemblyName: assemblyName)); }
internal static CSharpCompilation WithSource(this CSharpCompilation compilation, string newSource) { return(compilation.RemoveAllSyntaxTrees().AddSyntaxTrees(CSharpTestBase.Parse(newSource))); }