Esempio n. 1
0
        public CompilationContext(CSharpCompilation compilation,
                                  CompilationProjectContext compilationContext,
                                  IEnumerable<IMetadataReference> incomingReferences,
                                  Func<IList<ResourceDescriptor>> resourcesResolver)
        {
            Project = compilationContext;
            Modules = new List<ICompileModule>();

            _resourcesResolver = resourcesResolver;

            var projectContext = new ProjectContext
            {
                Name = compilationContext.Target.Name,
                ProjectDirectory = compilationContext.ProjectDirectory,
                ProjectFilePath = compilationContext.ProjectFilePath,
                TargetFramework = compilationContext.Target.TargetFramework,
                Version = compilationContext.Version?.ToString(),
                Configuration = compilationContext.Target.Configuration
            };

            _beforeCompileContext = new BeforeCompileContext(
                compilation,
                projectContext,
                ResolveResources,
                () => new List<Diagnostic>(),
                () => new List<IMetadataReference>(incomingReferences)
             );
        }
 private static CompilationSettings GetCompilationSettings(
     ICompilerOptionsProvider compilerOptionsProvider,
     ProjectContext projectContext)
 {
     return compilerOptionsProvider.GetCompilerOptions(projectContext.Name,
                                                       projectContext.TargetFramework,
                                                       projectContext.Configuration)
                                   .ToCompilationSettings(projectContext.TargetFramework);
 }