Beispiel #1
0
        public TestWorkspace(
            ExportProvider?exportProvider = null,
            TestComposition?composition   = null,
            string?workspaceKind          = WorkspaceKind.Host,
            bool disablePartialSolutions  = true,
            bool ignoreUnchangeableDocumentsWhenApplyingChanges = true
            ) : base(GetHostServices(exportProvider, composition), workspaceKind ?? WorkspaceKind.Host)
        {
            Contract.ThrowIfTrue(exportProvider != null && composition != null);

            this.TestHookPartialSolutionsDisabled = disablePartialSolutions;
            this.ExportProvider =
                exportProvider
                ?? GetComposition(composition).ExportProviderFactory.CreateExportProvider();
            _workspaceKind               = workspaceKind ?? WorkspaceKind.Host;
            this.Projects                = new List <TestHostProject>();
            this.Documents               = new List <TestHostDocument>();
            this.AdditionalDocuments     = new List <TestHostDocument>();
            this.AnalyzerConfigDocuments = new List <TestHostDocument>();
            this.ProjectionDocuments     = new List <TestHostDocument>();

            this.CanApplyChangeDocument = true;
            this.IgnoreUnchangeableDocumentsWhenApplyingChanges =
                ignoreUnchangeableDocumentsWhenApplyingChanges;

            if (
                Services.GetService <INotificationService>() is INotificationServiceCallback callback
                )
            {
                // Avoid showing dialogs in tests by default
                callback.NotificationCallback = (message, title, severity) =>
                {
                    var severityText = severity switch
                    {
                        NotificationSeverity.Information => "💡",
                        NotificationSeverity.Warning => "⚠",
                        _ => "❌"
                    };

                    var fullMessage = string.IsNullOrEmpty(title)
                      ? message
                      : $"{title}:{Environment.NewLine}{Environment.NewLine}{message}";

                    throw new InvalidOperationException($"{severityText} {fullMessage}");
                };
            }

            _backgroundCompiler = new BackgroundCompiler(this);
            _backgroundParser   = new BackgroundParser(this);
            _backgroundParser.Start();

            _metadataAsSourceFileService = ExportProvider
                                           .GetExportedValues <IMetadataAsSourceFileService>()
                                           .FirstOrDefault();

            RegisterDocumentOptionProviders(
                ExportProvider.GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>()
                );
        }
Beispiel #2
0
        internal VisualStudioWorkspace(HostServices hostServices, WorkspaceBackgroundWork backgroundWork)
            : base(hostServices, WorkspaceKind.Host)
        {
            if ((backgroundWork & WorkspaceBackgroundWork.Compile) != 0)
            {
                _backgroundCompiler = new BackgroundCompiler(this);
            }

            if ((backgroundWork & WorkspaceBackgroundWork.Parse) != 0)
            {
                _backgroundParser = new BackgroundParser(this);
                _backgroundParser.Start();
            }
        }
        internal VisualStudioWorkspace(HostServices hostServices)
            : base(hostServices, WorkspaceKind.Host)
        {
            _backgroundCompiler = new BackgroundCompiler(this);

            var cacheService = Services.GetService <IWorkspaceCacheService>();

            if (cacheService != null)
            {
                cacheService.CacheFlushRequested += OnCacheFlushRequested;
            }

            _backgroundParser = new BackgroundParser(this);
            _backgroundParser.Start();
        }
        private void OnCacheFlushRequested(object sender, EventArgs e)
        {
            if (_backgroundCompiler != null)
            {
                _backgroundCompiler.Dispose();
                _backgroundCompiler = null; // PartialSemanticsEnabled will now return false
            }

            // No longer need cache notifications
            var cacheService = Services.GetService <IWorkspaceCacheService>();

            if (cacheService != null)
            {
                cacheService.CacheFlushRequested -= OnCacheFlushRequested;
            }
        }
        public TestWorkspace(ExportProvider exportProvider, string workspaceKind = null, bool disablePartialSolutions = true)
            : base(MefV1HostServices.Create(exportProvider.AsExportProvider()), workspaceKind ?? WorkspaceName)
        {
            ResetThreadAffinity();

            this.TestHookPartialSolutionsDisabled = disablePartialSolutions;
            this.ExportProvider      = exportProvider;
            this.Projects            = new List <TestHostProject>();
            this.Documents           = new List <TestHostDocument>();
            this.AdditionalDocuments = new List <TestHostDocument>();
            this.ProjectionDocuments = new List <TestHostDocument>();

            this.CanApplyChangeDocument = true;

            _backgroundCompiler = new BackgroundCompiler(this);
            _backgroundParser   = new BackgroundParser(this);
            _backgroundParser.Start();
        }
Beispiel #6
0
        public TestWorkspace(ExportProvider exportProvider, string workspaceKind = null, bool disablePartialSolutions = true)
            : base(VisualStudioMefHostServices.Create(exportProvider), workspaceKind ?? WorkspaceKind.Test)
        {
            this.TestHookPartialSolutionsDisabled = disablePartialSolutions;
            this.ExportProvider      = exportProvider;
            this.Projects            = new List <TestHostProject>();
            this.Documents           = new List <TestHostDocument>();
            this.AdditionalDocuments = new List <TestHostDocument>();
            this.ProjectionDocuments = new List <TestHostDocument>();

            this.CanApplyChangeDocument = true;

            _backgroundCompiler = new BackgroundCompiler(this);
            _backgroundParser   = new BackgroundParser(this);
            _backgroundParser.Start();

            _metadataAsSourceFileService = exportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault();
        }
Beispiel #7
0
        public TestWorkspace(ExportProvider exportProvider, string?workspaceKind = null, bool disablePartialSolutions = true, bool ignoreUnchangeableDocumentsWhenApplyingChanges = true)
            : base(VisualStudioMefHostServices.Create(exportProvider), workspaceKind ?? WorkspaceKind.Test)
        {
            this.TestHookPartialSolutionsDisabled = disablePartialSolutions;
            this.ExportProvider          = exportProvider;
            this.Projects                = new List <TestHostProject>();
            this.Documents               = new List <TestHostDocument>();
            this.AdditionalDocuments     = new List <TestHostDocument>();
            this.AnalyzerConfigDocuments = new List <TestHostDocument>();
            this.ProjectionDocuments     = new List <TestHostDocument>();

            this.CanApplyChangeDocument = true;
            this.IgnoreUnchangeableDocumentsWhenApplyingChanges = ignoreUnchangeableDocumentsWhenApplyingChanges;

            _backgroundCompiler = new BackgroundCompiler(this);
            _backgroundParser   = new BackgroundParser(this);
            _backgroundParser.Start();

            _metadataAsSourceFileService = exportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault();

            RegisterDocumentOptionProviders(exportProvider.GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>());
        }
Beispiel #8
0
 private void Worker_DoWork(object sender, DoWorkEventArgs e)
 {
     BackgroundCompiler.Compile();
 }
					: super("Compile") {
				setPriority(Job.DECORATE);
				this.compiler = compiler;
			}
			CompileJob(BackgroundCompiler compiler)
					: super("Compile") {
Beispiel #11
0
 private void BuildPreviewStart(object sender, DoWorkEventArgs e)
 {
     BackgroundCompiler.Compile();
 }
Beispiel #12
0
     : super("Compile")
 {
     setPriority(Job.DECORATE);
     this.compiler = compiler;
 }
Beispiel #13
0
 CompileJob(BackgroundCompiler compiler)
     : super("Compile")