Improve detection of Record types (#24409)

This commit is contained in:
Pranav K 2020-07-29 13:27:27 -07:00 committed by GitHub
parent fd9f17ddf9
commit 17687f538c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -143,7 +143,8 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
static bool IsRecordType(Type type)
{
// Based on the state of the art as described in https://github.com/dotnet/roslyn/issues/45777
var cloneMethod = type.GetMethod("<>Clone", BindingFlags.Public | BindingFlags.Instance);
var cloneMethod = type.GetMethod("<Clone>$", BindingFlags.Public | BindingFlags.Instance) ??
type.GetMethod("<>Clone", BindingFlags.Public | BindingFlags.Instance);
return cloneMethod != null && cloneMethod.ReturnType == type;
}
}