-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Version Used: features/generic-attributes
Steps to Reproduce:
roslyn/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs
Lines 10094 to 10140 in 513ed88
| [Fact, WorkItem(55190, "https://github.com/dotnet/roslyn/issues/55190")] | |
| public void GenericAttributeParameter_01() | |
| { | |
| var source = @" | |
| using System; | |
| class Attr<T> : Attribute { public Attr(T param) { } } | |
| [Attr<string>(""a"")] | |
| class Program { } | |
| "; | |
| var verifier = CompileAndVerify(source, sourceSymbolValidator: verify, symbolValidator: verifyMetadata); | |
| verifier.VerifyTypeIL("Program", @" | |
| .class private auto ansi beforefieldinit Program | |
| extends [netstandard]System.Object | |
| { | |
| .custom instance void class Attr`1<string>::.ctor(!0) = ( | |
| 01 00 01 61 00 00 | |
| ) | |
| // Methods | |
| .method public hidebysig specialname rtspecialname | |
| instance void .ctor () cil managed | |
| { | |
| // Method begins at RVA 0x2058 | |
| // Code size 7 (0x7) | |
| .maxstack 8 | |
| IL_0000: ldarg.0 | |
| IL_0001: call instance void [netstandard]System.Object::.ctor() | |
| IL_0006: ret | |
| } // end of method Program::.ctor | |
| } // end of class Program | |
| "); | |
| void verify(ModuleSymbol module) | |
| { | |
| var program = module.GlobalNamespace.GetMember<TypeSymbol>("Program"); | |
| var attrs = program.GetAttributes(); | |
| Assert.Equal(new[] { "Attr<System.String>(\"a\")" }, GetAttributeStrings(attrs)); | |
| } | |
| void verifyMetadata(ModuleSymbol module) | |
| { | |
| var program = module.GlobalNamespace.GetMember<TypeSymbol>("Program"); | |
| var attrs = program.GetAttributes(); | |
| Assert.Equal(new[] { "Attr<System.String>" }, GetAttributeStrings(attrs)); | |
| } | |
| } |
Expected Behavior: If we reference Program from metadata and get a symbol for it, we should be able to GetAttributes() and find an attribute with an argument "a" on it.
Actual Behavior: We get an attribute with no arguments.
Related to #36285
Reactions are currently unavailable