internal static RootNodeDefinition TestHookParseSyntax(string fbsSchema, Dictionary <string, string> includes = null) { InMemoryIncludeLoader includeLoader = new InMemoryIncludeLoader { { "root.fbs", fbsSchema } }; if (includes != null) { foreach (var kvp in includes) { includeLoader[kvp.Key] = kvp.Value; } } using (ErrorContext.Current) { return(ParseSyntax("root.fbs", includeLoader)); } }
internal static string TestHookCreateCSharp(string fbsSchema, Dictionary <string, string> includes = null) { InMemoryIncludeLoader includeLoader = new InMemoryIncludeLoader { { "root.fbs", fbsSchema } }; if (includes != null) { foreach (var pair in includes) { includeLoader[pair.Key] = pair.Value; } } using (ErrorContext.Current) { return(CreateCSharp(ParseSyntax("root.fbs", includeLoader))); } }
internal static Assembly CompileAndLoadAssembly( string fbsSchema, CompilerOptions options, IEnumerable <Assembly>?additionalReferences = null, Dictionary <string, string>?additionalIncludes = null) { InMemoryIncludeLoader includeLoader = new InMemoryIncludeLoader { { "root.fbs", fbsSchema } }; if (additionalIncludes != null) { foreach (var kvp in additionalIncludes) { includeLoader[kvp.Key] = kvp.Value; } } using (var context = ErrorContext.Current) { context.PushScope("$"); try { Assembly[] additionalRefs = additionalReferences?.ToArray() ?? Array.Empty <Assembly>(); var rootNode = ParseSyntax("root.fbs", includeLoader); string cSharp = CreateCSharp(rootNode, options); var(assembly, formattedText, _) = RoslynSerializerGenerator.CompileAssembly(cSharp, true, additionalRefs); string debugText = formattedText(); return(assembly); } finally { context.PopScope(); } } }