You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cannot set CustomAttribute to nested erasable type
CustomAttribute with Generative types work fine
Repro steps
Add nested type with custom attributes
let createType typeName (count:int) =
let myType = ProvidedTypeDefinition(asm, ns, typeName, Some typeof<obj>, isErased = true)
let ctor = ProvidedConstructor([], invokeCode = fun args -> <@@ ():> obj @@>)
myType.AddMember(ctor)
let nestedType = ProvidedTypeDefinition("Nested", Some typeof<obj>)
let attr = {
new Reflection.CustomAttributeData() with
member __.Constructor = (typeof<MyNamespace.MyAttribute>).GetConstructor([|typeof<string>|])
member __.ConstructorArguments = [|"1"|] |> Array.map (fun i -> CustomAttributeTypedArgument(i.GetType(), i)) :> _
member __.NamedArguments = [||] :> _
}
nestedType.AddCustomAttribute(attr)
myType.AddMember nestedType
displaying a list of attributes in debug script
type B = LemonadeProvider.ErasingProvider<1>
let t2 = typeof<B.Nested>
t2.CustomAttributes |> Seq.iter(fun a -> printfn "%A" a )
Description
Cannot set CustomAttribute to nested erasable type
CustomAttribute with Generative types work fine
Repro steps
Add nested type with custom attributes
displaying a list of attributes in debug script
Expected behavior
[MyNamespace.MyAttribute("1")]
Actual behavior
[System.SerializableAttribute()]
[System.Runtime.CompilerServices.TypeForwardedFromAttribute("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
[System.Runtime.InteropServices.ComVisibleAttribute((Boolean)True)]
[System.Runtime.InteropServices.ClassInterfaceAttribute((System.Runtime.InteropServices.ClassInterfaceType)1)]
[System.Runtime.CompilerServices.NullableContextAttribute((Byte)2)]
Related information
The text was updated successfully, but these errors were encountered: