Skip to content

Reflection differences between Single Case DU and Multiple Case DU #12463

@no1melman

Description

@no1melman

So essentially, if you create a single case DU then the type name is the actual type name. But if you create multiple case DU then the type name is one of the case names....

Repro steps

type Events = CreatedEvent of string | DeletedEvent of string
type SuperEvents = AllEvents of Events

let cr = CreatedEvent "id"
let sucr = AllEvents cr

sucr.GetType().Name // val it: string = "SuperEvents"
cr.GetType().Name // val it: string = "CreatedEvent"

Expected behavior

I would expect sucr.GetType().Name === "AllEvents"

Actual behavior

sucr.GetType().Name === "SuperEvents"

Related information

Provide any related information (optional):

  • Operating system : Windows 10
  • .NET Runtime kind (.NET Core, .NET Framework, Mono) : .NET 6.0.100 :: F# 6.0.1
  • Editing Tools (e.g. Visual Studio Version, Visual Studio) : dotnet fsi

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions