/// <summary> /// Initializes the entry point by compiling the script and loading/saving the assembly /// </summary> /// <param name="assemblyInitType"></param> /// <returns></returns> public async Task InitializeEntryPointAsync() { ICompilationService compilationService = CompilationServiceFactory.CreateService(_entityMetaData, GetScriptOptions(_frameworkReferences)); _compilation = await compilationService.GetCompilationAsync(); _diagnostics = await _compilation.GetDiagnosticsAsync(); IsCompilationSuccessful = !_diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error); CompilationOutput = _diagnostics.Select(m => m.ToString()); if (IsCompilationSuccessful) { try { EntityMethodSignature methodSignature = _compilation.GetEntryPointSignature(); Assembly assembly = await _compilation.EmitAssemblyAsync(); _entryPointMethodInfo = methodSignature.GetMethod(assembly); InitializeAttributes(); Validate(); } catch (Exception ex) { if (ex is ScriptCompilationException scriptEx) { IsCompilationSuccessful = false; if (scriptEx.CompilationOutput.Any()) { CompilationOutput = CompilationOutput.Concat(scriptEx.CompilationOutput); } return; } throw ex; } } }