Search code examples
f#type-providers

How do I create type for array of ProvidedType?


How do I create type for array of ProvidedType? In other words, what is an alternative to MakeArrayType on generic Type class?

EDIT: The issue is that when I'm trying MakeArrayType, TP fails.

Here is an example to reproduce the error: https://gist.github.com/dsevastianov/46d1a8495c4af46a9875

Client fails with "The operation 'UnderlyingSystemType' on item 'Birch[]' should not be called on provided type, member or parameter"


Solution

  • This is a bug in ProvidedTypes.fs. Just ensure that GetUnderlyingSystemType is implemented for the ProvidedSymbolType class. This seems to work fine:

    override this.UnderlyingSystemType = 
        match kind with 
        | SymbolKind.SDArray
        | SymbolKind.Array _
        | SymbolKind.Pointer
        | SymbolKind.FSharpTypeAbbreviation _
        | SymbolKind.ByRef -> upcast this
        | SymbolKind.Generic gty -> gty.UnderlyingSystemType