コード例 #1
0
        public async Task <Tuple <string, string> > GetAssemblyBytesAsync()
        {
            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)
            {
                throw new ScriptCompilationException(CompilationOutput);
            }

            return(await _compilation.GetAssemblyBytesAsync());
        }