Skip to content

Commit 226c034

Browse files
github-actions[bot]cstonstephentoub
authored
[release/9.0] Update field references in property accessors (#108222)
* 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]>
1 parent 9e16fe2 commit 226c034

File tree

15 files changed

+49
-49
lines changed

15 files changed

+49
-49
lines changed

src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.TypeEquivalence.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,20 @@ public bool TypeHasCharacteristicsRequiredToBeLoadableTypeEquivalentType
136136
return false;
137137
}
138138

139-
foreach (var field in GetFields())
139+
foreach (var fieldInfo in GetFields())
140140
{
141-
if (field.IsLiteral)
141+
if (fieldInfo.IsLiteral)
142142
{
143143
// Literal fields are ok
144144
continue;
145145
}
146146

147-
if (field.IsStatic)
147+
if (fieldInfo.IsStatic)
148148
{
149149
return false;
150150
}
151151

152-
if (field.GetEffectiveVisibility() != EffectiveVisibility.Public)
152+
if (fieldInfo.GetEffectiveVisibility() != EffectiveVisibility.Public)
153153
{
154154
return false;
155155
}

src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,10 @@ public virtual TypeDesc UnderlyingType
472472
if (!this.IsEnum)
473473
return this;
474474

475-
foreach (var field in this.GetFields())
475+
foreach (var fieldInfo in this.GetFields())
476476
{
477-
if (!field.IsStatic)
478-
return field.FieldType;
477+
if (!fieldInfo.IsStatic)
478+
return fieldInfo.FieldType;
479479
}
480480

481481
ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadGeneral, this);

src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ public override TypeDesc UnderlyingType
464464

465465
foreach (var handle in _typeDefinition.GetFields())
466466
{
467-
var field = _module.GetField(handle, this);
468-
if (!field.IsStatic)
469-
return field.FieldType;
467+
var fieldInfo = _module.GetField(handle, this);
468+
if (!fieldInfo.IsStatic)
469+
return fieldInfo.FieldType;
470470
}
471471

472472
return base.UnderlyingType; // Use the base implementation to get consistent error behavior

src/libraries/Common/src/System/Net/CookieParser.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,9 @@ private static FieldInfo IsQuotedDomainField
553553
if (s_isQuotedDomainField == null)
554554
{
555555
// TODO https://github.com/dotnet/runtime/issues/19348:
556-
FieldInfo? field = typeof(Cookie).GetField("IsQuotedDomain", BindingFlags.Instance | BindingFlags.NonPublic);
557-
Debug.Assert(field != null, "We need to use an internal field named IsQuotedDomain that is declared on Cookie.");
558-
s_isQuotedDomainField = field;
556+
FieldInfo? fieldInfo = typeof(Cookie).GetField("IsQuotedDomain", BindingFlags.Instance | BindingFlags.NonPublic);
557+
Debug.Assert(fieldInfo != null, "We need to use an internal field named IsQuotedDomain that is declared on Cookie.");
558+
s_isQuotedDomainField = fieldInfo;
559559
}
560560

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

578578
return s_isQuotedVersionField;

src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/Symbol.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ public bool isStatic
131131
{
132132
get
133133
{
134-
if (this is FieldSymbol field)
134+
if (this is FieldSymbol fieldInfo)
135135
{
136-
return field.isStatic;
136+
return fieldInfo.isStatic;
137137
}
138138

139139
if (this is EventSymbol ev)

src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataMember.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ internal Type MemberType
170170
{
171171
if (_memberType == null)
172172
{
173-
if (MemberInfo is FieldInfo field)
174-
_memberType = field.FieldType;
173+
if (MemberInfo is FieldInfo fieldInfo)
174+
_memberType = fieldInfo.FieldType;
175175
else if (MemberInfo is PropertyInfo prop)
176176
_memberType = prop.PropertyType;
177177
else

src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ internal ConstantModel[] Constants
431431
FieldInfo[] fields = Type.GetFields();
432432
for (int i = 0; i < fields.Length; i++)
433433
{
434-
FieldInfo field = fields[i];
435-
ConstantModel? constant = GetConstantModel(field);
434+
FieldInfo fieldInfo = fields[i];
435+
ConstantModel? constant = GetConstantModel(fieldInfo);
436436
if (constant != null) list.Add(constant);
437437
}
438438
_constants = list.ToArray();

src/libraries/System.Reflection.TypeExtensions/tests/TypeTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,8 @@ public class GenericClassWithVarArgMethod<T>
792792

793793
public T publicField
794794
{
795-
get { return field; }
796-
set { field = value; }
795+
get { return this.field; }
796+
set { this.field = value; }
797797
}
798798

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

816816
public int publicField
817817
{
818-
get { return field; }
819-
set { field = value; }
818+
get { return this.field; }
819+
set { this.field = value; }
820820
}
821821

822822
public int ReturnAndSetField(int newFieldValue, params int[] moreFieldValues)

src/libraries/System.Runtime.Loader/tests/ApplyUpdate/System.Reflection.Metadata.ApplyUpdate.Test.AddLambdaCapturingThis/AddLambdaCapturingThis.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public AddLambdaCapturingThis()
1212
field = "abcd";
1313
}
1414

15-
public string GetField => field;
15+
public string GetField => this.field;
1616

1717
private string field;
1818

src/libraries/System.Runtime.Loader/tests/ApplyUpdate/System.Reflection.Metadata.ApplyUpdate.Test.AddLambdaCapturingThis/AddLambdaCapturingThis_v1.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public AddLambdaCapturingThis()
1212
field = "abcd";
1313
}
1414

15-
public string GetField => field;
15+
public string GetField => this.field;
1616

1717
private string field;
1818

src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTestTypes/DataContract.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,9 @@ public Type MemberType
10571057
{
10581058
get
10591059
{
1060-
FieldInfo field = MemberInfo as FieldInfo;
1061-
if (field != null)
1062-
return field.FieldType;
1060+
FieldInfo fieldInfo = MemberInfo as FieldInfo;
1061+
if (fieldInfo != null)
1062+
return fieldInfo.FieldType;
10631063
return ((PropertyInfo)MemberInfo).PropertyType;
10641064
}
10651065
}

src/libraries/System.Runtime/tests/System.Dynamic.Runtime.Tests/Dynamic.Context/Conformance.dynamic.context.operator.compound.event.+=.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,12 @@ public Dele Field
302302
{
303303
get
304304
{
305-
return field;
305+
return this.field;
306306
}
307307

308308
set
309309
{
310-
field = value;
310+
this.field = value;
311311
}
312312
}
313313

@@ -372,12 +372,12 @@ public Dele Field
372372
{
373373
get
374374
{
375-
return field;
375+
return this.field;
376376
}
377377

378378
set
379379
{
380-
field = value;
380+
this.field = value;
381381
}
382382
}
383383

src/libraries/System.Runtime/tests/System.Dynamic.Runtime.Tests/Dynamic.Context/Conformance.dynamic.context.operator.compound.event.-=.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,12 @@ public Dele Field
776776
{
777777
get
778778
{
779-
return field;
779+
return this.field;
780780
}
781781

782782
set
783783
{
784-
field = value;
784+
this.field = value;
785785
}
786786
}
787787

@@ -864,12 +864,12 @@ public Dele Field
864864
{
865865
get
866866
{
867-
return field;
867+
return this.field;
868868
}
869869

870870
set
871871
{
872-
field = value;
872+
this.field = value;
873873
}
874874
}
875875

@@ -952,12 +952,12 @@ public Dele Field
952952
{
953953
get
954954
{
955-
return field;
955+
return this.field;
956956
}
957957

958958
set
959959
{
960-
field = value;
960+
this.field = value;
961961
}
962962
}
963963

@@ -1041,12 +1041,12 @@ public Dele Field
10411041
{
10421042
get
10431043
{
1044-
return field;
1044+
return this.field;
10451045
}
10461046

10471047
set
10481048
{
1049-
field = value;
1049+
this.field = value;
10501050
}
10511051
}
10521052

src/tools/illink/test/ILLink.Tasks.Tests/Mock.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public MockDriver CreateDriver ()
3737

3838
public static string[] OptimizationNames {
3939
get {
40-
var field = typeof (ILLink).GetField ("_optimizationNames", BindingFlags.NonPublic | BindingFlags.Static);
41-
return (string[]) field.GetValue (null);
40+
var fieldInfo = typeof (ILLink).GetField ("_optimizationNames", BindingFlags.NonPublic | BindingFlags.Static);
41+
return (string[]) fieldInfo.GetValue (null);
4242
}
4343
}
4444

src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/MemberUsedViaReflection.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ static void TestIfElse (bool decision)
139139
private class SimpleType
140140
{
141141
[Kept]
142-
public static int field;
142+
public static int fieldKept;
143143

144144
[Kept]
145145
public int memberKept {
146146
[Kept]
147-
get { return field; }
147+
get { return fieldKept; }
148148
[Kept]
149-
set { field = value; }
149+
set { fieldKept = value; }
150150
}
151151

152152
[Kept]
@@ -508,4 +508,4 @@ public static class PrefixLookupNestedType { }
508508
private static class PrefixLookupPrivateNestedType { }
509509
}
510510
}
511-
}
511+
}

0 commit comments

Comments
 (0)