-
Notifications
You must be signed in to change notification settings - Fork 5
Auto-detect AutoComplete setting #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
93e0deb
locate attribute to read AutoComplete value
timbussmann 082c06c
rename public APIs
timbussmann a148188
remove obsolete method usage
timbussmann ade72e6
extract reflection code into helper
timbussmann 23f9d15
add more details to the reflection helper exception message
timbussmann 07081a9
merge AttributeDiscoverer and ReflectionHelper methods
timbussmann c7d396f
Merge remote-tracking branch 'origin/transactions' into auto-detect
timbussmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 0 additions & 38 deletions
38
src/NServiceBus.AzureFunctions.InProcess.ServiceBus/AttributeDiscoverer.cs
This file was deleted.
Oops, something went wrong.
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
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
50 changes: 50 additions & 0 deletions
50
src/NServiceBus.AzureFunctions.InProcess.ServiceBus/ReflectionHelper.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| namespace NServiceBus.AzureFunctions.InProcess.ServiceBus | ||
| { | ||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Reflection; | ||
| using Microsoft.Azure.ServiceBus; | ||
| using Microsoft.Azure.WebJobs; | ||
|
|
||
| class ReflectionHelper | ||
| { | ||
| public static bool GetAutoCompleteValue() | ||
timbussmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| var triggerAttribute = FindTriggerAttributeInternal(); | ||
| if (triggerAttribute != null) | ||
| { | ||
| return triggerAttribute.AutoComplete; | ||
| } | ||
|
|
||
| throw new Exception($"Could not locate {nameof(ServiceBusTriggerAttribute)} to infer the AutoComplete setting. Make sure that the function trigger contains a parameter decorated with {nameof(ServiceBusTriggerAttribute)} or use the advanced APIs exposed via the {nameof(FunctionEndpoint)} type instead."); | ||
| } | ||
|
|
||
| public static ServiceBusTriggerAttribute FindBusTriggerAttribute() => FindTriggerAttributeInternal(); | ||
|
|
||
| static ServiceBusTriggerAttribute FindTriggerAttributeInternal() | ||
| { | ||
| var st = new StackTrace(skipFrames: 2); // skip first two frames because it is this method + the public method | ||
| var frames = st.GetFrames(); | ||
| foreach (var frame in frames) | ||
| { | ||
| var method = frame?.GetMethod(); | ||
| if (method?.GetCustomAttribute<FunctionNameAttribute>(false) != null) | ||
| { | ||
| foreach (var parameter in method.GetParameters()) | ||
| { | ||
| ServiceBusTriggerAttribute serviceBusTriggerAttribute; | ||
| if (parameter.ParameterType == typeof(Message) | ||
timbussmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| && (serviceBusTriggerAttribute = parameter.GetCustomAttribute<ServiceBusTriggerAttribute>(false)) != null) | ||
| { | ||
| return serviceBusTriggerAttribute; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
| } | ||
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be calling in to an obsolete method? We're going to have to fix it as soon as we update to 2.0 anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was just to not duplicate the code because the obsoleted message still needs to work and it can't call
ProcessNonTransactionalbecause of the missing receiver (or pass null but I didn't like that). I'm fine either way.