/// <summary>
        /// Executes the parsing process.
        /// </summary>
        /// <param name="context">The compilation context.</param>
        public void Execute(CompilationContext context)
        {
            if (context.Input == null)
                throw new CompilationException("The compilation input cannot be null.");

            var compilation = CreateCompilation(context.Input);

            // workaround for project refs bug in Roslyn June 2012 CTP
            var fileRefs = compilation.References.OfType<AssemblyFileReference>();
            compilation = compilation.RemoveReferences(fileRefs)
                .AddReferences(fileRefs.Select(r => new AssemblyFileReference(r.Path)));

            // set the compilation
            context.Compilation = compilation;
        }
Beispiel #2
0
        /// <summary>
        /// Executes the compilation process.
        /// </summary>
        /// <param name="compilation">The compilation object.</param>
        /// <param name="outputStream">The output stream to write to.</param>
        /// <returns>The compilation result.</returns>
        public CompilationResult Execute(CompilationRequest input, Stream outputStream)
        {
            var context = new CompilationContext
            {
                Input = input,
                OutputStream = outputStream,
                Result = new CompilationResult()
            };

            // TODO: move model registry into 
            // compilation context instance

            // this locks the current scope
            ModelRegistry.BeginRegistration();
            CompilationContext.Current = context;
            var profiler = new ProcessProfiler();

            try
            {
                foreach (var proc in _processes)
                {
                    profiler.Execute(proc, context);
                    if (context.Result.HasErrors)
                        break;
                }
            }
            catch (CompilationException compEx)
            {
                context.Result.AddError(compEx.ToErrorMessage());
            }
            catch (Exception ex)
            {
                context.Result.AddError("Unexpected Error: " + ex.Message);
            }
            finally
            {
                // release lock
                ModelRegistry.EndRegistration();
                CompilationContext.Current = null;
                profiler.End();
            }

            return context.Result;
        }
        /// <summary>
        /// Executes the compilation process.
        /// </summary>
        /// <param name="compilation">The compilation object.</param>
        /// <param name="outputStream">The output stream to write to.</param>
        /// <returns>The compilation result.</returns>
        public CompilationResult Compile(CommonCompilation compilation, Stream outputStream)
        {
            var context = new CompilationContext
            {
                Compilation = compilation,
                OutputStream = outputStream,
                Result = new CompilationResult()
            };

            // this locks the current scope
            ModelRegistry.BeginRegistration();
            var profiler = new ProcessProfiler();

            try
            {
                foreach (var proc in _processes)
                {
                    profiler.Execute(proc, context);
                    if (context.Result.HasErrors)
                        break;
                }
            }
            catch (CompilationException compEx)
            {
                context.Result.AddError(compEx.ToErrorMessage());
            }
            catch (Exception ex)
            {
                context.Result.AddError("Unexpected Error: " + ex.Message);
            }
            finally
            {
                // release lock
                ModelRegistry.EndRegistration();
                profiler.End();
            }

            return context.Result;
        }
Beispiel #4
0
 public void Execute(ICompilationProcess process, CompilationContext context)
 {
     Begin(process);
     process.Execute(context);
     End();
 }