Commit ce4b019
Explicit AddHandler registration API (#7439)
* Add IHandleMessages and config extension
* Make RegisterHandler generic
* Move IsMessageHandler
* Don't deprecate RegisterHandler(Type) with error, use reflection to call generic
* Remove separate timeout handler registration method
* Replace GetMessageTypesBeingHandledBy implementation with more efficient one that doesn't use MakeGenericType (which is not AOT friendly)
* Bring the generics further down
* Change runtime check for injecting IMessageSession into compile-time analyzer
* Handler creation is ugly but might work
* Error in nullability test was excluding types with get-only properties that did have nullability enabled
* Not needed due to the new analyzer
* Can have IHandleMessages & IHandleTimeouts of same type
* Registration of both handler and timeout only when necessary, using reflection but I don't think anything AOT-averse
* Also not needed due to new analyzer
* This is wrong, this is done at a level up - at this level it could be both timeout/handler
* Parameterless IHandleTimeouts doesn't need to exist with the updated implementation
* RegisterHandler interceptor
* Made the first stage very memoizable
* Memoizable at all 3 levels
* Ability to output stage results
* Create method name from stable hash of file path + source span
* Generator test will automatically account for platform-unique data on interceptor attributes
* Remove test for unsupported handler registration in container
* Hash only handler type and dedupe calls
* Change RegisterHandler to AddHandler
* See if we can achieve something different
* Strong typing through
* Simplify
* Deprecate the removed MessageHandler constructor with error
* Easier to read without one inverted, and must be able to register for Handle and Timeout
* Fix tests
* Split add methods for handler and timeout with stronger generic constraints
* Fix interceptor with longer method name
* Add saga to interceptor test
* Just messing with the spacing/indent in the tests
* Fix after rebase
* Approve
* Variable naming
* Sealing
* Variable naming
* Sealed
* Rename to factories for now
* Cleanup test
* Add multi interface test
* Correctly cache factory for now
* Faster casting
* Dedup
* Add additional test
* Fix and use slight redundancy for better clarity
* Use built-in API
* Move handler related stuff
* Use non-cryptographic hash
* Fix spacin
* Cleanup
* InterceptDetails is too large to be a struct
* Simplify generator
* Remove leftover struct
* Remove using
* Stable ordering of method names
* Specify types explicitely to avoid nullable ref types
* Fast path first
* Simplify slightly
* Switch to symbol based analysis (#7483)
* Switch to symbol based analysis
* Static delegate
* No need for generics
* Use GetTypeSymbolOrDefault
* Be more defensive and avoid closure
* Inline directly
* Cleanup using
---------
Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com>
* Extracing non-cryptographic hash that will be useful in other source generators as well
* Span based
* For loop
* Manual unrolling and unsafe
BenchmarkDotNet v0.13.8, macOS 26.1 (25B78) [Darwin 25.1.0]
Apple M4 Max, 1 CPU, 16 logical and 16 physical cores
.NET SDK 10.0.100
[Host] : .NET 10.0.0 (10.0.25.52411), Arm64 RyuJIT AdvSIMD
DefaultJob : .NET 10.0.0 (10.0.25.52411), Arm64 RyuJIT AdvSIMD
| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio |
|----------------- |---------:|----------:|----------:|------:|--------:|----------:|------------:|
| HashBaseline | 8.429 ns | 0.1537 ns | 0.1438 ns | 1.00 | 0.00 | - | NA |
| HashUnroll | 7.728 ns | 0.0663 ns | 0.0620 ns | 0.92 | 0.02 | - | NA |
| HashUnsafe | 8.213 ns | 0.1716 ns | 0.1605 ns | 0.97 | 0.03 | - | NA |
| HashUnsafeUnroll | 7.311 ns | 0.0792 ns | 0.0702 ns | 0.87 | 0.02 | - | NA |
* Use AddHandler api to register handlers in ATTs (#7482)
* Use AddHandler api to register handlers in ATTs
* Test cleanup
* Fix conventions in test
* Test cleanup
* Use asm qualified name
* Test cleanup
* Naive fix to the handler ordering
* Test cleanup
* Register messages handled by the endpoint as messages
* Rollback unneded test change
* Rollback unneded test change
* Uneeded test change
* Cleanup
* Remove usings
* Use AddHandler to control handler ordering
* Revert handler registry changes
* Switch to add handler instead of ExecuteTheseHandlersFirst
* Initialize handler registry earlier
* Obsolete ExecuteTheseHandlersFirst with error
* Approvals
* Move diagnostic entry to a better place
* Cleanup test
* Test cleanup
* Remove handler detection code from the MessageMetadataRegistry
* Refactor
* Add test that ensures that we can types for messages
* Cleanup
* Add test that scans handlers
* Make message public
* Simplify
* Move obsoletes
---------
Co-authored-by: Daniel Marbach <daniel.marbach@openplace.net>
Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com>
* Fix after rebase
* Get rid of scanning in ATTs
* Cleanup att server
* Remove uneeded config
* Better test name
* Remove EditorBrowsable attributes on AddMessage/TimeoutHandlerForMessage methods
---------
Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com>
Co-authored-by: Andreas Öhlund <andreas.ohlund@particular.net>
Co-authored-by: Daniel Marbach <daniel.marbach@openplace.net>1 parent c120b15 commit ce4b019
File tree
66 files changed
+1478
-927
lines changed- src
- NServiceBus.AcceptanceTesting
- Customization
- Support
- NServiceBus.AcceptanceTests
- Core
- BestPractices
- Conventions
- Hosting
- Mutators
- OpenTelemetry
- Pipeline
- Sagas
- SubscriptionMigration
- EndpointTemplates
- Routing
- Sagas
- Serialization
- NServiceBus.Core.Analyzer.Tests.Common/Helpers
- NServiceBus.Core.Analyzer.Tests.Roslyn4
- ApprovalFiles
- Handlers
- NServiceBus.Core.Analyzer
- Handlers
- Utility
- NServiceBus.Core.Tests
- API
- ApprovalFiles
- Handlers
- OpenTelemetry
- Pipeline
- Incoming
- Routing/Routers
- Unicast
- Config
- Messages
- NServiceBus.Core
- Pipeline/Incoming
- Receiving
- Serialization
- Unicast
- Config
- Messages
- NServiceBus.Testing.Fakes
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
66 files changed
+1478
-927
lines changedLines changed: 20 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
34 | 45 | | |
35 | 46 | | |
36 | 47 | | |
| |||
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
80 | 97 | | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
118 | 125 | | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
src/NServiceBus.AcceptanceTests/Core/BestPractices/When_injecting_message_session_into_handlers.cs
Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 4 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 30 | + | |
| 31 | + | |
37 | 32 | | |
38 | 33 | | |
39 | 34 | | |
40 | 35 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 36 | + | |
45 | 37 | | |
46 | | - | |
| 38 | + | |
47 | 39 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 40 | | |
54 | 41 | | |
55 | 42 | | |
56 | 43 | | |
57 | 44 | | |
58 | | - | |
59 | | - | |
60 | 45 | | |
61 | 46 | | |
62 | 47 | | |
| |||
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
Lines changed: 2 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | | - | |
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
| |||
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
56 | | - | |
| 54 | + | |
57 | 55 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 56 | | |
64 | 57 | | |
65 | 58 | | |
66 | 59 | | |
67 | 60 | | |
68 | 61 | | |
69 | 62 | | |
70 | | - | |
71 | | - | |
72 | 63 | | |
73 | 64 | | |
74 | 65 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 8 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | 31 | | |
36 | 32 | | |
37 | | - | |
| 33 | + | |
38 | 34 | | |
39 | | - | |
40 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
41 | 38 | | |
42 | | - | |
| 39 | + | |
43 | 40 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | 41 | | |
50 | 42 | | |
51 | 43 | | |
| |||
54 | 46 | | |
55 | 47 | | |
56 | 48 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | 49 | | |
61 | 50 | | |
62 | | - | |
| 51 | + | |
63 | 52 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 53 | | |
70 | 54 | | |
71 | 55 | | |
72 | 56 | | |
73 | 57 | | |
74 | 58 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | 59 | | |
79 | 60 | | |
| 61 | + | |
| 62 | + | |
80 | 63 | | |
0 commit comments