提交 c8c3f053 编写于 作者: C CyrusNajmabadi

Suppress diagnostics entirely for the preview for add-nuget.

上级 103b9e70
......@@ -149,9 +149,7 @@ private void ProduceTags(TaggerContext<TTag> context, DocumentSnapshotSpan spanT
}
private bool IsSuppressed(NormalizedSnapshotSpanCollection suppressedSpans, SnapshotSpan span)
{
return suppressedSpans != null && suppressedSpans.IntersectsWith(span);
}
=> suppressedSpans != null && suppressedSpans.IntersectsWith(span);
internal void OnDiagnosticsUpdated(DiagnosticsUpdatedArgs e, SourceText sourceText, ITextSnapshot editorSnapshot)
{
......
......@@ -520,12 +520,8 @@ private string GetUsingDirectiveString(INamespaceOrTypeSymbol namespaceOrTypeSym
{
var root = GetCompilationUnitSyntaxNode(contextNode, cancellationToken);
// Suppress diagnostics on the import we create. Because we only get here when we are
// adding a nuget package, it is certainly the case that in the preview this will not
// bind properly. It will look silly to show such an error, so we just suppress things.
var usingDirective = SyntaxFactory.UsingDirective(
CreateNameSyntax(namespaceParts, namespaceParts.Count - 1)).WithAdditionalAnnotations(
SuppressDiagnosticsAnnotation.Create());
CreateNameSyntax(namespaceParts, namespaceParts.Count - 1));
var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var service = document.GetLanguageService<IAddImportsService>();
......
......@@ -76,7 +76,16 @@ private async Task<Solution> GetUpdatedSolutionAsync(CancellationToken cancellat
var oldText = await _oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
var newText = oldText.WithChanges(_textChanges);
return _oldDocument.WithText(newText).Project.Solution;
var newDocument = _oldDocument.WithText(newText);
var newRoot = await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
// Suppress diagnostics on the import we create. Because we only get here when we are
// adding a nuget package, it is certainly the case that in the preview this will not
// bind properly. It will look silly to show such an error, so we just suppress things.
var updatedRoot = newRoot.WithAdditionalAnnotations(SuppressDiagnosticsAnnotation.Create());
var updatedDocument = newDocument.WithSyntaxRoot(updatedRoot);
return updatedDocument.Project.Solution;
}
/// <summary>
......
......@@ -381,11 +381,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.AddImport
Dim nameSyntax = CreateNameSyntax(nameSpaceParts, nameSpaceParts.Count - 1)
Dim importsStatement = GetImportsStatement(nameSyntax)
' Suppress diagnostics on the import we create. Because we only get here when we are
' adding a NuGet package, it is certainly the case that in the preview this will not
' bind properly. It will look silly to show such an error, so we just suppress things.
importsStatement = importsStatement.WithAdditionalAnnotations(SuppressDiagnosticsAnnotation.Create())
Return AddImportAsync(
contextNode, Document, placeSystemNamespaceFirst,
importsStatement, cancellationToken)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册