-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for assembly origin for event marking (#102836)
Adds a regression test for the issue that was fixed in #102613. The assembly level attribute marks the members on the referenced type, and the assembly is the MessageOrigin for the marking. I confirmed this fails with before #102613.
- Loading branch information
1 parent
f36a477
commit 21f356a
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/AssemblyAttributeAccessesMembers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Mono.Linker.Tests.Cases.Attributes; | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
|
||
[assembly: KeptAttributeAttribute (typeof (AccessesMembersAttribute))] | ||
[assembly: AccessesMembers (typeof (AssemblyAttributeAccessesMembers.TypeWithMembers))] | ||
namespace Mono.Linker.Tests.Cases.Attributes | ||
{ | ||
/// <summary> | ||
/// A regression test for the issue that was fixed by https://github.com/dotnet/runtime/pull/102613. | ||
/// Events were assumed to always have a MemberDefinition or Descriptor file as the warning origin, but it also can occur from an assembly attribute. | ||
/// </summary> | ||
[Kept] | ||
class AssemblyAttributeAccessesMembers | ||
{ | ||
[Kept] | ||
public static void Main () | ||
{ | ||
typeof (AssemblyAttributeAccessesMembers).Assembly.GetCustomAttributes (false); | ||
} | ||
|
||
[Kept] | ||
public class TypeWithMembers | ||
{ | ||
[Kept] | ||
public TypeWithMembers () { } | ||
|
||
[Kept] | ||
public void Method () { } | ||
|
||
[Kept] | ||
public int Field; | ||
|
||
[Kept] | ||
[KeptBackingField] | ||
public int Property { [Kept] get; [Kept] set; } | ||
|
||
[Kept] | ||
[KeptEventAddMethod] | ||
[KeptEventRemoveMethod] | ||
[KeptBackingField] | ||
public event EventHandler Event; | ||
} | ||
} | ||
|
||
[Kept] | ||
[KeptBaseType (typeof (Attribute))] | ||
public class AccessesMembersAttribute : Attribute | ||
{ | ||
[Kept] | ||
public AccessesMembersAttribute ( | ||
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] | ||
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] | ||
Type type) | ||
{ | ||
} | ||
} | ||
} |