Skip to content

Commit

Permalink
Update field references in property accessors (#108219)
Browse files Browse the repository at this point in the history
  • Loading branch information
cston committed Sep 25, 2024
1 parent 3ab61c2 commit f4ba4d9
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,20 @@ public bool TypeHasCharacteristicsRequiredToBeLoadableTypeEquivalentType
return false;
}

foreach (var field in GetFields())
foreach (var fieldInfo in GetFields())
{
if (field.IsLiteral)
if (fieldInfo.IsLiteral)
{
// Literal fields are ok
continue;
}

if (field.IsStatic)
if (fieldInfo.IsStatic)
{
return false;
}

if (field.GetEffectiveVisibility() != EffectiveVisibility.Public)
if (fieldInfo.GetEffectiveVisibility() != EffectiveVisibility.Public)
{
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ public virtual TypeDesc UnderlyingType
if (!this.IsEnum)
return this;

foreach (var field in this.GetFields())
foreach (var fieldInfo in this.GetFields())
{
if (!field.IsStatic)
return field.FieldType;
if (!fieldInfo.IsStatic)
return fieldInfo.FieldType;
}

ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadGeneral, this);
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ public override TypeDesc UnderlyingType

foreach (var handle in _typeDefinition.GetFields())
{
var field = _module.GetField(handle, this);
if (!field.IsStatic)
return field.FieldType;
var fieldInfo = _module.GetField(handle, this);
if (!fieldInfo.IsStatic)
return fieldInfo.FieldType;
}

return base.UnderlyingType; // Use the base implementation to get consistent error behavior
Expand Down
12 changes: 6 additions & 6 deletions src/libraries/Common/src/System/Net/CookieParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ private static FieldInfo IsQuotedDomainField
if (s_isQuotedDomainField == null)
{
// TODO https://github.com/dotnet/runtime/issues/19348:
FieldInfo? field = typeof(Cookie).GetField("IsQuotedDomain", BindingFlags.Instance | BindingFlags.NonPublic);
Debug.Assert(field != null, "We need to use an internal field named IsQuotedDomain that is declared on Cookie.");
s_isQuotedDomainField = field;
FieldInfo? fieldInfo = typeof(Cookie).GetField("IsQuotedDomain", BindingFlags.Instance | BindingFlags.NonPublic);
Debug.Assert(fieldInfo != null, "We need to use an internal field named IsQuotedDomain that is declared on Cookie.");
s_isQuotedDomainField = fieldInfo;
}

return s_isQuotedDomainField;
Expand All @@ -570,9 +570,9 @@ private static FieldInfo IsQuotedVersionField
if (s_isQuotedVersionField == null)
{
// TODO https://github.com/dotnet/runtime/issues/19348:
FieldInfo? field = typeof(Cookie).GetField("IsQuotedVersion", BindingFlags.Instance | BindingFlags.NonPublic);
Debug.Assert(field != null, "We need to use an internal field named IsQuotedVersion that is declared on Cookie.");
s_isQuotedVersionField = field;
FieldInfo? fieldInfo = typeof(Cookie).GetField("IsQuotedVersion", BindingFlags.Instance | BindingFlags.NonPublic);
Debug.Assert(fieldInfo != null, "We need to use an internal field named IsQuotedVersion that is declared on Cookie.");
s_isQuotedVersionField = fieldInfo;
}

return s_isQuotedVersionField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ public bool isStatic
{
get
{
if (this is FieldSymbol field)
if (this is FieldSymbol fieldInfo)
{
return field.isStatic;
return fieldInfo.isStatic;
}

if (this is EventSymbol ev)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ internal Type MemberType
{
if (_memberType == null)
{
if (MemberInfo is FieldInfo field)
_memberType = field.FieldType;
if (MemberInfo is FieldInfo fieldInfo)
_memberType = fieldInfo.FieldType;
else if (MemberInfo is PropertyInfo prop)
_memberType = prop.PropertyType;
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ internal ConstantModel[] Constants
FieldInfo[] fields = Type.GetFields();
for (int i = 0; i < fields.Length; i++)
{
FieldInfo field = fields[i];
ConstantModel? constant = GetConstantModel(field);
FieldInfo fieldInfo = fields[i];
ConstantModel? constant = GetConstantModel(fieldInfo);
if (constant != null) list.Add(constant);
}
_constants = list.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,8 @@ public class GenericClassWithVarArgMethod<T>

public T publicField
{
get { return field; }
set { field = value; }
get { return this.field; }
set { this.field = value; }
}

public T ReturnAndSetField(T newFieldValue, params T[] moreFieldValues)
Expand All @@ -815,8 +815,8 @@ public class ClassWithVarArgMethod

public int publicField
{
get { return field; }
set { field = value; }
get { return this.field; }
set { this.field = value; }
}

public int ReturnAndSetField(int newFieldValue, params int[] moreFieldValues)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,9 @@ public Type MemberType
{
get
{
FieldInfo field = MemberInfo as FieldInfo;
if (field != null)
return field.FieldType;
FieldInfo fieldInfo = MemberInfo as FieldInfo;
if (fieldInfo != null)
return fieldInfo.FieldType;
return ((PropertyInfo)MemberInfo).PropertyType;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ public Dele Field
{
get
{
return field;
return this.field;
}

set
{
field = value;
this.field = value;
}
}

Expand Down Expand Up @@ -372,12 +372,12 @@ public Dele Field
{
get
{
return field;
return this.field;
}

set
{
field = value;
this.field = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,12 +776,12 @@ public Dele Field
{
get
{
return field;
return this.field;
}

set
{
field = value;
this.field = value;
}
}

Expand Down Expand Up @@ -864,12 +864,12 @@ public Dele Field
{
get
{
return field;
return this.field;
}

set
{
field = value;
this.field = value;
}
}

Expand Down Expand Up @@ -952,12 +952,12 @@ public Dele Field
{
get
{
return field;
return this.field;
}

set
{
field = value;
this.field = value;
}
}

Expand Down Expand Up @@ -1041,12 +1041,12 @@ public Dele Field
{
get
{
return field;
return this.field;
}

set
{
field = value;
this.field = value;
}
}

Expand Down

0 comments on commit f4ba4d9

Please sign in to comment.