Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c0884ae

Browse files
committed
isnot null
1 parent c0ca9d2 commit c0884ae

File tree

10 files changed

+43
-43
lines changed

10 files changed

+43
-43
lines changed

src/System.Private.CoreLib/shared/System/Type.Helpers.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,47 +270,47 @@ public virtual MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bin
270270
if (m != null)
271271
{
272272
for (i = 0; i < m.Length; i++)
273-
if (!(m[i] is null))
273+
if (m[i] is object)
274274
ret[cnt++] = m[i];
275275
}
276276

277277
// Copy the Constructors
278278
if (c != null)
279279
{
280280
for (i = 0; i < c.Length; i++)
281-
if (!(c[i] is null))
281+
if (c[i] is object)
282282
ret[cnt++] = c[i];
283283
}
284284

285285
// Copy the Fields
286286
if (f != null)
287287
{
288288
for (i = 0; i < f.Length; i++)
289-
if (!(f[i] is null))
289+
if (f[i] is object)
290290
ret[cnt++] = f[i];
291291
}
292292

293293
// Copy the Properties
294294
if (p != null)
295295
{
296296
for (i = 0; i < p.Length; i++)
297-
if (!(p[i] is null))
297+
if (p[i] is object)
298298
ret[cnt++] = p[i];
299299
}
300300

301301
// Copy the Events
302302
if (e != null)
303303
{
304304
for (i = 0; i < e.Length; i++)
305-
if (!(e[i] is null))
305+
if (e[i] is object)
306306
ret[cnt++] = e[i];
307307
}
308308

309309
// Copy the Types
310310
if (t != null)
311311
{
312312
for (i = 0; i < t.Length; i++)
313-
if (t[i] != null)
313+
if (t[i] is object)
314314
ret[cnt++] = t[i];
315315
}
316316

@@ -322,7 +322,7 @@ public virtual bool IsSubclassOf(Type c)
322322
Type p = this;
323323
if (p == c)
324324
return false;
325-
while (p != null)
325+
while (p is object)
326326
{
327327
if (p == c)
328328
return true;
@@ -369,7 +369,7 @@ public virtual bool IsAssignableFrom(Type c)
369369
internal bool ImplementInterface(Type ifaceType)
370370
{
371371
Type t = this;
372-
while (t != null)
372+
while (t is object)
373373
{
374374
Type[] interfaces = t.GetInterfaces();
375375
if (interfaces != null)

src/System.Private.CoreLib/shared/System/Type.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected Type() { }
4242
public virtual bool IsConstructedGenericType { get { throw NotImplemented.ByDesign; } }
4343
public virtual bool IsGenericParameter => false;
4444
public virtual bool IsGenericTypeParameter => IsGenericParameter && DeclaringMethod is null;
45-
public virtual bool IsGenericMethodParameter => IsGenericParameter && !(DeclaringMethod is null);
45+
public virtual bool IsGenericMethodParameter => IsGenericParameter && DeclaringMethod is object;
4646
public virtual bool IsGenericType => false;
4747
public virtual bool IsGenericTypeDefinition => false;
4848

@@ -281,7 +281,7 @@ public static TypeCode GetTypeCode(Type type)
281281
}
282282
protected virtual TypeCode GetTypeCodeImpl()
283283
{
284-
if (this != UnderlyingSystemType && !(UnderlyingSystemType is null))
284+
if (this != UnderlyingSystemType && (UnderlyingSystemType is object))
285285
return Type.GetTypeCode(UnderlyingSystemType);
286286

287287
return TypeCode.Object;

src/System.Private.CoreLib/shared/System/Version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public override bool Equals(object obj)
170170
public bool Equals(Version obj)
171171
{
172172
return object.ReferenceEquals(obj, this) ||
173-
(!(obj is null) &&
173+
((obj is object) &&
174174
_Major == obj._Major &&
175175
_Minor == obj._Minor &&
176176
_Build == obj._Build &&

src/System.Private.CoreLib/src/System/Attribute.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private static Attribute[] InternalGetCustomAttributes(PropertyInfo element, Typ
4141

4242

4343
PropertyInfo baseProp = GetParentDefinition(element, indexParamTypes);
44-
while (!(baseProp is null))
44+
while (baseProp is object)
4545
{
4646
attributes = GetCustomAttributes(baseProp, type, false);
4747
AddAttributesToList(attributeList, attributes, types);
@@ -70,7 +70,7 @@ private static bool InternalIsDefined(PropertyInfo element, Type attributeType,
7070

7171
PropertyInfo baseProp = GetParentDefinition(element, indexParamTypes);
7272

73-
while (!(baseProp is null))
73+
while (baseProp is object)
7474
{
7575
if (baseProp.IsDefined(attributeType, false))
7676
return true;
@@ -97,7 +97,7 @@ private static PropertyInfo GetParentDefinition(PropertyInfo property, Type[] pr
9797
{
9898
rtPropAccessor = rtPropAccessor.GetParentDefinition();
9999

100-
if (!(rtPropAccessor is null))
100+
if (rtPropAccessor is object)
101101
{
102102
// There is a public overload of Type.GetProperty that takes both a BingingFlags enum and a return type.
103103
// However, we cannot use that because it doesn't accept null for "types".
@@ -134,7 +134,7 @@ private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type t
134134
CopyToArrayList(attributeList, attributes, types);
135135

136136
EventInfo baseEvent = GetParentDefinition(element);
137-
while (!(baseEvent is null))
137+
while (baseEvent is object)
138138
{
139139
attributes = GetCustomAttributes(baseEvent, type, false);
140140
AddAttributesToList(attributeList, attributes, types);
@@ -158,7 +158,7 @@ private static EventInfo GetParentDefinition(EventInfo ev)
158158
if (add is RuntimeMethodInfo rtAdd)
159159
{
160160
rtAdd = rtAdd.GetParentDefinition();
161-
if (!(rtAdd is null))
161+
if (rtAdd is object)
162162
return rtAdd.DeclaringType.GetEvent(ev.Name);
163163
}
164164
return null;
@@ -181,7 +181,7 @@ private static bool InternalIsDefined(EventInfo element, Type attributeType, boo
181181

182182
EventInfo baseEvent = GetParentDefinition(element);
183183

184-
while (!(baseEvent is null))
184+
while (baseEvent is object)
185185
{
186186
if (baseEvent.IsDefined(attributeType, false))
187187
return true;

src/System.Private.CoreLib/src/System/Delegate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private MethodInfo InitalizeMethodBase()
242242
// walking won't be we compare using the generic type definition forms instead.
243243
Type currentType = _target.GetType();
244244
Type targetType = declaringType.GetGenericTypeDefinition();
245-
while (!(currentType is null))
245+
while (currentType is object)
246246
{
247247
if (currentType.IsGenericType &&
248248
currentType.GetGenericTypeDefinition() == targetType)

src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, boo
11291129

11301130
method = method.GetParentDefinition();
11311131

1132-
while (!(method is null))
1132+
while (method is object)
11331133
{
11341134
if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType, 0, inherit))
11351135
return true;
@@ -1285,7 +1285,7 @@ internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeTy
12851285
for (var i = 0; i < pcas.Count; i++)
12861286
result.Add(pcas[i]);
12871287

1288-
while (!(method is null))
1288+
while (method is object)
12891289
{
12901290
AddCustomAttributes(ref result, method.GetRuntimeModule(), method.MetadataToken, caType, mustBeInheritable, ref result);
12911291
mustBeInheritable = true;

src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ private int GetMemberRefToken(MethodBase methodInfo, Type[] optionalParameterTyp
456456
parameterTypes,
457457
optionalParameterTypes);
458458

459-
if (!(rtMeth is null))
459+
if (rtMeth is object)
460460
return GetTokenForVarArgMethod(rtMeth, sig);
461461
else
462462
return GetTokenForVarArgMethod(dm, sig);

src/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ internal ParameterInfo[] GetIndexParametersNoCopy()
322322

323323
// First try to get the Get method.
324324
MethodInfo m = GetGetMethod(true);
325-
if (!(m is null))
325+
if (m is object)
326326
{
327327
// There is a Get method so use it.
328328
methParams = m.GetParametersNoCopy();
@@ -333,7 +333,7 @@ internal ParameterInfo[] GetIndexParametersNoCopy()
333333
// If there is no Get method then use the Set method.
334334
m = GetSetMethod(true);
335335

336-
if (!(m is null))
336+
if (m is object)
337337
{
338338
methParams = m.GetParametersNoCopy();
339339
numParams = methParams.Length - 1;

src/System.Private.CoreLib/src/System/RtType.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ private unsafe RuntimeMethodInfo[] PopulateMethods(Filter filter)
691691
}
692692

693693
declaringType = RuntimeTypeHandle.GetBaseType(declaringType);
694-
} while (!(declaringType is null));
694+
} while (declaringType is object);
695695
}
696696

697697
return list.ToArray();
@@ -763,7 +763,7 @@ private unsafe RuntimeFieldInfo[] PopulateFields(Filter filter)
763763
while (RuntimeTypeHandle.IsGenericVariable(declaringType))
764764
declaringType = declaringType.GetBaseType();
765765

766-
while (!(declaringType is null))
766+
while (declaringType is object)
767767
{
768768
PopulateRtFields(filter, declaringType, ref list);
769769

@@ -1112,7 +1112,7 @@ private unsafe RuntimeEventInfo[] PopulateEvents(Filter filter)
11121112
declaringType = declaringType.GetBaseType();
11131113

11141114
// Populate associates off of the class hierarchy
1115-
while (!(declaringType is null))
1115+
while (declaringType is object)
11161116
{
11171117
PopulateEvents(filter, declaringType, csEventInfos, ref list);
11181118
declaringType = RuntimeTypeHandle.GetBaseType(declaringType);
@@ -1216,7 +1216,7 @@ private unsafe RuntimePropertyInfo[] PopulateProperties(Filter filter)
12161216
{
12171217
PopulateProperties(filter, declaringType, csPropertyInfos, usedSlots, ref list);
12181218
declaringType = RuntimeTypeHandle.GetBaseType(declaringType);
1219-
} while (!(declaringType is null));
1219+
} while (declaringType is object);
12201220
}
12211221
else
12221222
{
@@ -1303,7 +1303,7 @@ private unsafe void PopulateProperties(
13031303
associateMethod = propertyInfo.GetSetMethod();
13041304
}
13051305

1306-
if (!(associateMethod is null))
1306+
if (associateMethod is object)
13071307
{
13081308
int slot = RuntimeMethodHandle.GetSlot((RuntimeMethodInfo)associateMethod);
13091309

@@ -1565,7 +1565,7 @@ internal string GetDefaultMemberName()
15651565
{
15661566
CustomAttributeData attr = null;
15671567
Type DefaultMemberAttrType = typeof(DefaultMemberAttribute);
1568-
for (RuntimeType t = m_runtimeType; !(t is null); t = t.GetBaseType())
1568+
for (RuntimeType t = m_runtimeType; t is object; t = t.GetBaseType())
15691569
{
15701570
IList<CustomAttributeData> attrs = CustomAttributeData.GetCustomAttributes(t);
15711571
for (int i = 0; i < attrs.Count; i++)
@@ -1612,7 +1612,7 @@ internal MethodInfo GetGenericMethodInfo(RuntimeMethodHandleInternal genericMeth
16121612
{
16131613
crmi = s_methodInstantiations[rmi];
16141614
}
1615-
if (!(crmi is null))
1615+
if (crmi is object)
16161616
return crmi;
16171617

16181618
if (s_methodInstantiationsLock == null)
@@ -1627,14 +1627,14 @@ internal MethodInfo GetGenericMethodInfo(RuntimeMethodHandleInternal genericMeth
16271627
if (la != null)
16281628
{
16291629
crmi = la.m_methodInstantiations[rmi];
1630-
if (!(crmi is null))
1630+
if (crmi is object)
16311631
return crmi;
16321632
la.m_methodInstantiations[rmi] = rmi;
16331633
}
16341634
else
16351635
{
16361636
crmi = s_methodInstantiations[rmi];
1637-
if (!(crmi is null))
1637+
if (crmi is object)
16381638
return crmi;
16391639
s_methodInstantiations[rmi] = rmi;
16401640
}
@@ -1795,7 +1795,7 @@ internal static unsafe MethodBase GetMethodBase(RuntimeType reflectedType, Runti
17951795

17961796
RuntimeType baseType = reflectedType;
17971797

1798-
while (!(baseType is null))
1798+
while (baseType is object)
17991799
{
18001800
RuntimeType baseDefinition = baseType;
18011801

@@ -2340,7 +2340,7 @@ private static bool FilterApplyMethodBase(
23402340
for (int i = 0; i < parameterInfos.Length; i++)
23412341
{
23422342
// a null argument type implies a null arg which is always a perfect match
2343-
if (!(argumentTypes[i] is null) && !argumentTypes[i].MatchesParameterTypeExactly(parameterInfos[i]))
2343+
if (argumentTypes[i] is object && !argumentTypes[i].MatchesParameterTypeExactly(parameterInfos[i]))
23442344
return false;
23452345
}
23462346
}
@@ -2806,7 +2806,7 @@ protected override PropertyInfo GetPropertyImpl(
28062806
{
28072807
PropertyInfo firstCandidate = candidates[0];
28082808

2809-
if (!(returnType is null) && !returnType.IsEquivalentTo(firstCandidate.PropertyType))
2809+
if (returnType is object && !returnType.IsEquivalentTo(firstCandidate.PropertyType))
28102810
return null;
28112811

28122812
return firstCandidate;
@@ -2847,7 +2847,7 @@ public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
28472847
RuntimeEventInfo eventInfo = cache[i];
28482848
if ((bindingAttr & eventInfo.BindingFlags) == eventInfo.BindingFlags)
28492849
{
2850-
if (!(match is null))
2850+
if (match is object)
28512851
throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException);
28522852

28532853
match = eventInfo;
@@ -2876,7 +2876,7 @@ public override FieldInfo GetField(string name, BindingFlags bindingAttr)
28762876
RuntimeFieldInfo fieldInfo = cache[i];
28772877
if ((bindingAttr & fieldInfo.BindingFlags) == fieldInfo.BindingFlags)
28782878
{
2879-
if (!(match is null))
2879+
if (match is object)
28802880
{
28812881
if (ReferenceEquals(fieldInfo.DeclaringType, match.DeclaringType))
28822882
throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException);
@@ -2923,7 +2923,7 @@ public override Type GetInterface(string fullname, bool ignoreCase)
29232923
RuntimeType iface = cache[i];
29242924
if (FilterApplyType(iface, bindingAttr, name, false, ns))
29252925
{
2926-
if (!(match is null))
2926+
if (match is object)
29272927
throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException);
29282928

29292929
match = iface;
@@ -2953,7 +2953,7 @@ public override Type GetNestedType(string fullname, BindingFlags bindingAttr)
29532953
RuntimeType nestedType = cache[i];
29542954
if (FilterApplyType(nestedType, bindingAttr, name, false, ns))
29552955
{
2956-
if (!(match is null))
2956+
if (match is object)
29572957
throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException);
29582958

29592959
match = nestedType;
@@ -3151,7 +3151,7 @@ public override bool IsSubclassOf(Type type)
31513151

31523152
RuntimeType baseType = GetBaseType();
31533153

3154-
while (!(baseType is null))
3154+
while (baseType is object)
31553155
{
31563156
if (baseType == rtType)
31573157
return true;
@@ -3962,7 +3962,7 @@ public override object InvokeMember(
39623962
selFld = binder.BindToField(bindingFlags, flds, IsGetField ? Empty.Value : providedArgs[0], culture);
39633963
}
39643964

3965-
if (!(selFld is null))
3965+
if (selFld is object)
39663966
{
39673967
// Invocation on a field
39683968
if (selFld.FieldType.IsArray || ReferenceEquals(selFld.FieldType, typeof(Array)))
@@ -4148,7 +4148,7 @@ public override object InvokeMember(
41484148
}
41494149
}
41504150

4151-
if (!(finalist is null))
4151+
if (finalist is object)
41524152
{
41534153
// Invoke
41544154
if (finalists == null &&

src/System.Private.CoreLib/src/System/StartupHookProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private static void CallStartupHook(string assemblyPath)
8989
Debug.Assert(initializeMethod == null);
9090
wrongSignature = true;
9191
}
92-
if (!(initializeMethod is null))
92+
if (initializeMethod is object)
9393
{
9494
// Found one
9595
wrongSignature = true;

0 commit comments

Comments
 (0)