Пример #1
0
        protected async Task VerifyDiagnosticsAsync(CodeDescriptor descriptor, DiagnosticLocation[] expectedLocations)
        {
            var baseResult = CSharpDiagnostic(DiagnosticId);
            var expected   = expectedLocations.Select(l => baseResult.WithLocation(l.Line, l.Col)).ToArray();

            var doc = CreateProject(new[] { descriptor.Code })
                      .AddMetadataReferences(descriptor.References.Select(assembly => MetadataReference.CreateFromFile(assembly.Location)))
                      .Documents
                      .First();

            var analyzersArray = ImmutableArray.Create(DiagnosticAnalyzer);

            var diag = await GetSortedDiagnosticsFromDocumentsAsync(analyzersArray, new[] { doc }, CancellationToken.None)
                       .ConfigureAwait(false);

            VerifyDiagnosticsAsync(diag, analyzersArray, expected);
        }
Пример #2
0
 protected async Task VerifyDiagnosticsAsync(CodeDescriptor descriptor, DiagnosticLocation expectedLocations)
 {
     await VerifyDiagnosticsAsync(descriptor, new [] { expectedLocations });
 }