Accessing GetCustomAttributes on a providedType/Method fails with an invalid cast exception
Repro steps
Using one of the tests as reference doing this causes the exception to occur:
let t = (tp :> ITypeProvider).ApplyStaticArguments(providedType, [| typeName |], staticArgs)
//check that attributes read using the typed overload to GetCustomAttributes<t> can be read from the provided method
let firstMethod = t.GetMembers() |> Array.find (fun m -> m :? ProvidedMethod )
let attrib = firstMethod.GetCustomAttributes<CompiledNameAttribute>()
Expected behavior
No exception
Actual behavior
Exception:
System.InvalidCastException
Specified cast is not valid.
at (wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
at System.Reflection.CustomAttributeExtensions.GetCustomAttributes[T] (System.Reflection.MemberInfo element) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/reflection/CustomAttributeExtensions.cs:117
at FSharp.TypeProviders.SDK.Tests.BasicGenerativeTests.GenerativePropertyProviderWithStaticParams generates for correctly () [0x0011f] in <5b48d8756931f8a3a745038375d8485b>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
Description
Accessing GetCustomAttributes on a providedType/Method fails with an invalid cast exception
Repro steps
Using one of the tests as reference doing this causes the exception to occur:
Expected behavior
No exception
Actual behavior
Exception:
Known workarounds
None
Related information
There is a PR for a test here: https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/239