Closed
Description
This exception should occur in ASP.NET Core OData 8 too, because I'm talking about the code which exists in Shared section of repository codes
I've updated my owin / web api 2 project to .NET 6 and I'm getting a Sequence contains more than one matching element at following:
internal static readonly MethodInfo EnumTryParseMethod = typeof(Enum).GetMethods()
.Single(m => m.Name == "TryParse" && m.GetParameters().Length == 2);
Assemblies affected
OData WebApi lib 7.5.8
Reproduce steps
Run following in .NET 6 console app:
typeof(Enum).GetMethods()
.Single(m => m.Name == "TryParse" && m.GetParameters().Length == 2)
Expected result
TryParse method should get reflected.
Actual result
Invalid operation exception
Additional detail
In .NET 5 and older versions, we only have TryParse method which accepts a string
value.
In .NET 6, a new overload has been added which accepts ReadOnlySpan<char>