protected override async Task <Document> GetChangedSuppressionDocumentAsync( CancellationToken cancellationToken ) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken) .ConfigureAwait(false); var workspace = suppressionsDoc.Project.Solution.Workspace; var suppressionsRoot = await suppressionsDoc .GetSyntaxRootAsync(cancellationToken) .ConfigureAwait(false); var compilation = await suppressionsDoc.Project .GetCompilationAsync(cancellationToken) .ConfigureAwait(false); var addImportsService = suppressionsDoc.GetRequiredLanguageService <IAddImportsService>(); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute( suppressionsRoot, _targetSymbol, _suppressMessageAttribute, _diagnostic, workspace, compilation, addImportsService, cancellationToken ); return(suppressionsDoc.WithSyntaxRoot(suppressionsRoot)); }
protected override async Task <Document> GetChangedSuppressionDocumentAsync(CancellationToken cancellationToken) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken).ConfigureAwait(false); var services = suppressionsDoc.Project.Solution.Workspace.Services; var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var addImportsService = suppressionsDoc.GetRequiredLanguageService <IAddImportsService>(); var options = await SyntaxFormattingOptions.FromDocumentAsync(suppressionsDoc, cancellationToken).ConfigureAwait(false); foreach (var(targetSymbol, diagnostics) in _diagnosticsBySymbol) { foreach (var diagnostic in diagnostics) { Contract.ThrowIfFalse(!diagnostic.IsSuppressed); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute( suppressionsRoot, targetSymbol, _suppressMessageAttribute, diagnostic, services, options, addImportsService, cancellationToken); } } var result = suppressionsDoc.WithSyntaxRoot(suppressionsRoot); var final = await CleanupDocumentAsync(result, cancellationToken).ConfigureAwait(false); return(final); }
protected override async Task <Document> GetChangedSuppressionDocumentAsync(CancellationToken cancellationToken) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken).ConfigureAwait(false); var workspace = suppressionsDoc.Project.Solution.Workspace; var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var compilation = await suppressionsDoc.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); var addImportsService = suppressionsDoc.Project.LanguageServices.GetRequiredService <IAddImportsService>(); foreach (var kvp in _diagnosticsBySymbol) { var targetSymbol = kvp.Key; var diagnostics = kvp.Value; foreach (var diagnostic in diagnostics) { Contract.ThrowIfFalse(!diagnostic.IsSuppressed); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute(suppressionsRoot, targetSymbol, diagnostic, workspace, compilation, addImportsService, cancellationToken); } } return(suppressionsDoc.WithSyntaxRoot(suppressionsRoot)); }
protected override async Task <Document> GetChangedSuppressionDocumentAsync(CancellationToken cancellationToken) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken).ConfigureAwait(false); var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var semanticModel = await suppressionsDoc.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute(suppressionsRoot, _targetSymbol, _diagnostic); return(suppressionsDoc.WithSyntaxRoot(suppressionsRoot)); }
protected override async Task<Document> GetChangedSuppressionDocumentAsync(CancellationToken cancellationToken) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken).ConfigureAwait(false); var services = suppressionsDoc.Project.Solution.Workspace.Services; var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var addImportsService = suppressionsDoc.GetRequiredLanguageService<IAddImportsService>(); var options = await SyntaxFormattingOptions.FromDocumentAsync(suppressionsDoc, cancellationToken).ConfigureAwait(false); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute( suppressionsRoot, _targetSymbol, _suppressMessageAttribute, _diagnostic, services, options, addImportsService, cancellationToken); return suppressionsDoc.WithSyntaxRoot(suppressionsRoot); }
protected override async Task <Document> GetChangedSuppressionDocumentAsync(CancellationToken cancellationToken) { var suppressionsDoc = await GetOrCreateSuppressionsDocumentAsync(cancellationToken).ConfigureAwait(false); var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); foreach (var kvp in _diagnosticsBySymbol) { var targetSymbol = kvp.Key; var diagnostics = kvp.Value; foreach (var diagnostic in diagnostics) { Contract.ThrowIfFalse(!diagnostic.IsSuppressed); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute(suppressionsRoot, targetSymbol, diagnostic); } } return(suppressionsDoc.WithSyntaxRoot(suppressionsRoot)); }