CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
3.07k stars 299 forks source link

Fix TypeExtensions.ToTypeString method Exception. #639

Closed GabrieleMessina closed 1 year ago

GabrieleMessina commented 1 year ago

Fix TypeExtensions.ToTypeString method throws if invoked on a generic class without specifying the generic type.

Closes #609

Added a check on type.IsGenericParameter inside FormatDisplayString to avoid calling the method recursively given that, in this case, type.DeclaringType returns the parent class that defined the generic type parameter and this parent class was already taken into account by FormatDisplayString.

I've also added 2 tests for testing this case.

PR Checklist

GabrieleMessina commented 1 year ago

@dotnet-policy-service agree