public async Task SetAnalysisRoots() { using (var service = CreateTestService()) { var errors = new List<AnalysisError>(); // Keep track of errors that are reported using (service.AnalysisErrorsNotification.Subscribe(e => errors.AddRange(e.Errors))) { // Send a request to do some analysis. await service.SetAnalysisRoots(new[] { SampleDartProject }); await service.WaitForAnalysis(); // Ensure the error-free file got no errors. errors.Where(e => e.Location.File == HelloWorldFile).Should().BeEmpty(); // Ensure the single-error file got the expected error. var expectedError = new AnalysisError { Location = new Location { File = @"M:\Coding\Applications\DanTup.DartVS\DanTup.DartAnalysis.Tests.SampleDartProject\single_type_error.dart", Length = 1, Offset = 29, StartColumn = 15, StartLine = 2 }, Severity = AnalysisErrorSeverity.Warning, Type = AnalysisErrorType.StaticWarning, Message = "The argument type 'int' cannot be assigned to the parameter type 'String'" }; // At least one error (we may have dupes due to multiple analysis passes). errors.First(e => e.Location.File == SingleTypeErrorFile).ShouldBeEquivalentTo(expectedError); } } }
private ErrorTask CreateErrorTask(AnalysisError analysisError) { return new ErrorTask { ErrorCategory = analysisError.Severity == AnalysisErrorSeverity.Error ? TaskErrorCategory.Error : analysisError.Severity == AnalysisErrorSeverity.Warning ? TaskErrorCategory.Warning : TaskErrorCategory.Message, Text = analysisError.Message, Document = analysisError.Location.File, Line = analysisError.Location.StartLine - 1, // Line appears to be 0-based in VS! :-( Column = analysisError.Location.StartColumn }; }