public void AddGeneratedCodeLeadingTrivia() { string sourceWith = File.ReadAllText(m_targetWithGeneratedCodeLeadingTrivia); string sourceWithout = File.ReadAllText(m_targetWithoutGeneratedCodeLeadingTrivia); SyntaxNode node = SyntaxFactory.ParseSyntaxTree(sourceWithout).GetRoot(); node = CodeGenerateEditorUtility.AddGeneratedCodeLeadingTrivia(node); string result = node.ToFullString(); Assert.AreEqual(sourceWith, result); }
public static string GenerateResolver(IReadOnlyList <string> sourcePaths, string resolverName, string namespaceRoot, Utf8JsonGenerateArguments generateArguments) { if (sourcePaths == null) { throw new ArgumentNullException(nameof(sourcePaths)); } if (string.IsNullOrEmpty(resolverName)) { throw new ArgumentException("Value cannot be null or empty.", nameof(resolverName)); } if (string.IsNullOrEmpty(namespaceRoot)) { throw new ArgumentException("Value cannot be null or empty.", nameof(namespaceRoot)); } string resolver = Utf8JsonUniversalCodeGeneratorUtility.Generate(sourcePaths, resolverName, namespaceRoot, generateArguments); CompilationUnitSyntax unit = SyntaxFactory.ParseCompilationUnit(resolver); unit = CodeGenerateEditorUtility.AddGeneratedCodeLeadingTrivia(unit); return(unit.ToFullString()); }