public async Task GlobalAssets() { var workspace = new AdhocWorkspace(TestHostServices.CreateHostServices()); var analyzerReference = new AnalyzerFileReference(typeof(object).Assembly.Location, new NullAssemblyAnalyzerLoader()); var service = CreateRemoteHostClientService(workspace, SpecializedCollections.SingletonEnumerable <AnalyzerReference>(analyzerReference)); service.Enable(); // make sure client is ready var client = await service.TryGetRemoteHostClientAsync(CancellationToken.None); var checksumService = workspace.Services.GetService <IRemotableDataService>(); var asset = checksumService.GetGlobalAsset(analyzerReference, CancellationToken.None); Assert.NotNull(asset); service.Disable(); var noAsset = checksumService.GetGlobalAsset(analyzerReference, CancellationToken.None); Assert.Null(noAsset); }
public async Task TestUnknownProject() { var workspace = new AdhocWorkspace(TestHostServices.CreateHostServices()); var solution = workspace.CurrentSolution.AddProject("unknown", "unknown", NoCompilationConstants.LanguageName).Solution; var client = (InProcRemoteHostClient)(await InProcRemoteHostClient.CreateAsync(workspace, runCacheCleanup: false)); await UpdatePrimaryWorkspace(client, solution); await VerifyAssetStorageAsync(client, solution); // Only C# and VB projects are supported in Remote workspace. // See "RemoteSupportedLanguages.IsSupported" Assert.Empty(RemoteWorkspace.CurrentSolution.Projects); Assert.NotEqual( await solution.State.GetChecksumAsync(CancellationToken.None), await RemoteWorkspace.CurrentSolution.State.GetChecksumAsync(CancellationToken.None)); solution = solution.RemoveProject(solution.ProjectIds.Single()); Assert.Equal( await solution.State.GetChecksumAsync(CancellationToken.None), await RemoteWorkspace.CurrentSolution.State.GetChecksumAsync(CancellationToken.None)); }
public async Task UpdaterService() { var exportProvider = TestHostServices.CreateMinimalExportProvider(); var workspace = new AdhocWorkspace(TestHostServices.CreateHostServices(exportProvider)); workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.SolutionChecksumMonitorBackOffTimeSpanInMS, 1); var listener = new Listener(); var analyzerReference = new AnalyzerFileReference(typeof(object).Assembly.Location, new NullAssemblyAnalyzerLoader()); var service = CreateRemoteHostClientService(workspace, SpecializedCollections.SingletonEnumerable <AnalyzerReference>(analyzerReference), listener); service.Enable(); // make sure client is ready var client = await service.TryGetRemoteHostClientAsync(CancellationToken.None); // add solution workspace.AddSolution(SolutionInfo.Create(SolutionId.CreateNewId(), VersionStamp.Default)); var listeners = exportProvider.GetExports <IAsynchronousOperationListener, FeatureMetadata>(); var workspaceListener = listeners.First(l => l.Metadata.FeatureName == FeatureAttribute.Workspace).Value as IAsynchronousOperationWaiter; // wait for listener await workspaceListener.CreateWaitTask(); await listener.CreateWaitTask(); // checksum should already exist SolutionStateChecksums checksums; Assert.True(workspace.CurrentSolution.State.TryGetStateChecksums(out checksums)); service.Disable(); }
public static int TestMain(TestHostServices services, string[] args) { return(new Program(services).Run(args)); }
public Program(TestHostServices hostServices) { testHostServices = hostServices; appEnv = PlatformServices.Default.Application; libraryManager = PlatformServices.Default.LibraryManager; }
private TestWorkspace CreateWorkspace(string language, string code, ParseOptions options = null) { var workspace = (language == LanguageNames.CSharp) ? TestWorkspace.CreateCSharp(code, parseOptions: options, exportProvider: TestHostServices.CreateExportProvider()) : TestWorkspace.CreateVisualBasic(code, parseOptions: options, exportProvider: TestHostServices.CreateExportProvider()); workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, true) .WithChangedOption(SolutionCrawlerOptions.BackgroundAnalysisScopeOption, LanguageNames.CSharp, BackgroundAnalysisScope.FullSolution) .WithChangedOption(SolutionCrawlerOptions.BackgroundAnalysisScopeOption, LanguageNames.VisualBasic, BackgroundAnalysisScope.FullSolution); return(workspace); }
private TestWorkspace CreateWorkspace(string language, string code, ParseOptions options = null) { var workspace = (language == LanguageNames.CSharp) ? TestWorkspace.CreateCSharp(code, parseOptions: options, exportProvider: TestHostServices.CreateExportProvider()) : TestWorkspace.CreateVisualBasic(code, parseOptions: options, exportProvider: TestHostServices.CreateExportProvider()); workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.RemoteHostTest, true) .WithChangedOption(ServiceFeatureOnOffOptions.ClosedFileDiagnostic, LanguageNames.CSharp, true) .WithChangedOption(ServiceFeatureOnOffOptions.ClosedFileDiagnostic, LanguageNames.VisualBasic, true); return(workspace); }