Fix exception thrown during deserialization for generic base type - #184
Open
manuc66 wants to merge 6 commits into
Open
Fix exception thrown during deserialization for generic base type#184manuc66 wants to merge 6 commits into
manuc66 wants to merge 6 commits into
Conversation
- Guard MakeGenericType against arity mismatch (clean JsonSerializationException instead of ArgumentException) - Restrict generic CanConvert matching to the base class hierarchy only; interface matching is used only against registered subtypes, so unrelated types that merely implement the generic base interface are no longer claimed - Add edge-case tests proving the previous issues (arity, unrelated interface implementors)
Type.GetGenericArguments is not available on netstandard1.3; use a GetGenericTypeParameterCount helper (TypeInfo.GenericTypeParameters there, GetGenericArguments elsewhere).
Rename InheritsOrImplementsGeneric to IsClosedGenericFormOf with an includeInterfaces opt-in parameter and a doc comment explaining why interface matching is only enabled against registered subtypes. Add tests for: multi-level generic hierarchies, explicit closed-form registration precedence over the open generic, and a generic fallback subtype being closed during deserialization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.