Repository navigation
GH-1287 part 3: opt-in JFXEVT018 for a natural key no event sets; one diagnostic for a mistyped mapped key; 3.15.0 - #1289
Merged
Conversation
…iagnostic, not 011 and 015, for a mistyped mapped key JFXEVT018 is off by default. A NaturalKeyFor() call or a projection with [NaturalKeySource] methods can live in another assembly, a referenced library's generic helper, or reach the definition through IAggregateProjection, so no analyzer can rule a registration out on its own. A project that holds every registration turns it on with dotnet_diagnostic.JFXEVT018.severity, and even then any registration it cannot attribute to one aggregate keeps it silent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1287 (part 3; parts 1 and 2 shipped in #1288, in 3.14.0). Also bumps the version to 3.15.0.
JFXEVT018: a natural key that no event sets (opt-in)
A new warning for an owned
[NaturalKey]that nothing in the project sets. "Nothing" means no[NaturalKeySource]method on the aggregate, its base types or any projection of it, and noNaturalKeyFor()call for it. Today the runtime refuses this with theInvalidProjectionExceptioninassertNaturalKeyValidity.It is off by default, because it can't be free of false positives when it's on by default. A mapping can be registered where no analyzer can see it:
[NaturalKeySource]methods) or callsNaturalKeyFor(), the usual Domain/Infrastructure split;IAggregateProjection.NaturalKeyDefinition.AddOrReplaceMapping(), which any code holding the projection can call without naming the aggregate.A project that holds every registration for its aggregates turns it on with
dotnet_diagnostic.JFXEVT018.severity = warning. Turning it on is the explicit assertion the analyzer can't make for itself. Even then it stays silent whenever the project might set the key in a way it can't attribute to one aggregate:NaturalKeyFor()in generic code;[NaturalKeySource]method on a generic projection base;AddOrReplaceMapping()call;NaturalKeyFor/AddOrReplaceMappingname that doesn't resolve.A non-public
[NaturalKeySource]also keeps it silent, because the runtime already names that problem better. When the diagnostic is off, the pipeline returns before it looks at the compilation, so the IDE pays nothing.One diagnostic, not JFXEVT011 and JFXEVT015
A mapped key with the wrong type for its source, whose type is also the aggregate's own key type, used to draw both diagnostics. Now it draws only
JFXEVT015, because fixing the type fixes both. Two other keys that really do share a type still getJFXEVT011.Tests
UnsetNaturalKeyDiagnosticTests(16 tests): off by default; on through compilation options and through a global config; a suppressed global config leaves it off; plus each silence rule above, and the negative cases (a source orNaturalKeyFor()for an unrelated aggregate doesn't count).NaturalKeyDiagnosticTestsfor the 011/015 dedupe: the mapped key declared after the owned key, declared before it, and a genuine clash beside a mistyped key.docs/codegen/diagnostics.mddocuments JFXEVT018 and the dedupe.Gate
The full local gate (
stoat gate exec critter-stack-net11-rc/gate-slot-jasperfx -- ./build.sh Test, with--rooton this nested worktree) is green on this commit. The first run hit the knownDescribeCommandTests.write_file_smoke_testconsole-recorder flake, which is unrelated and passed on the re-run.🤖 Generated with Claude Code