Skip to content

Fix TypeExtensions.ToTypeString method Exception.#639

Merged
Sergio0694 merged 1 commit intoCommunityToolkit:mainfrom
GabrieleMessina:fix-TypeExtensions-ToTypeString
Mar 12, 2023
Merged

Fix TypeExtensions.ToTypeString method Exception.#639
Sergio0694 merged 1 commit intoCommunityToolkit:mainfrom
GabrieleMessina:fix-TypeExtensions-ToTypeString

Conversation

@GabrieleMessina
Copy link
Contributor

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

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

@GabrieleMessina
Copy link
Contributor Author

@dotnet-policy-service agree

Fix TypeExtensions ToTypeString method throws if invoked on a generic class without specify the generic type
@Sergio0694 Sergio0694 force-pushed the fix-TypeExtensions-ToTypeString branch from 354e56f to 551921d Compare March 12, 2023 19:31
Copy link
Member

@Sergio0694 Sergio0694 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a couple tweaks, but otherwise LGTM! :shipit:

Thank you! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

TypeExtensions.ToTypeString throws exception for open generic types TypeExtensions.ToTypeString does not support generic types definitions

2 participants