Skip to content

Reduce the number of members on ModelMetadataIdentity #15280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,8 @@ protected ModelBindingMessageProvider() { }
public Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataKind MetadataKind { 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 System.Reflection.ParameterInfo ParameterInfo { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Reflection.PropertyInfo PropertyInfo { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Reflection.ParameterInfo ParameterInfo { get { throw null; } }
public System.Reflection.PropertyInfo PropertyInfo { get { throw null; } }
public bool Equals(Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity other) { 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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ private ModelMetadataIdentity(
Type modelType,
string name = null,
Type containerType = null,
ParameterInfo parameterInfo = null,
PropertyInfo propertyInfo = null)
object fieldInfo = null)
{
ModelType = modelType;
Name = name;
ContainerType = containerType;
ParameterInfo = parameterInfo;
PropertyInfo = propertyInfo;
FieldInfo = fieldInfo;
}

/// <summary>
Expand Down Expand Up @@ -100,7 +98,7 @@ public static ModelMetadataIdentity ForProperty(
throw new ArgumentNullException(nameof(containerType));
}

return new ModelMetadataIdentity(modelType, propertyInfo.Name, containerType, propertyInfo: propertyInfo);
return new ModelMetadataIdentity(modelType, propertyInfo.Name, containerType, fieldInfo: propertyInfo);
}

/// <summary>
Expand Down Expand Up @@ -130,7 +128,7 @@ public static ModelMetadataIdentity ForParameter(ParameterInfo parameter, Type m
throw new ArgumentNullException(nameof(modelType));
}

return new ModelMetadataIdentity(modelType, parameter.Name, parameterInfo: parameter);
return new ModelMetadataIdentity(modelType, parameter.Name, fieldInfo: parameter);
}

/// <summary>
Expand Down Expand Up @@ -172,17 +170,19 @@ public ModelMetadataKind MetadataKind
/// </summary>
public string Name { get; }

private object FieldInfo { get; }

/// <summary>
/// Gets a descriptor for the parameter, or <c>null</c> if this instance
/// does not represent a parameter.
/// </summary>
public ParameterInfo ParameterInfo { get; }
public ParameterInfo ParameterInfo => FieldInfo as ParameterInfo;

/// <summary>
/// Gets a descriptor for the property, or <c>null</c> if this instance
/// does not represent a property.
/// </summary>
public PropertyInfo PropertyInfo { get; }
public PropertyInfo PropertyInfo => FieldInfo as PropertyInfo;

/// <inheritdoc />
public bool Equals(ModelMetadataIdentity other)
Expand Down