Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetUnionCases fails on an option of provided type #336

Open
kerams opened this issue Mar 14, 2020 · 1 comment
Open

GetUnionCases fails on an option of provided type #336

kerams opened this issue Mar 14, 2020 · 1 comment
Labels

Comments

@kerams
Copy link
Contributor

kerams commented Mar 14, 2020

Description

The following snippet causes an error message box to appear in the VS instance that consumes the type provider.

let typ = ProvidedTypeDefinition ("Blah", Some typeof<obj>)
let optionTyp = ProvidedTypeBuilder.MakeGenericType (typedefof<_ option>, [ typ ])
let cases = FSharp.Reflection.FSharpType.GetUnionCases optionTyp

Expected behavior

Expecting the function call so succeed and return 2 cases.

Actual behavior

A design time error message with The operation 'GetNestedType' on item 'FSharpOption``1' should not be called on provided type, member or parameter of type 'ProviderImplementation.ProvidedTypes.TypeSymbol' and a stack trace.

Is there any workaround for this?

@dsyme dsyme added the bug label Sep 21, 2021
@7sharp9
Copy link
Member

7sharp9 commented Jun 3, 2022

I believe this is because GetUnionCases is expecting the providedtype typ to have a member called Tags present which is retrieved via reflection.

It's possible to get around it via some fakery if you really need to: https://github.com/jet/falanx/blob/fe3bfbce4a9ec40aecfd7db6704aaab91283c3a5/src/Falanx.Machinery/ProvidedTypesExtensions.fs#L16-L70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants