Skip to content

Give ReferencedInstanceValidator one MessagePack constructor - #701

Open
andrzejskowronski wants to merge 1 commit into
developfrom
feature/messagepack-ctor-contract-test
Open

andrzejskowronski wants to merge 1 commit into
developfrom
feature/messagepack-ctor-contract-test

Conversation

@andrzejskowronski

Copy link
Copy Markdown
Contributor

Description

Firely CAR deserializes compiled schemas with MessagePack's DynamicObjectResolverAllowPrivate, which picks a single constructor per [DataContract] type. ReferencedInstanceValidator's schema and targetCases constructors both matched at four parameters, so TargetCases-form validators failed to deserialize.

Adds a private constructor taking all five [DataMember]s, marked [SerializationConstructor], and route the rewrite constructor through it. Add a reflection test that mirrors MessagePack's constructor pick for every assertion type and fails when it is ambiguous or leaves a [DataMember] unsettable.

Firely CAR deserializes compiled schemas with MessagePack's
DynamicObjectResolverAllowPrivate, which picks a single constructor per
[DataContract] type. ReferencedInstanceValidator's schema and
targetCases constructors both matched at four parameters, so
TargetCases-form validators failed to deserialize.

Add a private constructor taking all five [DataMember]s, marked
[SerializationConstructor], and route the rewrite constructor through
it. Add a reflection test that mirrors MessagePack's constructor pick
for every assertion type and fails when it is ambiguous or leaves a
[DataMember] unsettable.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 10:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new regression test does not validate attributed constructor parameters as MessagePack does.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds deterministic MessagePack deserialization for ReferencedInstanceValidator.

Changes:

  • Adds a five-member serialization constructor.
  • Adds reflection-based contract validation tests.
File Description
ReferencedInstanceValidator.cs Defines the MessagePack constructor and reuses it for rewriting.
MessagePackContractTests.cs Checks constructor selection across assertion contracts.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

yield break;
}

var ctorParams = chosen[0].GetParameters().Select(p => p.Name!).ToHashSet(StringComparer.OrdinalIgnoreCase);
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