/// <summary>
/// Creates a <see cref="MemberExpression"/> accessing a field.
/// </summary>
/// <param name="expression">The containing object of the field. This can be null for static fields.</param>
/// <param name="fieldName">The field to be accessed.</param>
/// <returns>The created <see cref="MemberExpression"/>.</returns>
public static MemberExpression Field(Expression expression, string fieldName)
{
RequiresCanRead(expression, "expression");
// bind to public names first
var fi = expression.Type.GetField(fieldName, _publicFlags) ?? expression.Type.GetField(fieldName, _nonPublicFlags);
if (fi == null)
{
throw Error.InstanceFieldNotDefinedForType(fieldName, expression.Type);
}
return(Field(expression, fi));
}