Reduce the number of members on ModelMetadataIdentity (#15280)
* Reduce the number of members on ModelMetadataIdentity ModelMetadataIdentity is a discriminated union. We recently introduced an additional member on this type, but are concerned about the performance implication of doing this. This change uses a discriminated field to reset the member count to 3.0.
This commit is contained in:
parent
9bb9fc3bdc
commit
8c77190db5
|
|
@ -882,8 +882,8 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||||
public Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataKind MetadataKind { get { throw null; } }
|
public Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataKind MetadataKind { get { throw null; } }
|
||||||
public System.Type ModelType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
public System.Type ModelType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
||||||
public System.Reflection.ParameterInfo ParameterInfo { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
public System.Reflection.ParameterInfo ParameterInfo { get { throw null; } }
|
||||||
public System.Reflection.PropertyInfo PropertyInfo { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
|
public System.Reflection.PropertyInfo PropertyInfo { get { throw null; } }
|
||||||
public bool Equals(Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity other) { throw null; }
|
public bool Equals(Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity other) { throw null; }
|
||||||
public override bool Equals(object obj) { throw null; }
|
public override bool Equals(object obj) { throw null; }
|
||||||
public static Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity ForParameter(System.Reflection.ParameterInfo parameter) { throw null; }
|
public static Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity ForParameter(System.Reflection.ParameterInfo parameter) { throw null; }
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,12 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||||
Type modelType,
|
Type modelType,
|
||||||
string name = null,
|
string name = null,
|
||||||
Type containerType = null,
|
Type containerType = null,
|
||||||
ParameterInfo parameterInfo = null,
|
object fieldInfo = null)
|
||||||
PropertyInfo propertyInfo = null)
|
|
||||||
{
|
{
|
||||||
ModelType = modelType;
|
ModelType = modelType;
|
||||||
Name = name;
|
Name = name;
|
||||||
ContainerType = containerType;
|
ContainerType = containerType;
|
||||||
ParameterInfo = parameterInfo;
|
FieldInfo = fieldInfo;
|
||||||
PropertyInfo = propertyInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -100,7 +98,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||||
throw new ArgumentNullException(nameof(containerType));
|
throw new ArgumentNullException(nameof(containerType));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ModelMetadataIdentity(modelType, propertyInfo.Name, containerType, propertyInfo: propertyInfo);
|
return new ModelMetadataIdentity(modelType, propertyInfo.Name, containerType, fieldInfo: propertyInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -130,7 +128,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||||
throw new ArgumentNullException(nameof(modelType));
|
throw new ArgumentNullException(nameof(modelType));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ModelMetadataIdentity(modelType, parameter.Name, parameterInfo: parameter);
|
return new ModelMetadataIdentity(modelType, parameter.Name, fieldInfo: parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -172,17 +170,19 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
|
private object FieldInfo { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a descriptor for the parameter, or <c>null</c> if this instance
|
/// Gets a descriptor for the parameter, or <c>null</c> if this instance
|
||||||
/// does not represent a parameter.
|
/// does not represent a parameter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ParameterInfo ParameterInfo { get; }
|
public ParameterInfo ParameterInfo => FieldInfo as ParameterInfo;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a descriptor for the property, or <c>null</c> if this instance
|
/// Gets a descriptor for the property, or <c>null</c> if this instance
|
||||||
/// does not represent a property.
|
/// does not represent a property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PropertyInfo PropertyInfo { get; }
|
public PropertyInfo PropertyInfo => FieldInfo as PropertyInfo;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Equals(ModelMetadataIdentity other)
|
public bool Equals(ModelMetadataIdentity other)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue