Add opt-in EmitShapeTag support - #49
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Summary by CodeRabbit
WalkthroughThe serializer generator now supports opt-in shape-tag emission through the obsolete ChangesShape tag emission
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SerializerAttribute
participant ZeroSerializerGenerator
participant TypeGenerationModel
participant GeneratedView
SerializerAttribute->>ZeroSerializerGenerator: Read EmitShapeTag = true
ZeroSerializerGenerator->>TypeGenerationModel: Store emitShapeTag
ZeroSerializerGenerator->>GeneratedView: Emit ShapeTag remarks and constant
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
There was a problem hiding this comment.
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 `@tests/ShapeTagEmissionTests.cs`:
- Around line 22-36: Strengthen the ShapeTag emission tests: in the default-mode
test, assert that an uncommented public ShapeTag declaration is absent, and in
ShapeTagAndRemarksAreEmittedWhenRequested, assert that the public ShapeHash
declaration is still present. Keep the existing assertions for commented
ShapeTag output and enabled remarks.
🪄 Autofix
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: 29f7f5a9-e159-4a56-8d24-5e78fdd11630
📒 Files selected for processing (4)
src/TypeGenerationModel.cssrc/ZeroSerializerGenerator.cstests/SerializationModels.cstests/ShapeTagEmissionTests.cs
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: test (Debug)
- GitHub Check: test (Release)
🔇 Additional comments (4)
src/ZeroSerializerGenerator.cs (1)
114-117: LGTM!Also applies to: 292-292, 373-407, 957-980
src/TypeGenerationModel.cs (1)
18-26: LGTM!Also applies to: 39-40
tests/ShapeTagEmissionTests.cs (1)
39-71: LGTM!tests/SerializationModels.cs (1)
25-25: 📐 Maintainability & Code QualityNo warning-policy issue found. The test project and repository configuration do not promote
CS0618warnings to errors. No narrow suppression is required.> Likely an incorrect or invalid review comment.
Co-authored-by: sator-imaging <16752340+sator-imaging@users.noreply.github.com>
EmitShapeTag support
Motivation
ShapeTagby default because it can expose internal type details, while still providingShapeHashfor consumers and an opt-in escape hatch.Description
public bool EmitShapeTag;and an explicit parameterless constructor on the generatedZeroSerializerAttributeso consumers can opt in; changes insrc/ZeroSerializerGenerator.cs.ShouldEmitShapeTagthat inspects attribute arguments and pipes the result into theTypeGenerationModelvia a newEmitShapeTagproperty insrc/TypeGenerationModel.cs.<remarks>and the activepublic const string ShapeTagare emitted only whenEmitShapeTagis true, otherwise a commented-outShapeTagline with guidance is emitted, whileShapeHashis always generated; changes insrc/ZeroSerializerGenerator.cs.ShapeTag, and added a new unit test filetests/ShapeTagEmissionTests.csthat covers default suppression, explicit emission, and the injected attribute contents.Testing
git diff --checkandgit diff --cached --check, which succeeded.dotnet test tests/ZeroSerializer.Tests.csproj -f net8.0 --no-restorebut the environment does not havedotnetinstalled so the command could not be executed.tests/ShapeTagEmissionTests.cs) and model fixtures were updated (tests/SerializationModels.cs), but the C# test run was not executed in this environment due to the missingdotnettool.Codex Task