Azure / Azure/azure-functions-dotnet-worker
No way to access the MethodInfo of function in Middleware
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
When writing Middleware one of the most fundamental thing that almost every middleware will want to do is check the function for its attributes so that the logic can be conditionally applied (e.g an Authorization attribute to mark a function as requiring Authorization).
After digging through the FunctionContext there seem to be no reference to the MethodInfo of the function being called leaving to having to search online for an answer. I thought that surely there was a way to get it without having to reflect into the assembly for the Type and Method but when I came across [juunas11/IsolatedFunctionsAuthentication](https://github.com/juunas11/IsolatedFunctionsAuthentication/blob/f0ce03968f2ce300b5f3ffd09f001d32abd358e2/IsolatedFunctionAuth/Middleware/FunctionContextExtensions.cs#L33-L49)'s Implementation and It seemed quite as if it was the only way to access the MethodInfo.
This feels very unstable and hopefully is not intended to stay as is. Are there any plans to supply the MethodInfo and or Type of the containing class so Middleware's will be able to access any Attributes to execute logic conditionally or with additional information?
Really hoping to see this fixed as it make the Middlewares feel like they are only meant for demonstration purposes.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing FunctionContext and the referenced FunctionContextExtensions.cs implementation in IsolatedFunctionsAuthentication to understand how the current MethodInfo lookup works. Then inspect the worker's middleware and invocation-context APIs to define the supported metadata access and determine what tests would demonstrate attribute-based middleware behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100