-
Notifications
You must be signed in to change notification settings - Fork 374
Closed
Labels
bug 🐛An unexpected issue that highlights incorrect behaviorAn unexpected issue that highlights incorrect behaviorduplicate 👥Indicates that an identical issue or PR already existsIndicates that an identical issue or PR already existsmvvm-toolkit 🧰Issues/PRs for the MVVM ToolkitIssues/PRs for the MVVM Toolkit
Description
Describe the bug
TypeExtensions.ToTypeString throws an ArgumentOutOfRangeException for open generic types.
Regression
No response
Steps to reproduce
- Run the following code:
using CommunityToolkit.Diagnostics;
System.Console.WriteLine(typeof(Foo<>).ToTypeString());
public sealed record Foo<T>;- Observe the exception is thrown
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at CommunityToolkit.Diagnostics.TypeExtensions.<ToTypeString>g__FormatDisplayString|2_0(Type type, Int32 genericTypeOffset, ReadOnlySpan`1 typeArguments) in /_/src/CommunityToolkit.Diagnostics/Extensions/TypeExtensions.cs:line 110
at CommunityToolkit.Diagnostics.TypeExtensions.<ToTypeString>g__FormatDisplayString|2_0(Type type, Int32 genericTypeOffset, ReadOnlySpan`1 typeArguments) in /_/src/CommunityToolkit.Diagnostics/Extensions/TypeExtensions.cs:line 131
at CommunityToolkit.Diagnostics.TypeExtensions.<>c.<ToTypeString>b__2_3(Type t) in /_/src/CommunityToolkit.Diagnostics/Extensions/TypeExtensions.cs:line 114
at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
at System.String.Join(String separator, IEnumerable`1 values)
at CommunityToolkit.Diagnostics.TypeExtensions.<ToTypeString>g__FormatDisplayString|2_0(Type type, Int32 genericTypeOffset, ReadOnlySpan`1 typeArguments) in /_/src/CommunityToolkit.Diagnostics/Extensions/TypeExtensions.cs:line 114
at CommunityToolkit.Diagnostics.TypeExtensions.<>c.<ToTypeString>b__2_1(Type t) in /_/src/CommunityToolkit.Diagnostics/Extensions/TypeExtensions.cs:line 164
at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValueLocked(TKey key, CreateValueCallback createValueCallback)
at System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValue(TKey key, CreateValueCallback createValueCallback)
at CommunityToolkit.Diagnostics.TypeExtensions.ToTypeString(Type type) in /_/src/CommunityToolkit.Diagnostics/Extensions/TypeExtensions.cs:line 138
at Program.<Main>$(String[] args)
Command terminated by signal 6
Expected behavior
typeof(Foo<>).ToTypeString() should produce the text Foo<>
Screenshots
No response
IDE and version
Rider
IDE version
#RD-223.8617.53
Nuget packages
- CommunityToolkit.Common
- CommunityToolkit.Diagnostics
- CommunityToolkit.HighPerformance
- CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)
8.1.0
Additional context
No response
Help us help you
No, just wanted to report this
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug 🐛An unexpected issue that highlights incorrect behaviorAn unexpected issue that highlights incorrect behaviorduplicate 👥Indicates that an identical issue or PR already existsIndicates that an identical issue or PR already existsmvvm-toolkit 🧰Issues/PRs for the MVVM ToolkitIssues/PRs for the MVVM Toolkit