Skip to content

feat: support semantic versioning for grain interfaces#9996

Open
bknote71 wants to merge 1 commit intodotnet:mainfrom
bknote71:feature/grain-semver-support
Open

feat: support semantic versioning for grain interfaces#9996
bknote71 wants to merge 1 commit intodotnet:mainfrom
bknote71:feature/grain-semver-support

Conversation

@bknote71
Copy link
Copy Markdown
Contributor

@bknote71 bknote71 commented Apr 9, 2026

Summary

Add semantic versioning (SemVer) support for grain interfaces alongside the existing ushort versioning.

Motivation

The current ushort-only versioning limits grain interfaces to a simple numeric counter. This change allows developers to use SemVer strings (e.g. "1.2.0", "2.0.0-beta.1") while maintaining full backward compatibility with existing numeric versions.

Changes

  • SemanticVersion struct (SemVer 2.0.0 compliant)
  • GrainInterfaceVersion unified wrapper supporting both ushort and SemanticVersion
  • VersionAttribute now accepts string for SemVer
  • GrainVersionManifest updated to use GrainInterfaceVersion
  • Message serialization updated with kind marker for protocol-level support

Backward Compatibility

  • Existing [Version(2)] usage works unchanged
  • GrainInterfaceVersion.Parse() auto-detects numeric vs SemVer
  • Cross-kind comparison (numeric vs semantic) throws to prevent misconfiguration
Microsoft Reviewers: Open in CodeFlow

@bknote71
Copy link
Copy Markdown
Contributor Author

bknote71 commented Apr 9, 2026

@dotnet-policy-service agree

@ReubenBond
Copy link
Copy Markdown
Member

What is the use case for this - why wouldn't numeric versions suffice?

@bknote71
Copy link
Copy Markdown
Contributor Author

What is the use case for this - why wouldn't numeric versions suffice?

A couple of thoughts on this:

Traceability:
A bare ushort like 1026 tells you nothing about what changed
you have to look up a per-grain mapping to understand the change.
Semantic versions are self-describing: v1.2.1 immediately signals a patch on the 1.2 line.
This also makes it straightforward to aggregate changelogs by major/minor across grains.

Versioning in CI/CD:
With semantic versioning, a git tag like v1.2.1 can be injected directly into the build as the version value (no conversion or state needed.)
With ushort, you need to track the last-used number somewhere and increment it, which introduces an external dependency for version assignment itself.

@ReubenBond
Copy link
Copy Markdown
Member

@bknote71 Could you use a comment or a custom attribute for those things? Grain interface versioning is primarily for compatibility breaks it's not intended to be informational.

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