-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
Description
Test case:
using System;
using System.Reflection;
namespace dm_play
{
public enum Levels { one, two, three }
[AttributeUsage(AttributeTargets.Method)]
public class TestAttribute : Attribute
{
Levels this_level;
public TestAttribute(Levels level) => this_level = level;
}
public class MainClass
{
public static void Main(string[] args)
{
var mi = typeof(MainClass).FindMembers(MemberTypes.Method, BindingFlags.Instance | BindingFlags.Public, (m, criteria) => m.Name == nameof(MethodWithAttribute), null);
foreach (CustomAttributeData cad in ((MethodInfo)(mi[0])).CustomAttributes) {
Console.WriteLine($"attr.Type: {cad.AttributeType}");
foreach (CustomAttributeTypedArgument cata in cad.ConstructorArguments)
Console.WriteLine($"-> cata: {cata.ArgumentType}, val: {cata.Value}, type of val: {cata.Value.GetType()}");
}
}
[TestAttribute(Levels.two)]
public void MethodWithAttribute() => Console.WriteLine("Hello");
}
}Expected output: (works with 5.16.0)
$ mono dm_play.exe
attr.Type: dm_play.TestAttribute
-> cata: dm_play.Levels, val: two, type of val: dm_play.Levels
Actual output: (with master)
$ ~/misc/bin/mono dm_play.exe
attr.Type: dm_play.TestAttribute
-> cata: dm_play.Levels, val: 1, type of val: System.Int32
The CustomAttributeTypedArgument.ArgumentType is the same, but the CustomAttributeTypedArgument.Value has different types:
5.16.x: dm_play.Levels
master: System.Int32
The commit that introduced this behavior: faaa9a4
This breaks msbuild tests being run with xunit.