public LongRunningContext() { workspace = new AdhocWorkspace(ProxyGenerator.CreateHost()); var references = Assembly.GetExecutingAssembly().GetReferencedAssemblies() .Select(name => Assembly.Load(name)) .Concat(new[] { typeof(IProxy).Assembly, typeof(Task).Assembly, }) .Concat(typeof(IProxy).Assembly.GetReferencedAssemblies().Select(x => Assembly.Load(x))) .Where(asm => File.Exists(asm.ManifestModule.FullyQualifiedName)) .Select(asm => MetadataReference.CreateFromFile(asm.ManifestModule.FullyQualifiedName)) .Concat(new[] { MetadataReference.CreateFromFile(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) }); csproj = workspace.AddProject("cscode", LanguageNames.CSharp) .WithCompilationOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)) .WithMetadataReferences(references); csbuild = new AsyncLazy <Compilation>(() => csproj.GetCompilationAsync(new CancellationTokenSource(LongRunningTests.AsyncTimeoutMilliseconds).Token)); vbproj = workspace.AddProject("vbcode", LanguageNames.VisualBasic) .WithCompilationOptions(new VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary)) .WithMetadataReferences(references); vbbuild = new AsyncLazy <Compilation>(() => vbproj.GetCompilationAsync(new CancellationTokenSource(LongRunningTests.AsyncTimeoutMilliseconds).Token)); }
public static (AdhocWorkspace workspace, Project project) CreateWorkspaceAndProject(string language, string assemblyName = "Code") { var workspace = new AdhocWorkspace(ProxyGenerator.CreateHost()); var projectInfo = CreateProjectInfo(language, assemblyName); var project = workspace.AddProject(projectInfo); return(workspace, project); }
public static (Workspace workspace, Project project) CreateWorkspaceAndProject(string language) { var workspace = new AdhocWorkspace(ProxyGenerator.CreateHost()); var project = workspace.AddProject("code", language) .WithCompilationOptions(language == LanguageNames.CSharp ? (CompilationOptions) new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary) : (CompilationOptions) new VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary)) .WithMetadataReferences(ReferencePaths.Paths .Select(path => MetadataReference.CreateFromFile(path))) .AddMetadataReference(MetadataReference.CreateFromFile(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName)); return(workspace, project); }