Resolve a command's key where the context values are built - #2434
Conversation
Reading the key from the command was done where the key is read, which made an extension method reach into the service provider for the rules and gave a caller without one a different answer. It now happens while the command context values are being built, next to the providers that resolve the key in the first place: once per command rather than once per read model resolved, and the same answer for everything that reads it. GetResolvedKey() is a lookup again. The overload taking a service provider shipped in 20.68.0, so it stays and is marked obsolete rather than removed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VRa2Z1cA6D3Fuw9TAo6m2p
ARCCHR0008 named the attribute to use but read like a typo, when what it reports is that key resolution has changed underneath the command - so the message now says what happens if it is left alone, and the report sits on the attribute rather than the property name. The fix writes the attribute out in full rather than adding a using: a file marking the data annotations attribute already imports that namespace, and with both in scope a bare [Key] is ambiguous. It is annotated for simplification, so it shortens once the old using goes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VRa2Z1cA6D3Fuw9TAo6m2p
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VRa2Z1cA6D3Fuw9TAo6m2p
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VRa2Z1cA6D3Fuw9TAo6m2p
|
Addresses the two things I flagged as unsettled on #2431 rather than leaving them as caveats. Key resolution moved out of the extension method#2431 read a command's key inside The third option is better than either: resolve the key in the builder, after the providers have run and only if none wrote one. It is a DI service, so nothing is service-located; precedence is a single explicit branch; and it fixes two things beyond the smell:
ARCCHR0008 made actionableThe rule always fired once Chronicle was referenced — the gap was that it read like a typo when what it reports is that key resolution changed underneath commands nobody touched. So the message now names the consequence, the report sits on the attribute rather than the property name, and there is a code fix. The fix writes Two supporting changes worth knowing about:
This does not close #2433 — that is about surfacing the change at the moment Chronicle is added, which an analyzer cannot see. It does make the diagnostic that fires afterwards say the right thing and fix itself. VerificationClean All 15 spec projects green: Arc.Core 1596, Chronicle 563, Chronicle.CodeAnalysis 41, Screenplay 1173, ProxyGenerator 1039, MongoDB 148, EF 300 and the rest. The new and changed specs were also run isolated by filter.
ReviewAuthored by an agent with no human review. |
Summary
Follows up the two loose ends left by #2431.
Added
ARCCHR0008, rewriting a command's data annotations[Key]into the Chronicle one (Support injecting read models from non-Chronicle providers into the command pipeline #2303)Changed
ARCCHR0008says what happens if it is left alone — Chronicle resolves a new event source id for the command and every read model keyed by it resolves to nothing — and reports on the attribute rather than the property name (Support injecting read models from non-Chronicle providers into the command pipeline #2303)Deprecated
CommandContextExtensions.GetResolvedKey(CommandContext, IServiceProvider). A command's key is now resolved while the command context values are being built, soGetResolvedKey()reads it without a service provider (Support injecting read models from non-Chronicle providers into the command pipeline #2303)