Skip to content

Commit

Permalink
[release/9.0] Update field references in property accessors (#108222)
Browse files Browse the repository at this point in the history
* Update field references in property accessors

* Update field references in property accessors (#108225)

* Update field references in property accessors (#108413)

* Update field references in property accessors

* Update field references

* Use @

* Rename field

---------

Co-authored-by: Stephen Toub <[email protected]>

---------

Co-authored-by: Charles Stoner <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2024
1 parent 9e16fe2 commit 226c034
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 49 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 @@ -12,7 +12,7 @@ public AddLambdaCapturingThis()
field = "abcd";
}

public string GetField => field;
public string GetField => this.field;

private string field;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public AddLambdaCapturingThis()
field = "abcd";
}

public string GetField => field;
public string GetField => this.field;

private string field;

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
4 changes: 2 additions & 2 deletions src/tools/illink/test/ILLink.Tasks.Tests/Mock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public MockDriver CreateDriver ()

public static string[] OptimizationNames {
get {
var field = typeof (ILLink).GetField ("_optimizationNames", BindingFlags.NonPublic | BindingFlags.Static);
return (string[]) field.GetValue (null);
var fieldInfo = typeof (ILLink).GetField ("_optimizationNames", BindingFlags.NonPublic | BindingFlags.Static);
return (string[]) fieldInfo.GetValue (null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ static void TestIfElse (bool decision)
private class SimpleType
{
[Kept]
public static int field;
public static int fieldKept;

[Kept]
public int memberKept {
[Kept]
get { return field; }
get { return fieldKept; }
[Kept]
set { field = value; }
set { fieldKept = value; }
}

[Kept]
Expand Down Expand Up @@ -508,4 +508,4 @@ public static class PrefixLookupNestedType { }
private static class PrefixLookupPrivateNestedType { }
}
}
}
}

0 comments on commit 226c034

Please sign in to comment.