Skip to content

feat(analyzers): validate grain contract serialization - #11576

Open
KSemenenko wants to merge 2 commits into
dotnet:mainfrom
KSemenenko:feat/grain-contract-serialization-analyzer
Open

KSemenenko wants to merge 2 commits into
dotnet:mainfrom
KSemenenko:feat/grain-contract-serialization-analyzer

Conversation

@KSemenenko

@KSemenenko KSemenenko commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

An unannotated DTO can enter a grain request, response, or state graph without a build diagnostic, leaving a missing codec to be discovered only when that path runs. Existing member-annotation checks do not catch this omission.

Add two independent opt-in warnings: ORLEANS0028 checks RPC contracts inherited from IGrain/IGrainObserver, and ORLEANS0029 checks state used by Orleans-serialized storage or live activation migration. Grain implementation classes are inspected through their contracts and state; they are not annotated as serialized data.

Follow actual constructed data schemas, including inherited and referenced contracts, asynchronous responses, arrays, built-in collections, model bases, explicit/implicit member IDs, and constructor-selected members on records and ordinary classes. Unused generic model arguments do not require serializers. Built-in codecs, registered custom codecs, and surrogate converters provide alternatives to GenerateSerializer. Traversal limits explicitly warn when a graph cannot be fully checked, including recursively expanding converter chains, so analysis stays bounded without silently skipping constructions.

State checks remain separate because JSON storage does not inherently require an Orleans codec, while live migration serializes persistent state through Orleans independently of the storage format. Documentation explains activation, remediation, migration, and limits involving runtime registrations, polymorphic values, and large or expanding graphs.

Regressions cover warning severity and independent activation, inherited/generic contracts, repeated closed constructions, constructor-selected external models, unused generic arguments, bounded converter/model graphs, and real serializer round trips for unused arguments and persistent-state migration payloads.

Closes #11575.

Microsoft Reviewers: Open in CodeFlow

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 84.00% (120,840 / 143,851) 83.97% (120,451 / 143,437) +0.0287 pp
Branches 73.87% (36,395 / 49,270) 73.77% (36,036 / 48,846) +0.0938 pp

Report-only conclusion: improved.

The current-main baseline is commit efffe4681c and uses the same reviewed coverage matrix.

Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.

The comparison remains report-only while normal line and branch variance is calibrated.

Coverage details

@KSemenenko
KSemenenko force-pushed the feat/grain-contract-serialization-analyzer branch from 2972e26 to 9adf47e Compare October 23, 2026 07:47

This branch has not been deployed

No deployments
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.

feat(analyzers): detect missing serialization support in grain contracts

2 participants