Replace interceptor with source-generated extension method #22
Replace interceptor with source-generated extension method #22mattmercurio merged 5 commits intomainfrom
Conversation
mattmercurio
commented
Feb 18, 2026
- Generate AddNServiceBusFunctions() directly into the host project instead of intercepting a placeholder
- Detect host project MSBuild properties
- Add warning when endpoint registrations exist but AddNServiceBusFunctions() is not called
| sb.AppendLine(" }"); | ||
| sb.AppendLine("}"); | ||
| sb.AppendLine(); | ||
| sb.AppendLine("namespace NServiceBus"); |
There was a problem hiding this comment.
Should it be put into the user namespace instead so that it doesn't clash?
There was a problem hiding this comment.
Using RootNamespace property and captured that on the board for packaging items. Unless we should do another way such as compilation.Assembly.Name?
| sb.AppendLine("namespace NServiceBus"); | ||
| sb.AppendLine("{"); | ||
| sb.AppendLine(" static file class NServiceBusFunctionsInterceptors"); | ||
| sb.AppendLine(" [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); |
There was a problem hiding this comment.
Out of curiousity: Why browsable state never?
There was a problem hiding this comment.
Yeaaa. That would have been quite obvious to a user I suppose.
src/NServiceBus.AzureFunctions.Analyzer/FunctionCompositionGenerator.cs
Outdated
Show resolved
Hide resolved
| }); | ||
| } | ||
|
|
||
| static bool HasAutoGeneratedRegistrationTypes( |
There was a problem hiding this comment.
This might be a stupid question. I only had limited time today to look at this. I was wondering given the generator generates a well know type in a well known namespace couldn't we simply check for the metadata to exist?
|
|
||
| if (nodeContext.Node is InvocationExpressionSyntax | ||
| { | ||
| Expression: MemberAccessExpressionSyntax |
There was a problem hiding this comment.
I think this would also fire and flip the call found for similar method names, and you probably would have to check whether it is the real method you are looking for
|
@mattmercurio unfortunately this might require some rebasing |
danielmarbach
left a comment
There was a problem hiding this comment.
Discussed it today. Pre-approving since we want to further iterate on things anyway over time this is good enough for now.
…rviceBusFunctions. Detect host project. Warn if AddNServiceBusFunctions not called.
b940fbb to
d23c600
Compare