Exemple #1
0
 private static void PrepareCompilation(ICompilerOptions compilerOptions, out RoslynCompiler compiler,
     out CompilationProjectContext projectContext)
 {
     var cacheContextAccessor = new FakeCacheContextAccessor { Current = new CacheContext(null, (d) => { }) };
     compiler = new RoslynCompiler(null, cacheContextAccessor, new FakeNamedDependencyProvider(), null, null, null);
     var compilationTarget = new CompilationTarget("test", new FrameworkName(".NET Framework, Version=4.0"), "Release", null);
     projectContext = new CompilationProjectContext(
         compilationTarget, Directory.GetCurrentDirectory(), "project.json", "title", "description", "copyright",
         "1.0.0", new System.Version(1, 0), false, new CompilationFiles(Enumerable.Empty<string>(),
         Enumerable.Empty<string>()), compilerOptions);
 }
Exemple #2
0
        private static void PrepareCompilation(ICompilerOptions compilerOptions, out RoslynCompiler compiler,
                                               out CompilationProjectContext projectContext)
        {
            var cacheContextAccessor = new FakeCacheContextAccessor {
                Current = new CacheContext(null, (d) => { })
            };

            compiler = new RoslynCompiler(null, cacheContextAccessor, new FakeNamedDependencyProvider(), null, null, null);
            var compilationTarget = new CompilationTarget("test", new FrameworkName(".NET Framework, Version=4.0"), "Release", null);

            projectContext = new CompilationProjectContext(
                compilationTarget, Directory.GetCurrentDirectory(), "project.json", "title", "description", "copyright",
                "1.0.0", new System.Version(1, 0), false, new CompilationFiles(Enumerable.Empty <string>(),
                                                                               Enumerable.Empty <string>()), compilerOptions);
        }
Exemple #3
0
        private static CompilationContext Compile(FakeCompilerOptions compilerOptions, CompilationTarget target)
        {
            var cacheContextAccessor = new FakeCacheContextAccessor {
                Current = new CacheContext(null, (d) => { })
            };

            var compilationProjectContext = new CompilationProjectContext(
                target,
                Directory.GetCurrentDirectory(),
                "project.json",
                TestTitle,
                TestDescription,
                TestCopyright,
                TestVersion,
                Version.Parse(TestAssemblyFileVersion),
                false,
                new CompilationFiles(
                    new List <string> {
            },
                    new List <string> {
            }),
                compilerOptions);

            var compiler = new RoslynCompiler(null, cacheContextAccessor, new FakeNamedDependencyProvider(), null, null, null);

            var assembly          = typeof(object).GetTypeInfo().Assembly;
            var metadataReference = new FakeMetadataReference()
            {
                MetadataReference = MetadataReference.CreateFromFile((string)assembly.GetType().GetProperty("Location").GetValue(assembly))
            };

            var compilationContext = compiler.CompileProject(
                compilationProjectContext,
                new List <IMetadataReference> {
                metadataReference
            },
                new List <ISourceReference> {
            },
                () => new List <ResourceDescriptor>(),
                "Debug");

            return(compilationContext);
        }
Exemple #4
0
        private static CompilationContext Compile(FakeCompilerOptions compilerOptions, CompilationTarget target)
        {
            var cacheContextAccessor = new FakeCacheContextAccessor {Current = new CacheContext(null, (d) => { })};

            var compilationProjectContext = new CompilationProjectContext(
               target,
                Directory.GetCurrentDirectory(),
                "project.json",
                TestTitle,
                TestDescription,
                TestCopyright,
                TestVersion,
                Version.Parse(TestAssemblyFileVersion),
                false,
                new CompilationFiles(
                    new List<string> {},
                    new List<string> {}),
                compilerOptions);

            var compiler = new RoslynCompiler(null, cacheContextAccessor, new FakeNamedDependencyProvider(), null, null, null);

            var assembly = typeof (object).GetTypeInfo().Assembly;
            var metadataReference = new FakeMetadataReference()
            {
                MetadataReference = MetadataReference.CreateFromFile((string)assembly.GetType().GetProperty("Location").GetValue(assembly))
            };

            var compilationContext = compiler.CompileProject(
                compilationProjectContext,
                new List<IMetadataReference> { metadataReference },
                new List<ISourceReference> {},
                () => new List<ResourceDescriptor>(),
                "Debug");
            return compilationContext;
        }