Repository navigation
GH-990: source generator infers a handler's emitted events into an assembly manifest - #991
Merged
Merged
Conversation
…sembly manifest - New JasperFx.Events.ICarriesEvents marker and EmittedEventsAttribute (assembly, AllowMultiple). - New generator pipeline: a method that takes an IEventStream<T> or an IRefersToAggregate parameter, or returns an ICarriesEvents type (incl. tuple / Task<T>), has its body read for AppendOne/AppendMany, ICarriesEvents factory/ctor args, collection initializers and Add calls. Only object-typed parameter slots count as events; object-typed values are skipped. Per-method results are value-equatable, so unrelated edits stay cached. - Pass 2's syntax filter no longer requires "Aggregate" in the attribute name; the IRefersToAggregate check decides, so [WriteModel]/[ReadModel]/[DcbModel] are analyzed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8KxC18Q51z5w4u6YARwe4
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 #990.
Summary
Pass 2 bug fix. The syntax filter now admits any method with an attributed parameter, and the
IRefersToAggregatecheck decides. Before this,[WriteModel]/[ReadModel]/[DcbModel]and user aliases never reached the semantic check.New JasperFx.Events types
ICarriesEvents: a marker interface for return types that carry events without naming them.EmittedEventsAttribute(Type handlerType, string methodName, params Type[] eventTypes): assembly-level, and allows multiple applications so a double-loaded analyzer doesn't fail the build.New generator pass (
EmittedEventsAnalyzer.cs)IEventStream<T>parameter or anIRefersToAggregate-attributed parameter, or returning anICarriesEventstype. That includes tuple elements and looks insideTask<T>/ValueTask<T>.AppendOne/AppendMany; constructors and static factories returning anICarriesEventstype; collection initializers;Add-style calls on anICarriesEventsvalue.object,object[]orIEnumerable<object>count, so aGuidorstringstream id is never mistaken for an event, wherever it sits.object-typed values, anonymous types, and types atypeofat assembly scope can't name.JasperFxEmittedEvents.g.cs, emitted only when the compilation can seeEmittedEventsAttribute. Each method's result is compared by value, so unrelated edits stay cached.Decisions worth a look
ICarriesEventsvalue are matched by name (Add,AddRange,Insert,InsertRange,Append,AppendOne,AppendMany). Matching on parameter shape alone would also pick upContains(object).objectis excluded.Tests
EmittedEventsManifestTests.cscovers:All 96 source generator tests pass, and
jasperfx.slnxbuilds with 0 errors.Wolverine follow-up: JasperFx/wolverine#4914.
🤖 Generated with Claude Code
https://claude.ai/code/session_01J8KxC18Q51z5w4u6YARwe4