TypeExtensions.ToTypeString does not support generic types definitions
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;
}
Regression
No response
Reproducible in sample app?
- [X] 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.
Screenshots
No response
Windows Build Number
- [ ] Windows 10 1809 (Build 17763)
- [ ] Windows 10 1903 (Build 18362)
- [ ] Windows 10 1909 (Build 18363)
- [ ] Windows 10 2004 (Build 19041)
- [ ] Windows 10 20H2 (Build 19042)
- [ ] Windows 10 21H1 (Build 19043)
- [ ] Windows 11 21H2 (Build 22000)
- [ ] Other (specify)
Other Windows Build number
Windows 10 21H2 (Build 19044.1889)
App minimum and target SDK version
- [ ] Windows 10, version 1809 (Build 17763)
- [ ] Windows 10, version 1903 (Build 18362)
- [ ] Windows 10, version 1909 (Build 18363)
- [ ] Windows 10, version 2004 (Build 19041)
- [ ] Other (specify)
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
No response
Device form factor
No response
Nuget packages
CommunityToolkit.Diagnostics 8.0.0
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item.
Hello OleksiiD, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
@OleksiiD I've transferred your issue to the proper repository here for the .NET Community Toolkit. To help us better understand, what led you to originally file it in the Windows Community Toolkit repository? Thanks!