Skip to content

TypeExtensions.ToTypeString does not support generic types definitions #390

@OleksiiD

Description

@OleksiiD

Describe the bug

TypeExtensions.ToTypeString throws the ArgumentOutOfRangeException exception for generic type definitions.

TypeExtensions.ToTypeString(typeof(IDictionary<,>))

The easiest solution would be to add the following code in the FormatDisplayString method:

if (type.IsGenericTypeParameter)
{
    return type.Name;
}

Reproducible in sample app?

  • This bug can be reproduced in the sample app.

Steps to reproduce

  • Create .net6 app
  • Add CommunityToolkit.Diagnostics 8.0.0 NuGet package
  • Add the following line of code
TypeExtensions.ToTypeString(typeof(IDictionary<,>))
  • Run project

Expected behavior

No exception.

Nuget packages

CommunityToolkit.Diagnostics 8.0.0

Help us help you

Yes, I'd like to be assigned to work on this item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An unexpected issue that highlights incorrect behaviordiagnostics 🔬Issues/PRs for the Diagnostics package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions