Skip to content

Commit

Permalink
Merge pull request #45613 from mavasani/FixAD0001ForIDE0076
Browse files Browse the repository at this point in the history
Fix AD0001 for IDE0076
  • Loading branch information
msftbot[bot] authored Jul 2, 2020
2 parents 295eaa6 + a08c596 commit f9bd4ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#nullable enable

using System.Threading.Tasks;
using Microsoft.CodeAnalysis.RemoveUnnecessarySuppressions;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
Expand Down Expand Up @@ -182,5 +183,23 @@ public void M() {{ }}
}}";
await VerifyCS.VerifyCodeFixAsync(input, input);
}

[Fact, WorkItem(45465, "https://github.com/dotnet/roslyn/issues/45465")]
public async Task LegacyModeGlobalSuppressionWithNamespaceAndDescendantsScope()
{
var target = "N:N.InvalidChild";
var input = $@"
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""Category"", ""Id: Title"", Scope = ""namespaceanddescendants"", Target = {{|#0:""{target}""|}})]
namespace N
{{
class C {{ }}
}}";
var expectedDiagnostic = VerifyCS.Diagnostic(AbstractRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.LegacyFormatTargetDescriptor)
.WithLocation(0)
.WithArguments(target);

await VerifyCS.VerifyCodeFixAsync(input, expectedDiagnostic, input);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public bool HasValidTarget(
// Compilation wide suppression with a non-null target is considered invalid.
return targetSymbolString == null;
}
else if (targetScope == TargetScope.NamespaceAndDescendants)
{
// TargetSymbolResolver expects the callers to normalize 'NamespaceAndDescendants' and 'Namespace' scopes to 'Namespace' scope.
targetScope = TargetScope.Namespace;
}

var resolver = new TargetSymbolResolver(_compilation, targetScope, targetSymbolString);
resolvedSymbols = resolver.Resolve(out targetHasDocCommentIdFormat);
Expand Down

0 comments on commit f9bd4ff

Please sign in to comment.