public async Task SnapshotWithMissingReferencesTest() { var hostServices = MefHostServices.Create( MefHostServices.DefaultAssemblies.Add(typeof(Host.TemporaryStorageServiceFactory.TemporaryStorageService).Assembly)); var project = new AdhocWorkspace(hostServices).CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.CSharp); var metadata = new MissingMetadataReference(); var analyzer = new AnalyzerFileReference("missing_reference", new MissingAnalyzerLoader()); project = project.AddMetadataReference(metadata); project = project.AddAnalyzerReference(analyzer); var snapshotService = (new RemotableDataServiceFactory()).CreateService(project.Solution.Workspace.Services) as IRemotableDataService; using var snapshot = await snapshotService.CreatePinnedRemotableDataScopeAsync(project.Solution, CancellationToken.None).ConfigureAwait(false); // this shouldn't throw var recovered = await GetSolutionAsync(snapshotService, snapshot).ConfigureAwait(false); }
public async Task SnapshotWithMissingReferencesTest() { var hostServices = MefHostServices.Create( MefHostServices.DefaultAssemblies.Add(typeof(Host.TemporaryStorageServiceFactory.TemporaryStorageService).Assembly)); var project = new AdhocWorkspace(hostServices).CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.CSharp); var metadata = new MissingMetadataReference(); var analyzer = new AnalyzerFileReference("missing_reference", new MissingAnalyzerLoader()); project = project.AddMetadataReference(metadata); project = project.AddAnalyzerReference(analyzer); var snapshotService = (new SolutionSynchronizationServiceFactory()).CreateService(project.Solution.Workspace.Services) as ISolutionSynchronizationService; using (var snapshot = await snapshotService.CreatePinnedRemotableDataScopeAsync(project.Solution, CancellationToken.None).ConfigureAwait(false)) { // this shouldn't throw var recovered = await GetSolutionAsync(snapshotService, snapshot).ConfigureAwait(false); } }