[NativeAOT] Incorrect source generator types when Minimal API endpoint delegate return type is inferred
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
When using an inferred type in the delegate passed to a Minimal API endpoint, the source generator does not generate the correct code.
### Expected Behavior
The source generator should infer the types and generate correct code.
This issue does not occur if the type is explicitly declared.
```csharp
return httpClient.GetFromJsonAsync("https://ipinfo.io/", AppJsonSerializerContext.Default.Response);
```
### Steps To Reproduce
https://github.com/qin-guan/dotnet-minimalapi-source-generator-httpclient-repro
### Exceptions (if any)
_No response_
### .NET Version
9.0.100-preview.4.24267.66
### Anything else?
This also occurs with .NET 8
Please see lines 85 and 102
Contributor guide
Assessment
This issue has not been assessed yet.