Azure / Azure/azure-functions-dotnet-worker
DefaultMethodInfoLocator can't locate internal function methods
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
The build process allows me to define functions using internal classes and internal methods, like the following:
```csharp
internal static class HelloSequenceUntyped
{
[Function(nameof(StartHelloCitiesUntyped))]
internal static async Task StartHelloCitiesUntyped(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
[DurableClient] DurableClientContext durableContext,
FunctionContext executionContext)
{
/* implementation */
}
```
The Functions host correctly detects these functions, as can be seen by the console output after pressing F5. However, shortly after startup, the .NET worker throws an `InvalidOperationException` because it can't find the function method.
The following is the code snippet where the exception gets thrown because `methodInfo` is null.
```csharp
Type? functionType = assembly.GetType(typeName);
MethodInfo? methodInfo = functionType?.GetMethod(methodName); // <-- RETURNS NULL
if (methodInfo == null)
{
throw new InvalidOperationException($"Method '{methodName}' specified in {nameof(FunctionDefinition.EntryPoint)} was not found. This function cannot be created."); // <-- THROWS HERE
}
```
### Expected
The .NET worker should be able to find my internal methods if the Functions host itself is able to find them.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at DefaultMethodInfoLocator and inspect the assembly.GetType and GetMethod lookup shown in the report. Reproduce the failure with an internal class and internal function method, then verify that the worker can locate and create the function without throwing InvalidOperationException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100