private static LanguageServiceErrorListProvider CreateInstance(IActiveWorkspaceProjectContextHost projectContextHost)
        {
            projectContextHost ??= IActiveWorkspaceProjectContextHostFactory.Create();

            var provider = new LanguageServiceErrorListProvider(UnconfiguredProjectFactory.Create(), projectContextHost);

            return(provider);
        }
Beispiel #2
0
        private static VsContainedLanguageComponentsFactory CreateInstance(IOleAsyncServiceProvider serviceProvider = null, IUnconfiguredProjectVsServices projectVsServices = null, IActiveWorkspaceProjectContextHost projectContextHost = null)
        {
            projectVsServices  = projectVsServices ?? IUnconfiguredProjectVsServicesFactory.Create();
            projectContextHost = projectContextHost ?? IActiveWorkspaceProjectContextHostFactory.Create();

            return(new VsContainedLanguageComponentsFactory(IVsServiceFactory.Create <SAsyncServiceProvider, IOleAsyncServiceProvider>(serviceProvider),
                                                            projectVsServices,
                                                            projectContextHost));
        }
        public async Task AddMessageAsync_ReturnsHandledAndStopProcessing()
        {
            var reporter = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) => { });
            var host     = IActiveWorkspaceProjectContextHostFactory.ImplementHostSpecificErrorReporter(() => reporter);
            var provider = CreateInstance(host);
            var task     = CreateDefaultTask();

            var result = await provider.AddMessageAsync(task);

            Assert.Equal(AddMessageResult.HandledAndStopProcessing, result);
        }
Beispiel #4
0
        public void GetProjectName_WhenActiveIntellisenseProjectContextNotSet_ReturnsActiveHostContextId(string contextId)
        {
            var activeWorkspaceProjectContextHost = IActiveWorkspaceProjectContextHostFactory.ImplementContextId(contextId);
            var instance = CreateInstance(activeWorkspaceProjectContextHost);

            var context = IWorkspaceProjectContextMockFactory.Create();

            instance.RegisterContext(context, contextId);

            instance.GetProjectName(HierarchyId.Root, out string result);

            Assert.Equal(contextId, result);
        }
Beispiel #5
0
        [InlineData("contextId")]           // Case-sensitive
        public void IsActiveEditorContext_WhenActiveIntellisenseProjectContextNotSet_UsesActiveHostContextId(string contextId)
        {
            var activeWorkspaceProjectContextHost = IActiveWorkspaceProjectContextHostFactory.ImplementContextId(contextId);
            var instance = CreateInstance(activeWorkspaceProjectContextHost);

            var context = IWorkspaceProjectContextMockFactory.Create();

            instance.RegisterContext(context, contextId);

            var result = instance.IsActiveEditorContext(context);

            Assert.True(result);
        }
Beispiel #6
0
        public async Task ClearAllAsync_WhenHostSpecificErrorReporter_CallsClearErrors()
        {
            int callCount = 0;
            var reporter  = IVsLanguageServiceBuildErrorReporter2Factory.ImplementClearErrors(() => { callCount++; return(0); });
            var host      = IActiveWorkspaceProjectContextHostFactory.ImplementHostSpecificErrorReporter(() => reporter);
            var task      = CreateDefaultTask();
            var provider  = CreateInstance(host);

            await provider.AddMessageAsync(task);   // Force initialization

            await provider.ClearAllAsync();

            Assert.Equal(1, callCount);
        }
        public async Task AddMessageAsync_CriticalBuildMessageTaskAsTask_PassesTP_LOWAsPriority()
        {
            VSTASKPRIORITY?result   = null;
            var            reporter = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) =>
            {
                result = nPriority;
            });
            var host     = IActiveWorkspaceProjectContextHostFactory.ImplementHostSpecificErrorReporter(() => reporter);
            var provider = CreateInstance(host);

            await provider.AddMessageAsync(new TargetGeneratedError("Test", new CriticalBuildMessageEventArgs(null, "Code", "File", 1, 1, 1, 1, "Message", "HelpKeyword", "Sender")));

            Assert.Equal(VSTASKPRIORITY.TP_LOW, result);
        }
        public async Task AddMessageAsync_WhenHostSpecificErrorReporterThrows_Throws()
        {
            var reporter = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) =>
            {
                throw new Exception();
            });

            var host     = IActiveWorkspaceProjectContextHostFactory.ImplementHostSpecificErrorReporter(() => reporter);
            var provider = CreateInstance(host);
            var task     = CreateDefaultTask();

            await Assert.ThrowsAsync <Exception>(() =>
            {
                return(provider.AddMessageAsync(task));
            });
        }
Beispiel #9
0
            public TestTempPEBuildManager(IFileSystem fileSystem)
                : base(IProjectThreadingServiceFactory.Create(),
                       IUnconfiguredProjectCommonServicesFactory.Create(threadingService: IProjectThreadingServiceFactory.Create()),
                       IActiveWorkspaceProjectContextHostFactory.Create(),
                       IActiveConfiguredProjectSubscriptionServiceFactory.Create(),
                       null,
                       fileSystem,
                       IProjectFaultHandlerServiceFactory.Create(),
                       null)
            {
                BuildManager = new TestBuildManager(this);

                AppliedValue = new ProjectVersionedValue <DesignTimeInputsItem>(new DesignTimeInputsItem()
                {
                    OutputPath = "TempPE"
                }, ImmutableDictionary <NamedIdentity, IComparable> .Empty);
            }
        public async Task AddMessageAsync_BuildErrorAsTask_CallsReportErrorSettingEndLineAndColumn(int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, int expectedEndLineNumber, int expectedEndColumnNumber)
        {
            int?endLineResult   = null;
            int?endColumnResult = null;
            var reporter        = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) =>
            {
                endLineResult   = iEndLine;
                endColumnResult = iEndColumn;
            });

            var host = IActiveWorkspaceProjectContextHostFactory.ImplementHostSpecificErrorReporter(() => reporter);

            var provider = CreateInstance(host);
            await provider.AddMessageAsync(new TargetGeneratedError("Test", new BuildErrorEventArgs(null, "Code", "File", lineNumber, columnNumber, endLineNumber, endColumnNumber, "ErrorMessage", "HelpKeyword", "Sender")));


            Assert.Equal(expectedEndLineNumber, endLineResult);
            Assert.Equal(expectedEndColumnNumber, endColumnResult);
        }
        public async Task AddMessageAsync_BuildErrorAsTask_CallsReportErrorSettingErrorMessageAndCode(string errorMessage, string code)
        {
            string errorMessageResult = "NotSet";
            string errorIdResult      = "NotSet";
            var    reporter           = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) =>
            {
                errorMessageResult = bstrErrorMessage;
                errorIdResult      = bstrErrorId;
            });

            var host = IActiveWorkspaceProjectContextHostFactory.ImplementHostSpecificErrorReporter(() => reporter);

            var provider = CreateInstance(host);
            await provider.AddMessageAsync(new TargetGeneratedError("Test", new BuildErrorEventArgs(null, code, "File", 0, 0, 0, 0, errorMessage, "HelpKeyword", "Sender")));


            Assert.Equal(errorMessage, errorMessageResult);
            Assert.Equal(code, errorIdResult);
        }
Beispiel #12
0
        public void GetProjectName_WhenActiveIntellisenseProjectContextSetToNull_ReturnsActiveHostContextId(string contextId)
        {
            var activeWorkspaceProjectContextHost = IActiveWorkspaceProjectContextHostFactory.ImplementContextId(contextId);
            var instance = CreateInstance(activeWorkspaceProjectContextHost);

            var context = IWorkspaceProjectContextMockFactory.Create();

            instance.RegisterContext(context, contextId);

            // Set it the value first
            instance.ActiveIntellisenseProjectContext = contextId;

            // Now explicitly set to null
            instance.ActiveIntellisenseProjectContext = null;

            instance.GetProjectName(HierarchyId.Root, out string result);

            Assert.Equal(contextId, result);
        }
Beispiel #13
0
        [InlineData("contextId")]           // Case-sensitive
        public void IsActiveEditorContext_WhenActiveIntellisenseProjectContextSetToNull_UsesActiveHostContextId(string contextId)
        {
            var activeWorkspaceProjectContextHost = IActiveWorkspaceProjectContextHostFactory.ImplementContextId(contextId);
            var instance = CreateInstance(activeWorkspaceProjectContextHost);

            var context = IWorkspaceProjectContextMockFactory.Create();

            instance.RegisterContext(context, contextId);

            // Set it the value first
            instance.ActiveIntellisenseProjectContext = contextId;

            // Now explicitly set to null
            instance.ActiveIntellisenseProjectContext = null;

            var result = instance.IsActiveEditorContext(context);

            Assert.True(result);
        }