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 = ILanguageServiceHostFactory.ImplementHostSpecificErrorReporter(() => reporter); var provider = CreateInstance(host); var task = CreateDefaultTask(); var result = await provider.AddMessageAsync(task); Assert.Equal(AddMessageResult.HandledAndStopProcessing, result); }
public async void AddMessageAsync_ReturnsHandledAndStopProcessing() { var reporter = IVsLanguageServiceBuildErrorReporter2Factory.ImplementReportError((string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, int iEndLine, int iEndColumn, string bstrFileName) => { }); var project = IProjectWithIntellisenseFactory.ImplementGetExternalErrorReporter(reporter); var provider = CreateInstance(project); var task = CreateDefaultTask(); var result = await provider.AddMessageAsync(task); Assert.Equal(result, AddMessageResult.HandledAndStopProcessing); }
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 host = ILanguageServiceHostFactory.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(result, VSTASKPRIORITY.TP_LOW); }
public async void AddMessageAsync_ErrorTaskAsTask_PassesTP_HIGHAsPriority() { 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 TargetGeneratedError("Test", new BuildErrorEventArgs(null, "Code", "File", 1, 1, 1, 1, "Message", "HelpKeyword", "Sender"))); Assert.Equal(result, VSTASKPRIORITY.TP_HIGH); }
public async Task AddMessageAsync_WarningTaskAsTask_PassesTP_NORMALAsPriority() { 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 BuildWarningEventArgs(null, "Code", "File", 1, 1, 1, 1, "Message", "HelpKeyword", "Sender"))); Assert.Equal(VSTASKPRIORITY.TP_NORMAL, result); }
public async void 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 void 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); }
[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); }
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); }