//----------------------------------------------------------------------------------------------------------------------------------------------------- public static TypeMemberTagCache CreateOnCurrentThread() { if (_s_current != null) { throw new InvalidOperationException("Current thread already has an associated instance of TypeMemberTagCache."); } var cache = new TypeMemberTagCache(); _s_current = cache; return(cache); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- public CompilationResult Compile(ICollection <TypeMember> types) { using (TypeMemberTagCache.CreateOnCurrentThread()) { var syntaxTree = GenerateSyntaxTree(types, out Assembly[] referencedAssemblies); var success = TryCompileNewAssembly( referencedAssemblies, ref syntaxTree, out Assembly assembly, out ImmutableArray <Diagnostic> diagnostics); if (success) { var artifactPerTypeKey = LoadProductAssembly(assembly); var productPerType = CreateProductPerTypeDictionary(types, artifactPerTypeKey); ProductsLoaded?.Invoke(productPerType.Values.ToArray()); return(CreateSuccessfulCompilationResult(types, diagnostics, productPerType)); } return(CreateFailedCompilatioResult(types, diagnostics, syntaxTree)); } }