diff options
author | Sven Boemer <sbomer@gmail.com> | 2022-05-03 21:13:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 21:13:32 +0300 |
commit | 2e91f8916748e794570fab82f7cf549ffde66aeb (patch) | |
tree | db6943626ca8f47f75756675e12f6b177027ce45 /test | |
parent | 9eb23e4a61c59b8dd12078e50fce3147b41171da (diff) |
Fix warning about duplicate attributes (#2780)
Duplicate attributes were producing warnings on every callsite in
the linker to GetLinkerAttributes, which makes the number of
warnings depend on the number of callsites in user code.
Deduplicate these by producing the warning only once, when
building the linker attributes cache.
Fixes one of the remaining issues encountered while adding trim
analysis patterns in the linker.
Make `TryGetLinkerAttribute` fail if there are multiple attributes.
Diffstat (limited to 'test')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresViaXml.cs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresViaXml.cs b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresViaXml.cs index dd62871ef..a77e13e96 100644 --- a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresViaXml.cs +++ b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresViaXml.cs @@ -25,15 +25,17 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability // The second attribute is added through link attribute XML [RequiresUnreferencedCode ("Message for --MethodWithDuplicateRequiresAttribute--")] [ExpectedWarning ("IL2027", "RequiresUnreferencedCodeAttribute", nameof (MethodWithDuplicateRequiresAttribute), ProducedBy = ProducedBy.Trimmer)] - [ExpectedWarning ("IL2027", "RequiresUnreferencedCodeAttribute", nameof (MethodWithDuplicateRequiresAttribute), ProducedBy = ProducedBy.Trimmer)] static void MethodWithDuplicateRequiresAttribute () { } [ExpectedWarning ("IL2026", "--MethodWithDuplicateRequiresAttribute--")] + [ExpectedWarning ("IL2026", "--MethodWithDuplicateRequiresAttribute--")] static void TestDuplicateRequiresAttribute () { MethodWithDuplicateRequiresAttribute (); + // A second callsite should not introduce extra warnings about the duplicate attributes. + MethodWithDuplicateRequiresAttribute (); } |