Skip to content

Fix exception thrown during deserialization for generic base type - #184

Open
manuc66 wants to merge 6 commits into
masterfrom
feature/deserialization-generic-base-type
Open

Fix exception thrown during deserialization for generic base type#184
manuc66 wants to merge 6 commits into
masterfrom
feature/deserialization-generic-base-type

Conversation

@manuc66

@manuc66 manuc66 commented Nov 15, 2025

Copy link
Copy Markdown
Owner

No description provided.

manuc66 and others added 6 commits November 15, 2025 23:31
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants