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     = ILanguageServiceHostFactory.ImplementHostSpecificErrorReporter(() => reporter);
            var provider = CreateInstance(host);
            var task     = CreateDefaultTask();

            await Assert.ThrowsAsync <Exception>(() => {
                return(provider.AddMessageAsync(task));
            });
        }
        public async Task AddMessageAsync_WhenHostSpecificErrorReporterThrowsNotImplemented_ReturnsNotHandled()
        {
            var reporter = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) =>
            {
                throw new NotImplementedException();
            });

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

            var result = await provider.AddMessageAsync(task);

            Assert.Equal(result, AddMessageResult.NotHandled);
        }
        public async void AddMessageAsync_WhenReporterThrows_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 project  = IProjectWithIntellisenseFactory.ImplementGetExternalErrorReporter(reporter);
            var provider = CreateInstance(project);
            var task     = CreateDefaultTask();

            await Assert.ThrowsAsync <Exception>(() => {
                return(provider.AddMessageAsync(task));
            });
        }
        public async void AddMessageAsync_WhenReporterThrowsNotImplemented_ReturnsNotHandled()
        {
            var reporter = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) =>
            {
                throw new NotImplementedException();
            });

            var project  = IProjectWithIntellisenseFactory.ImplementGetExternalErrorReporter(reporter);
            var provider = CreateInstance(project);
            var task     = CreateDefaultTask();

            var result = await provider.AddMessageAsync(task);

            Assert.Equal(result, AddMessageResult.NotHandled);
        }
        public async void 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 project  = IProjectWithIntellisenseFactory.ImplementGetExternalErrorReporter(reporter);
            var provider = CreateInstance(project);

            await provider.AddMessageAsync(new TargetGeneratedTask()
            {
                BuildEventArgs = new CriticalBuildMessageEventArgs(null, "Code", "File", 1, 1, 1, 1, "Message", "HelpKeyword", "Sender")
            });

            Assert.Equal(result, VSTASKPRIORITY.TP_LOW);
        }
        [InlineData(100, 101, 1, 1, 99, 100)]                                                                                  //  Roslyn's ProjectExternalErrorReporter throws if end is less than start
        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 = ILanguageServiceHostFactory.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 = ILanguageServiceHostFactory.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);
        }
Ejemplo n.º 8
0
        public async void AddMessageAsync_BuildErrorAsTask_CallsReportErrorSettingFileName(string file, string projectFile, string expectedFileName)
        {
            string fileNameResult = "NotSet";
            var    reporter       = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) =>
            {
                fileNameResult = bstrFileName;
            });

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

            var provider = CreateInstance(host);

            var args = new BuildErrorEventArgs(null, "Code", file, 0, 0, 0, 0, "ErrorMessage", "HelpKeyword", "Sender");

            args.ProjectFile = projectFile;
            await provider.AddMessageAsync(new TargetGeneratedError("Test", args));

            Assert.Equal(expectedFileName, fileNameResult);
        }
        public async void AddMessageAsync_BuildErrorAsTask_CallsReportErrorSettingLineAndColumnAdjustingBy1(int lineNumber, int columnNumber, int expectedLineNumber, int expectedColumnNumber)
        {
            int?lineResult   = null;
            int?columnResult = null;
            var reporter     = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) =>
            {
                lineResult   = iLine;
                columnResult = iColumn;
            });

            var project = IProjectWithIntellisenseFactory.ImplementGetExternalErrorReporter(reporter);

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


            Assert.Equal(expectedLineNumber, lineResult);
            Assert.Equal(expectedColumnNumber, columnResult);
        }
        public async void 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 project = IProjectWithIntellisenseFactory.ImplementGetExternalErrorReporter(reporter);

            var provider = CreateInstance(project);
            await provider.AddMessageAsync(new TargetGeneratedTask()
            {
                BuildEventArgs = new BuildErrorEventArgs(null, code, "File", 0, 0, 0, 0, errorMessage, "HelpKeyword", "Sender")
            });


            Assert.Equal(errorMessage, errorMessageResult);
            Assert.Equal(code, errorIdResult);
        }