Skip to content
Closed
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 @@ -793,21 +793,21 @@ internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr
fieldHandle = default;

object handle = m_scope[token] ?? throw new InvalidProgramException();
if (handle is RuntimeTypeHandle)
if (handle is RuntimeTypeHandle runtimeTypeHandle)
{
typeHandle = ((RuntimeTypeHandle)handle).Value;
typeHandle = runtimeTypeHandle.Value;
return;
}

if (handle is RuntimeMethodHandle)
if (handle is RuntimeMethodHandle runtimeMethodHandle)
{
methodHandle = ((RuntimeMethodHandle)handle).Value;
methodHandle = runtimeMethodHandle.Value;
return;
}

if (handle is RuntimeFieldHandle)
if (handle is RuntimeFieldHandle runtimeFieldHandle)
{
fieldHandle = ((RuntimeFieldHandle)handle).Value;
fieldHandle = runtimeFieldHandle.Value;
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ private void AddOneArgTypeHelperWorker(Type clsArgument, bool lastWasGenericInst
{
CorElementType type = CorElementType.ELEMENT_TYPE_MAX;

if (clsArgument is RuntimeType)
if (clsArgument is RuntimeType runtimeType)
{
type = ((RuntimeType)clsArgument).GetCorElementType();
type = runtimeType.GetCorElementType();

// GetCorElementType returns CorElementType.ELEMENT_TYPE_CLASS for both object and string
if (type == CorElementType.ELEMENT_TYPE_CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ public static unsafe int QueryContextAttributes(SafeDeleteContext phContext, Int

if (status == 0 && refHandle != null)
{
if (refHandle is SafeFreeContextBuffer)
if (refHandle is SafeFreeContextBuffer safeFreeContextBuffer)
{
((SafeFreeContextBuffer)refHandle).Set(*(IntPtr*)buffer);
safeFreeContextBuffer.Set(*(IntPtr*)buffer);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override void CopyFrom(AsnEncodedData asnEncodedData)
{
ArgumentNullException.ThrowIfNull(asnEncodedData);

if (!(asnEncodedData is Pkcs9AttributeObject))
if (asnEncodedData is not Pkcs9AttributeObject)
throw new ArgumentException(SR.Cryptography_Pkcs9_AttributeMismatch);

base.CopyFrom(asnEncodedData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ internal static unsafe void PadOaep(
destination[0] = 0;
}
}
catch (Exception e) when (!(e is CryptographicException))
catch (Exception e) when (e is not CryptographicException)
{
Debug.Fail("Bad exception produced from OAEP padding: " + e);
throw new CryptographicException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ private static ExprMemberGroup CreateMemberGroupExpr(
ExprMemberGroup memgroup = ExprFactory.CreateMemGroup( // Tree
flags, name, typeArgumentsAsTypeArray, kind, callingType, null,
new CMemberLookupResults(TypeArray.Allocate(callingTypes.ToArray()), name));
if (!(callingObject is ExprClass))
if (callingObject is not ExprClass)
{
memgroup.OptionalObject = callingObject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static bool IsGenericallyEqual(this Type t1, Type t2)
// i.e if the inputs are (T, int, C<T>, C<int>) then this will return true.
private static bool IsGenericallyEquivalentTo(this Type t1, Type t2, MemberInfo member1, MemberInfo member2)
{
Debug.Assert(!(member1 is MethodBase) ||
Debug.Assert(member1 is not MethodBase ||
!((MethodBase)member1).IsGenericMethod ||
(((MethodBase)member1).IsGenericMethodDefinition && ((MethodBase)member2).IsGenericMethodDefinition));

Expand Down Expand Up @@ -226,12 +226,12 @@ private static bool IsTypeParameterEquivalentToTypeInst(this Type typeParam, Typ
{
// The type param is from a generic method. Since only methods can be generic, anything else
// here means they are not equivalent.
if (!(member is MethodBase))
if (member is not MethodBase methodBase)
{
return false;
}

MethodBase method = (MethodBase)member;
MethodBase method = methodBase;
int position = typeParam.GenericParameterPosition;
Type[] args = method.IsGenericMethod ? method.GetGenericArguments() : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private static TypeArray RearrangeNamedArguments(TypeArray pta, MethPropWithInst
// If we've no args we can skip. If the last argument isn't named then either we
// have no named arguments, and we can skip, or we have non-trailing named arguments
// and we MUST skip!
if (args.carg == 0 || !(args.prgexpr[args.carg - 1] is ExprNamedArgumentSpecification))
if (args.carg == 0 || args.prgexpr[args.carg - 1] is not ExprNamedArgumentSpecification)
{
return pta;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private bool canConvert(Expr expr, CType dest, CONVERTTYPE flags) =>
[RequiresDynamicCode(Binder.DynamicCodeWarning)]
private Expr mustConvertCore(Expr expr, CType dest, CONVERTTYPE flags)
{
Debug.Assert(!(expr is ExprMemberGroup));
Debug.Assert(expr is not ExprMemberGroup);

if (BindImplicitConversion(expr, expr.Type, dest, out Expr exprResult, flags))
{
Expand Down Expand Up @@ -453,7 +453,7 @@ private Expr tryConvert(Expr expr, CType dest, CONVERTTYPE flags)
[RequiresDynamicCode(Binder.DynamicCodeWarning)]
private Expr mustCastCore(Expr expr, CType dest, CONVERTTYPE flags)
{
Debug.Assert(!(expr is ExprMemberGroup));
Debug.Assert(expr is not ExprMemberGroup);
Debug.Assert(dest != null);

CSemanticChecker.CheckForStaticClass(dest);
Expand Down Expand Up @@ -1014,7 +1014,7 @@ private bool bindUserDefinedConversion(Expr exprSrc, CType typeSrc, CType typeDs
Expr exprDst;
Expr pTransformedArgument = exprSrc;

if (ctypeLiftBest > 0 && !(typeFrom is NullableType) && fDstHasNull)
if (ctypeLiftBest > 0 && typeFrom is not NullableType && fDstHasNull)
{
// Create the memgroup.
ExprMemberGroup pMemGroup = ExprFactory.CreateMemGroup(null, mwiBest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static bool FExpRefConv(CType typeSrc, CType typeDst)
CType typeArr = arrayDest.ElementType;
CType typeLst = aggtypeSrc.TypeArgsAll[0];

Debug.Assert(!(typeArr is MethodGroupType));
Debug.Assert(typeArr is not MethodGroupType);
return typeArr == typeLst || FExpRefConv(typeArr, typeLst);
}
if (HasGenericDelegateExplicitReferenceConversion(typeSrc, typeDst))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private bool bindExplicitConversionFromIListToArray(ArrayType arrayDest)
CType typeArr = arrayDest.ElementType;
CType typeLst = aggSrc.TypeArgsAll[0];

Debug.Assert(!(typeArr is MethodGroupType));
Debug.Assert(typeArr is not MethodGroupType);
if (typeArr != typeLst && !CConversions.FExpRefConv(typeArr, typeLst))
{
return false;
Expand Down Expand Up @@ -723,7 +723,7 @@ private AggCastResult bindExplicitConversionFromPointerToInt(AggregateType aggTy
//
// * From any pointer-type to sbyte, byte, short, ushort, int, uint, long, or ulong.

if (!(_typeSrc is PointerType) || aggTypeDest.FundamentalType > FUNDTYPE.FT_LASTINTEGRAL || !aggTypeDest.IsNumericType)
if (_typeSrc is not PointerType || aggTypeDest.FundamentalType > FUNDTYPE.FT_LASTINTEGRAL || !aggTypeDest.IsNumericType)
{
return AggCastResult.Failure;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,15 +665,15 @@ internal Expr bindUDUnop(ExpressionKind ek, Expr arg)
private ExprCall BindLiftedUDUnop(Expr arg, CType typeArg, MethPropWithInst mpwi)
{
CType typeRaw = typeArg.StripNubs();
if (!(arg.Type is NullableType) || !canConvert(arg.Type.StripNubs(), typeRaw, CONVERTTYPE.NOUDC))
if (arg.Type is not NullableType || !canConvert(arg.Type.StripNubs(), typeRaw, CONVERTTYPE.NOUDC))
{
// Convert then lift.
arg = mustConvert(arg, typeArg);
}
Debug.Assert(arg.Type is NullableType);

CType typeRet = TypeManager.SubstType(mpwi.Meth().RetType, mpwi.GetType());
if (!(typeRet is NullableType))
if (typeRet is not NullableType)
{
typeRet = TypeManager.GetNullable(typeRet);
}
Expand Down Expand Up @@ -792,7 +792,7 @@ private static NamedArgumentsKind FindNamedArgumentsType(Expr args)
list = null;
}

if (!(arg is ExprNamedArgumentSpecification))
if (arg is not ExprNamedArgumentSpecification)
{
return NamedArgumentsKind.NonTrailing;
}
Expand Down Expand Up @@ -882,8 +882,8 @@ private void CheckLvalue(Expr expr, CheckLvalueKind kind)
return;
}

Debug.Assert(!(expr is ExprLocal));
Debug.Assert(!(expr is ExprMemberGroup));
Debug.Assert(expr is not ExprLocal);
Debug.Assert(expr is not ExprMemberGroup);

switch (expr.Kind)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ internal static bool ReOrderArgsForNamedArguments(

// Positional.
if (index < pArguments.carg &&
!(pArguments.prgexpr[index] is ExprNamedArgumentSpecification) &&
pArguments.prgexpr[index] is not ExprNamedArgumentSpecification &&
!(pArguments.prgexpr[index] is ExprArrayInit arrayInitPos && arrayInitPos.GeneratedForParamArray))
{
pExprArguments[index] = pArguments.prgexpr[index++];
Expand Down Expand Up @@ -1222,7 +1222,7 @@ private RuntimeBinderException ReportErrorsOnFailure()

if (0 != (_pGroup.Flags & EXPRFLAG.EXF_CTOR))
{
Debug.Assert(!(_pGroup.ParentType is TypeParameterType));
Debug.Assert(_pGroup.ParentType is not TypeParameterType);
return ErrorHandling.Error(ErrorCode.ERR_BadCtorArgCount, _pGroup.ParentType, _pArguments.carg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public bool Bind()
{
case TypeKind.TK_NullType:
// Can only convert to the null type if src is null.
if (!(_typeSrc is NullType))
if (_typeSrc is not NullType)
{
return false;
}
Expand Down Expand Up @@ -581,7 +581,7 @@ private bool bindImplicitConversionToBase(AggregateType pSource)
// * From any delegate-type to System.Delegate.
// * From any delegate-type to System.ICloneable.

if (!(_typeDest is AggregateType) || !SymbolLoader.HasBaseConversion(pSource, _typeDest))
if (_typeDest is not AggregateType || !SymbolLoader.HasBaseConversion(pSource, _typeDest))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private bool SearchSingleType(AggregateType typeCur, out bool pfHideByName)
symCur != null;
symCur = symCur.LookupNext(symbmask_t.MASK_Member))
{
Debug.Assert(!(symCur is AggregateSymbol));
Debug.Assert(symCur is not AggregateSymbol);
// Check for arity.
// For non-zero arity, only methods of the correct arity are considered.
// For zero arity, don't filter out any methods since we do type argument
Expand Down Expand Up @@ -176,7 +176,7 @@ private bool SearchSingleType(AggregateType typeCur, out bool pfHideByName)
// Make sure that whether we're seeing a ctor, operator, or indexer is consistent with the flags.
if (((_flags & MemLookFlags.Ctor) == 0) != (meth == null || !meth.IsConstructor()) ||
((_flags & MemLookFlags.Operator) == 0) != (meth == null || !meth.isOperator) ||
((_flags & MemLookFlags.Indexer) == 0) != !(prop is IndexerSymbol))
((_flags & MemLookFlags.Indexer) == 0) != (prop is not IndexerSymbol))
{
if (!_swtBad)
{
Expand All @@ -188,7 +188,7 @@ private bool SearchSingleType(AggregateType typeCur, out bool pfHideByName)
// We can't call CheckBogus on methods or indexers because if the method has the wrong
// number of parameters people don't think they should have to /r the assemblies containing
// the parameter types and they complain about the resulting CS0012 errors.
if (!(symCur is MethodSymbol) && (_flags & MemLookFlags.Indexer) == 0 && CSemanticChecker.CheckBogus(symCur))
if (symCur is not MethodSymbol && (_flags & MemLookFlags.Indexer) == 0 && CSemanticChecker.CheckBogus(symCur))
{
// A bogus member - we can't use these, so only record them for error reporting.
if (!_swtBogus)
Expand Down Expand Up @@ -267,7 +267,7 @@ private bool SearchSingleType(AggregateType typeCur, out bool pfHideByName)
else if (!_fMulti)
{
// Give method groups priority.
if (!(symCur is MethodSymbol))
if (symCur is not MethodSymbol)
goto LAmbig;
// Erase previous results so we'll record this method as the first.
_prgtype = new List<AggregateType>();
Expand All @@ -280,7 +280,7 @@ private bool SearchSingleType(AggregateType typeCur, out bool pfHideByName)
if (!typeCur.DiffHidden)
{
// Give method groups priority.
if (!(_swtFirst.Sym is MethodSymbol))
if (_swtFirst.Sym is not MethodSymbol)
goto LAmbig;
}
// This one is hidden by another. This one also hides any more in base types.
Expand Down Expand Up @@ -644,7 +644,7 @@ public Exception ReportErrors()
if (_swtBadArity)
{
Debug.Assert(_arity != 0);
Debug.Assert(!(_swtBadArity.Sym is AggregateSymbol));
Debug.Assert(_swtBadArity.Sym is not AggregateSymbol);
if (_swtBadArity.Sym is MethodSymbol badMeth)
{
int cvar = badMeth.typeVars.Count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public bool CanUseCurrentSymbol
if (_mask == symbmask_t.MASK_MethodSymbol && (
0 == (_flags & EXPRFLAG.EXF_CTOR) != !((MethodSymbol)CurrentSymbol).IsConstructor() ||
0 == (_flags & EXPRFLAG.EXF_OPERATOR) != !((MethodSymbol)CurrentSymbol).isOperator) ||
_mask == symbmask_t.MASK_PropertySymbol && !(CurrentSymbol is IndexerSymbol))
_mask == symbmask_t.MASK_PropertySymbol && CurrentSymbol is not IndexerSymbol)
{
// Get the next symbol.
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private bool InferTypeArgs()
////////////////////////////////////////////////////////////////////////////////

private static bool IsReallyAType(CType pType) =>
!(pType is NullType) && !(pType is VoidType) && !(pType is MethodGroupType);
pType is not NullType && pType is not VoidType && pType is not MethodGroupType;

////////////////////////////////////////////////////////////////////////////////
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static Expr StripNullableConstructor(Expr pExpr)
while (IsNullableConstructor(pExpr, out ExprCall call))
{
pExpr = call.OptionalArguments;
Debug.Assert(pExpr != null && !(pExpr is ExprList));
Debug.Assert(pExpr != null && pExpr is not ExprList);
}

return pExpr;
Expand All @@ -45,7 +45,7 @@ private static Expr BindNubValue(Expr exprSrc)
if (IsNullableConstructor(exprSrc, out ExprCall call))
{
Expr args = call.OptionalArguments;
Debug.Assert(args != null && !(args is ExprList));
Debug.Assert(args != null && args is not ExprList);
return args;
}

Expand Down
Loading
Loading