Browsing the source code on dotnet/corefx on GitHub for System.Linq.Expressions, I found the following code:
MethodInfo mi = property.GetGetMethod(true);
if (mi == null)
{
mi = property.GetSetMethod(true);
if (mi == null)
{
throw Error.PropertyDoesNotHaveAccessor(property, nameof(property));
}
}
Is there any way that GetGetMethod
and GetSetMethod
can both return null, as seems to be accounted for here? Is this dead code? The C# compiler doesn't allow for a property to have no getter and no setter, so how is this possible for PropertyInfo
Aucun commentaire:
Enregistrer un commentaire