Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeExtensions.ToTypeString method Exception. #639

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! 🙂

@Sergio0694 Sergio0694 merged commit 24388b8 into CommunityToolkit:main Mar 12, 2023
@Sergio0694 Sergio0694 linked an issue Mar 12, 2023 that may be closed by this pull request
1 task
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
2 participants