Skip to content

Update MessagePack NuGet files and improve type handling - #597

Merged
Daniel-Svensson merged 8 commits into
OpenRIAServices:mainfrom
Daniel-Svensson:nuget_update
Jul 30, 2026
Merged

Update MessagePack NuGet files and improve type handling#597
Daniel-Svensson merged 8 commits into
OpenRIAServices:mainfrom
Daniel-Svensson:nuget_update

Conversation

@Daniel-Svensson

@Daniel-Svensson Daniel-Svensson commented Jul 30, 2026

Copy link
Copy Markdown
Member

Dependency updates:

  • Upgraded Nerdbank.MessagePack to version 1.2.36 and added PolyType version 1.4.1 and update code to work with the latest versions.

Serialization and constructor generation improvements:

  • Fixed code generation for types that has only required properties by chaning PolyType deserialization constructor generation to accept only required properties. (Removed workaround required due to old PolyType behavior)

MessagePack/PolyType integration fixes:

  • Modified the MessagePack serialization provider to disable additional discriminators for surrogate types by updating DerivedTypeUnions when surrogates are used, preventing serialization issues with derived types.
    (Seems to be a change in behavior of messagepack?)

NuGet packaging cleanup:

  • Cleaned up the nuspec file by removing commented-out file entries for netstandard2.0 and OpenRiaServices.Client.Web, focusing the package on supported targets and binaries.

Summary by CodeRabbit

  • Bug Fixes

    • Improved MessagePack/PolyType deserialization for entities with required data members by generating constructor shapes that initialize all required properties.
    • Updated serialization behavior to align derived-type union handling during surrogate-based deserialization.
    • Fixed test-generated deserialization constructor expectations to match the new required-property initialization.
  • Chores

    • Bumped MessagePack dependency versions and added PolyType support across the supported projects.
    • Refreshed generated baseline and scenario artifacts to reflect updated serialization behavior.

@Daniel-Svensson
Daniel-Svensson requested a review from Copilot July 30, 2026 10:04
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Daniel-Svensson, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 60a3baee-58d3-4992-9a32-bd05f8d6a117

📥 Commits

Reviewing files that changed from the base of the PR and between af63694 and 23db6d9.

📒 Files selected for processing (7)
  • src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/CSharpComplexObjectGenerator.cs
  • src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/CSharpEntityGenerator.cs
  • src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/Templates/DataContractGeneratorTemplate.ttinclude
  • src/OpenRiaServices.Tools/Test/OpenRiaServices.Tools.Test.csproj
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Mocks/MockCustomers.g.vb
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/TestProvider_Scenarios_CodeGen.g.vb
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/TestProvider_Scenarios_CodeGen.g.vb
📝 Walkthrough

Walkthrough

MessagePack dependencies are updated, surrogate serialization disables derived-type discriminators, PolyType constructors now cover all required properties, and generated test baselines are refreshed.

Changes

MessagePack and PolyType integration

Layer / File(s) Summary
Serializer dependencies and surrogate unions
NuGet/OpenRiaServices.Client.Core.nuspec, src/OpenRiaServices.Client.*/Framework/*.csproj, src/OpenRiaServices.Hosting.AspNetCore/...
Nerdbank.MessagePack is updated to 1.2.36, PolyType 1.4.1 is added, obsolete commented entries are removed, and surrogate derived-type unions are disabled.
Required-property constructor generation
src/OpenRiaServices.Tools.TextTemplate/..., src/OpenRiaServices.Tools/...
Generated PolyType constructors now accept and assign all required eligible properties.
Generated baseline regeneration
src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/...
Mock and scenario outputs are regenerated with updated deserialization constructors, association synchronization, validation, notification, and domain-context wiring.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DomainService
  participant MessagePackSerializationProvider
  participant MessagePackSerializer
  DomainService->>MessagePackSerializationProvider: Create serializer
  MessagePackSerializationProvider->>MessagePackSerializationProvider: Disable surrogate discriminators
  MessagePackSerializationProvider->>MessagePackSerializer: Configure converters and derived-type unions
Loading

Possibly related PRs

Suggested labels: Area-Server-Hosting

Poem

I’m a rabbit with packets to pack,
Required fields hop into a stack.
PolyType draws near,
Discriminators disappear,
Generated code springs back!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main changes: MessagePack dependency updates and related type-handling adjustments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Pull request overview

This PR updates the OpenRiaServices MessagePack/PolyType integration to newer package versions and adjusts client-proxy code generation for PolyType-compatible deserialization constructors, with corresponding baseline and packaging updates.

Changes:

  • Upgrade Nerdbank.MessagePack to 1.2.36 and add PolyType 1.4.1 where needed.
  • Update PolyType deserialization-constructor generation to use required DataMember properties (instead of a workaround using a non-required property).
  • Adjust MessagePack serializer configuration to disable derived-type discriminators when surrogates are used; refresh codegen baselines and clean up the .nuspec.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/OpenRiaServices.Hosting.AspNetCore/Framework/OpenRiaServices.Hosting.AspNetCore.csproj Bumps Nerdbank.MessagePack and adds PolyType dependency.
src/OpenRiaServices.Hosting.AspNetCore/Framework/AspNetCore/Serialization/MessagePackSerializationProvider.cs Disables derived-type unions for types using surrogates to avoid discriminator issues.
src/OpenRiaServices.Client/Framework/OpenRiaServices.Client.csproj Bumps Nerdbank.MessagePack dependency.
src/OpenRiaServices.Client.DomainClients.Http/Framework/OpenRiaServices.Client.DomainClients.Http.csproj Bumps Nerdbank.MessagePack and adds PolyType dependency.
src/OpenRiaServices.Tools/Framework/DataContractProxyGenerator.cs Generates PolyType deserialization ctor parameters for all required DataMember properties.
src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/Templates/DataContractGeneratorTemplate.ttinclude Updates T4 template to emit required-property PolyType constructors.
src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/CSharpEntityGenerator.cs Updates generated entity code emitter for required-property PolyType constructors.
src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/CSharpComplexObjectGenerator.cs Updates generated complex-object code emitter for required-property PolyType constructors.
src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/TestProvider_Scenarios_CodeGen.g.cs Updates expected C# baseline for new ctor shape/required-property selection.
src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/TestProvider_Scenarios_CodeGen.g.vb Updates expected VB baseline for new ctor shape/required-property selection.
src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/TestProvider_Scenarios_CodeGen.g.cs Updates expected C# baseline (full type names) for new ctor shape.
src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/TestProvider_Scenarios_CodeGen.g.vb Updates expected VB baseline (full type names) for new ctor shape.
src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Mocks/MockCustomers.g.cs Updates expected C# baseline for required-property ctor changes in mocks.
src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Mocks/MockCustomers.g.vb Updates expected VB baseline for required-property ctor changes in mocks.
NuGet/OpenRiaServices.Client.Core.nuspec Updates package dependency versions and removes commented-out file entries.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/Templates/DataContractGeneratorTemplate.ttinclude`:
- Around line 69-100: Update the generated assignment inside the
requiredProperties loop to reference the property through
CodeGenUtilities.GetSafeName(pd.Name), matching the escaped name used for
parameter declarations and generated property declarations. Preserve the
existing assignment flow and only replace the raw pd.Name target.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c5aa6e5c-7373-412c-ada1-acd600149ed6

📥 Commits

Reviewing files that changed from the base of the PR and between e623cb1 and 7751333.

📒 Files selected for processing (15)
  • NuGet/OpenRiaServices.Client.Core.nuspec
  • src/OpenRiaServices.Client.DomainClients.Http/Framework/OpenRiaServices.Client.DomainClients.Http.csproj
  • src/OpenRiaServices.Client/Framework/OpenRiaServices.Client.csproj
  • src/OpenRiaServices.Hosting.AspNetCore/Framework/AspNetCore/Serialization/MessagePackSerializationProvider.cs
  • src/OpenRiaServices.Hosting.AspNetCore/Framework/OpenRiaServices.Hosting.AspNetCore.csproj
  • src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/CSharpComplexObjectGenerator.cs
  • src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/CSharpEntityGenerator.cs
  • src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/Templates/DataContractGeneratorTemplate.ttinclude
  • src/OpenRiaServices.Tools/Framework/DataContractProxyGenerator.cs
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Mocks/MockCustomers.g.cs
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Mocks/MockCustomers.g.vb
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/TestProvider_Scenarios_CodeGen.g.cs
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/TestProvider_Scenarios_CodeGen.g.vb
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/TestProvider_Scenarios_CodeGen.g.cs
  • src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/TestProvider_Scenarios_CodeGen.g.vb

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/Templates/DataContractGeneratorTemplate.ttinclude (1)

80-80: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use the translated property type for constructor parameters.

Lines 180 and 190 back fields and property declarations with CodeGenUtilities.TranslateType(...), so a required System.Data.Linq.Binary property is generated as byte[] in the class while the constructor parameter is emitted as System.Data.Linq.Binary, producing a non-compiling assignment.

Proposed fix
-				string parameterDeclarations = string.Join(", ", requiredProperties.Select(pd => $"{CodeGenUtilities.GetTypeName(pd.PropertyType)} {CodeGenUtilities.GetSafeName(pd.Name)}"));
+				string parameterDeclarations = string.Join(", ", requiredProperties.Select(pd => $"{CodeGenUtilities.GetTypeName(CodeGenUtilities.TranslateType(pd.PropertyType))} {CodeGenUtilities.GetSafeName(pd.Name)}"));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/Templates/DataContractGeneratorTemplate.ttinclude`
at line 80, Update the constructor parameter generation in the
requiredProperties flow to use CodeGenUtilities.TranslateType(pd.PropertyType)
before CodeGenUtilities.GetTypeName, matching the translated types used by the
generated fields and properties. Keep the existing safe-name handling and
parameter formatting unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/Templates/DataContractGeneratorTemplate.ttinclude`:
- Line 80: Update the constructor parameter generation in the requiredProperties
flow to use CodeGenUtilities.TranslateType(pd.PropertyType) before
CodeGenUtilities.GetTypeName, matching the translated types used by the
generated fields and properties. Keep the existing safe-name handling and
parameter formatting unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4a66aa37-51aa-4d75-857e-65d7f99601d9

📥 Commits

Reviewing files that changed from the base of the PR and between 7751333 and af63694.

📒 Files selected for processing (1)
  • src/OpenRiaServices.Tools.TextTemplate/Framework/CSharpGenerators/Templates/DataContractGeneratorTemplate.ttinclude

@sonarqubecloud

Copy link
Copy Markdown

@Daniel-Svensson
Daniel-Svensson merged commit 52ee939 into OpenRIAServices:main Jul 30, 2026
7 checks passed
@Daniel-Svensson
Daniel-Svensson deleted the nuget_update branch July 30, 2026 14:14
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.

3 participants