RequestDelegateGenerator requires the object to implement `IParsable<T>` or otherwise have a `TryParse` method.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
With the `RequestDelegateGenerator` enabled (`PublishAoT` or `EnableRequestDelegateGenerator` to `true`), minimal api endpoints with `[FromForm]` on a model without a custom-made `TryParse` method will not compile correctly.
`[FromBody]` - which I imagine would work more-or-less the same in this regard - does not have this issue.
Note: I have not tested whether these actually _work_ for `[FromBody]` (or any of the other ones, for that matter), but the generated code _compiles_ for all but the two non-`TryParsable` `[FromForm]`-based endpoints.
### Expected Behavior
`[FromForm]` and `[FromBody]` should work identically, and should not require the developer to create their own `TryParse` method.
### Steps To Reproduce
https://github.com/KennethHoff/Repros/tree/66a2d8c3b53fd64dfc5f3880cb2db8d9cac6550a/AspNetCoreRequestDelegateGenerator
### Exceptions (if any)
#### On .Net 8 (All compiler versions mentioned below):
```
0>GeneratedRouteBuilderExtensions.g.cs(520,59): Error CS0029 : Cannot implicitly convert type 'string' to 'NotParsableForm'
0>GeneratedRouteBuilderExtensions.g.cs(551,59): Error CS0029 : Cannot implicitly convert type 'string' to 'NotParsableForm'
0>GeneratedRouteBuilderExtensions.g.cs(637,67): Error CS0029 : Cannot implicitly convert type 'string' to 'ImplicitlyParseOnlyForm'
0>GeneratedRouteBuilderExtensions.g.cs(668,67): Error CS0029 : Cannot implicitly convert type 'string' to 'ImplicitlyParseOnlyForm'
```
#### On .Net 9 (With `9.0.100-preview.1.24101.2`):
```
0>GeneratedRouteBuilderExtensions.g.cs(526,59): Error CS0029 : Cannot implicitly convert type 'string' to 'NotParsableForm'
0>GeneratedRouteBuilderExtensions.g.cs(557,59): Error CS0029 : Cannot implicitly convert type 'string' to 'NotParsableForm'
0>GeneratedRouteBuilderExtensions.g.cs(645,67): Error CS0029 : Cannot implicitly convert type 'string' to 'ImplicitlyParseOnlyForm'
0>GeneratedRouteBuilderExtensions.g.cs(676,67): Error CS0029 : Cannot implicitly convert type 'string' to 'ImplicitlyParseOnlyForm'
```
### .NET Version
Tested with all the following versions:
`8.0.100`, `8.0.201`, `9.0.100-preview.1.24101.2`
### Anything else?
This was tested on Linux, but I have also experienced the general premise (`cannot implicitly convert type 'string' to ''` with `[FromForm]` on Windows.
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.