diff --git a/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs b/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs index 42e3822f9162dfba3555abd61e099ad575ecbadc..09fdb6781cc827270b38ed502cc54ae2a6042ab2 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs @@ -3072,7 +3072,7 @@ internal enum AddressKind bool peVerifyCompatEnabled, HashSet stackLocalsOpt) { - Debug.Assert(!(method is null)); + Debug.Assert(method is object); switch (expression.Kind) { @@ -3199,7 +3199,7 @@ internal enum AddressKind bool peVerifyCompatEnabled, HashSet stackLocalsOpt) { - Debug.Assert(!(method is null)); + Debug.Assert(method is object); FieldSymbol field = fieldAccess.FieldSymbol; diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs index 97305ca85509585909bfb87644d0614bd3fabf29..491da31e27195f2f18fdb8b2761c3a82a05bf97b 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs @@ -166,7 +166,7 @@ private BoundAttribute BindAttributeCore(AttributeSyntax node, NamedTypeSymbol a } diagnostics.Add(node, useSiteDiagnostics); - if (!(attributeConstructor is null)) + if (attributeConstructor is object) { ReportDiagnosticsIfObsolete(diagnostics, attributeConstructor, node, hasBaseReceiver: false); diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs index 5bc8e33aab9854f7a044dd90aa611d4e64050c70..fa9fa0205bb1dcd39aa203f156e4026a1728203f 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs @@ -2052,7 +2052,7 @@ private BoundExpression BindRangeExpression(RangeExpressionSyntax node, Diagnost memberOpt = WellKnownMember.System_Range__StartAt; } - if (!(memberOpt is null)) + if (memberOpt is object) { symbolOpt = (MethodSymbol)GetWellKnownTypeMember( Compilation, @@ -7048,7 +7048,7 @@ private BoundExpression ConvertToArrayIndex(BoundExpression index, SyntaxNode no if (result is null) { result = TryImplicitConversionToArrayIndex(index, WellKnownType.System_Range, node, diagnostics); - if (!(result is null)) + if (result is object) { // This member is needed for lowering and should produce an error if not present _ = GetWellKnownTypeMember( @@ -7097,7 +7097,7 @@ private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr, var attemptDiagnostics = DiagnosticBag.GetInstance(); var result = TryImplicitConversionToArrayIndex(expr, type, node, attemptDiagnostics); - if (!(result is null)) + if (result is object) { diagnostics.AddRange(attemptDiagnostics); } @@ -7113,7 +7113,7 @@ private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr, var result = TryImplicitConversionToArrayIndex(expr, type, node, attemptDiagnostics); - if (!(result is null)) + if (result is object) { diagnostics.AddRange(attemptDiagnostics); } diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs index f6056d50f757996b98d524cb5b1e5bdad4d73306..ddf98f7d967ee559cefcc50ead1b64460cbcbe68 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs @@ -689,7 +689,7 @@ private BoundStatement BindDeclarationStatementParts(LocalDeclarationStatementSy /// The of the Dispose method if one is found, otherwise null. internal MethodSymbol TryFindDisposePatternMethod(BoundExpression expr, SyntaxNode syntaxNode, bool hasAwait, DiagnosticBag diagnostics) { - Debug.Assert(!(expr is null)); + Debug.Assert(expr is object); Debug.Assert(!(expr.Type is null)); Debug.Assert(expr.Type.IsRefLikeType || hasAwait); // pattern dispose lookup is only valid on ref structs or asynchronous usings diff --git a/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs b/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs index b21b796ace4954c1dd50aaf38192c64c3f5ca38e..9ff495547cf36faede41f2475f14812ae453b76c 100644 --- a/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs +++ b/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs @@ -868,7 +868,7 @@ private void GetDisposalInfoForEnumerator(ref ForEachEnumeratorInfo.Builder buil var patternDisposeDiags = new DiagnosticBag(); var receiver = new BoundDisposableValuePlaceholder(_syntax, enumeratorType); MethodSymbol disposeMethod = TryFindDisposePatternMethod(receiver, _syntax, isAsync, patternDisposeDiags); - if (!(disposeMethod is null)) + if (disposeMethod is object) { builder.NeedsDisposal = true; builder.DisposeMethod = disposeMethod; diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs index 604ededf399e4eb5ea32ea1a8de87e8bcf260a84..0a279e0ee016ba7fb8dc80ab756c4496339588f1 100644 --- a/src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs +++ b/src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs @@ -62,7 +62,7 @@ internal static class AccessCheck /// internal static bool IsEffectivelyPublicOrInternal(Symbol symbol, out bool isInternal) { - Debug.Assert(!(symbol is null)); + Debug.Assert(symbol is object); switch (symbol.Kind) { @@ -101,7 +101,7 @@ internal static bool IsEffectivelyPublicOrInternal(Symbol symbol, out bool isInt symbol = symbol.ContainingType; } - while (!(symbol is null)); + while (symbol is object); return true; } diff --git a/src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs b/src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs index aa6fb960a5414e334633f55d8ed181527fc2024e..192c616054e3dac3185e8c00c3589862ff9cf0a9 100644 --- a/src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs +++ b/src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs @@ -125,7 +125,7 @@ private TypeSymbol InferResultType(ImmutableArray swit foreach (var @case in switchCases) { var type = @case.Value.Type; - if (!(type is null) && seenTypes.Add(type)) + if (type is object && seenTypes.Add(type)) { typesInOrder.Add(type); } diff --git a/src/Compilers/CSharp/Portable/Binder/UsingStatementBinder.cs b/src/Compilers/CSharp/Portable/Binder/UsingStatementBinder.cs index c4f535ec5999616b1e8d8d869792b7c0d24ba801..90240d56f45ce96ea18b8d4c8f58d29c5dc9e44a 100644 --- a/src/Compilers/CSharp/Portable/Binder/UsingStatementBinder.cs +++ b/src/Compilers/CSharp/Portable/Binder/UsingStatementBinder.cs @@ -189,14 +189,14 @@ bool populateDisposableConversionOrDisposeMethod(bool fromExpression) // If this is a ref struct, or we're in a valid asynchronous using, try binding via pattern. // We won't need to try and bind a second time if it fails, as async dispose can't be pattern based (ref structs are not allowed in async methods) - if (!(type is null) && (type.IsRefLikeType || hasAwait)) + if (type is object && (type.IsRefLikeType || hasAwait)) { BoundExpression receiver = fromExpression ? expressionOpt : new BoundLocal(syntax, declarationsOpt[0].LocalSymbol, null, type) { WasCompilerGenerated = true }; disposeMethodOpt = originalBinder.TryFindDisposePatternMethod(receiver, syntax, hasAwait, diagnostics); - if (!(disposeMethodOpt is null)) + if (disposeMethodOpt is object) { if (hasAwait) { diff --git a/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs b/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs index 99bf12ea18d09f41169046e49938cd56e109e22e..5ead53fa3176ca08bda48d9be076677196bfabc6 100644 --- a/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs +++ b/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs @@ -3326,7 +3326,7 @@ internal bool EmitNullablePublicOnly internal bool ShouldEmitNullableAttributes(Symbol symbol) { - Debug.Assert(!(symbol is null)); + Debug.Assert(symbol is object); Debug.Assert(symbol.IsDefinition); if (symbol.ContainingModule != SourceModule) diff --git a/src/Compilers/CSharp/Portable/Errors/LazyMissingNonNullTypesContextDiagnosticInfo.cs b/src/Compilers/CSharp/Portable/Errors/LazyMissingNonNullTypesContextDiagnosticInfo.cs index 059e4487edf74aad67c7fa542b4a4ccbcb09559a..938e08b12756c56ea25677b696db2c481e74d139 100644 --- a/src/Compilers/CSharp/Portable/Errors/LazyMissingNonNullTypesContextDiagnosticInfo.cs +++ b/src/Compilers/CSharp/Portable/Errors/LazyMissingNonNullTypesContextDiagnosticInfo.cs @@ -36,7 +36,7 @@ private static void GetRawDiagnosticInfos(bool isNullableEnabled, CSharpParseOpt { const MessageID featureId = MessageID.IDS_FeatureNullableReferenceTypes; var info = featureId.GetFeatureAvailabilityDiagnosticInfoOpt(options); - if (!(info is null)) + if (info is object) { infos.Add(info); } diff --git a/src/Compilers/CSharp/Portable/Errors/MessageID.cs b/src/Compilers/CSharp/Portable/Errors/MessageID.cs index ddb7c16d198837c5afacb9bb440e69e797496160..35c2fc64b17df1f15a1695f6578afabe4615d12d 100644 --- a/src/Compilers/CSharp/Portable/Errors/MessageID.cs +++ b/src/Compilers/CSharp/Portable/Errors/MessageID.cs @@ -233,7 +233,7 @@ internal static string RequiredFeature(this MessageID feature) internal static bool CheckFeatureAvailability(this MessageID feature, DiagnosticBag diagnostics, Location errorLocation) { var diag = GetFeatureAvailabilityDiagnosticInfoOpt(feature, (CSharpParseOptions)errorLocation.SourceTree.Options); - if (!(diag is null)) + if (diag is object) { diagnostics.Add(diag, errorLocation); return false; diff --git a/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs b/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs index 10b3ce74de4a225aebd8d01c2c6b94dd17598ec5..47cc455d98eb2edbd7cf9aa1c8f209c478ac352b 100644 --- a/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs +++ b/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs @@ -412,7 +412,7 @@ protected override ImmutableArray Scan(ref bool badRegion) { ParameterSymbol methodThisParameter = MethodThisParameter; EnterParameters(); // assign parameters - if (!(methodThisParameter is null)) + if (methodThisParameter is object) { EnterParameter(methodThisParameter, methodThisParameter.TypeWithAnnotations); } @@ -1869,7 +1869,7 @@ public override BoundNode VisitAnonymousObjectCreationExpression(BoundAnonymousO TrackNullableStateForAssignment(argument, property.TypeWithAnnotations, GetOrCreateSlot(property, receiverSlot), argumentType, MakeSlot(argument)); var currentDeclaration = getDeclaration(node, property, ref currentDeclarationIndex); - if (!(currentDeclaration is null)) + if (currentDeclaration is object) { TakeIncrementalSnapshot(currentDeclaration); SetAnalyzedNullability(currentDeclaration, new VisitResult(argumentType, property.TypeWithAnnotations)); @@ -2509,7 +2509,7 @@ public override BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperato TypeSymbol getLeftResultType(TypeSymbol leftType, TypeSymbol rightType) { - Debug.Assert(!(rightType is null)); + Debug.Assert(rightType is object); // If there was an identity conversion between the two operands (in short, if there // is no implicit conversion on the right operand), then check nullable conversions // in both directions since it's possible the right operand is the better result type. diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UsingStatement.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UsingStatement.cs index 5c2a69a2f84b5896d06477647259c95869b6ab3d..7df51d23c612a9cb152c0b8906959459f62e706e 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UsingStatement.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UsingStatement.cs @@ -424,7 +424,7 @@ private BoundExpression GenerateDisposeCall(SyntaxNode syntax, BoundExpression d { disposeCall = MakeCallWithNoExplicitArgument(syntax, disposedExpression, methodOpt); - if (!(awaitOpt is null)) + if (awaitOpt is object) { // await local.DisposeAsync() _sawAwaitInExceptionHandler = true; diff --git a/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEModuleSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEModuleSymbol.cs index cf1ba82d11a63e40d2310ed1c3e3170896e3515c..201fe1a390348c5b74e2745f86d7b5fbdb8aac20 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEModuleSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEModuleSymbol.cs @@ -711,7 +711,7 @@ internal IEnumerable GetForwardedTypes() internal bool ShouldDecodeNullableAttributes(Symbol symbol) { - Debug.Assert(!(symbol is null)); + Debug.Assert(symbol is object); Debug.Assert(symbol.IsDefinition); Debug.Assert((object)symbol.ContainingModule == this); diff --git a/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs index 6915c6d2e4850ef31a6c4bf97916fc30bb3d47ac..87a57e19554e82d5c96475e16353901fb2d087eb 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs @@ -434,7 +434,7 @@ private NamedTypeSymbol GetDeclaredBaseType(bool skipTransformsIfNecessary) if (ReferenceEquals(_lazyDeclaredBaseType, ErrorTypeSymbol.UnknownResultType)) { var baseType = MakeDeclaredBaseType(); - if (!(baseType is null)) + if (baseType is object) { if (skipTransformsIfNecessary) { diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs index bb453097a9867223523e9a67e63c1bc12a1b4262..a9abe90060a5c45f00ddfd5c90d193b94dabf92e 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs @@ -229,7 +229,7 @@ internal void ComputeReturnType() // Skip some diagnostics when the local function is not associated with a compilation // (specifically, local functions nested in expressions in the EE). - if (!(compilation is null)) + if (compilation is object) { if (this.IsAsync) { diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs index c2e1712cbb1beb7663535566c0dc20fe90a8b4b2..ed90299b7aff7f6c41c986688bd2514dd56b8d4b 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs @@ -3339,7 +3339,7 @@ private void AddAccessorIfAvailable(ArrayBuilder symbols, MethodSymbol a var builder = new MostCommonNullableValueBuilder(); var baseType = BaseTypeNoUseSiteDiagnostics; - if (!(baseType is null)) + if (baseType is object) { builder.AddValue(TypeWithAnnotations.Create(baseType)); } @@ -3366,7 +3366,7 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r var compilation = DeclaringCompilation; NamedTypeSymbol baseType = this.BaseTypeNoUseSiteDiagnostics; - if (!(baseType is null)) + if (baseType is object) { if (baseType.ContainsDynamic()) { @@ -3386,7 +3386,7 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNullableContextAttribute(this, nullableContextValue)); } - if (!(baseType is null)) + if (baseType is object) { AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNullableAttributeIfNecessary(this, nullableContextValue, TypeWithAnnotations.Create(baseType))); } diff --git a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_NullablePublicOnly.cs b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_NullablePublicOnly.cs index 4bfd577502851aa4bc453dab185d25b938e3d9d9..8ca2831abbffcebbd3456cce011c57f4ae11cb85 100644 --- a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_NullablePublicOnly.cs +++ b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_NullablePublicOnly.cs @@ -593,7 +593,7 @@ private static void AssertNullablePublicOnlyAttribute(ModuleSymbol module, bool type = attribute.AttributeClass; } } - if (!(type is null)) + if (type is object) { Assert.Equal(publicDefinition ? Accessibility.Public : Accessibility.Internal, type.DeclaredAccessibility); } diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs index 11a20414de2d22b9cb3ffb75f510af66b06511ce..d0e731bc2b94bf4adca2949d6e9d922fc481d411 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs @@ -37,7 +37,7 @@ private static void RunInThread(Action action) thread.Start(); thread.Join(); - if (!(exception is null)) + if (exception is object) { throw exception; } diff --git a/src/Compilers/Core/Portable/Compilation/Compilation.cs b/src/Compilers/Core/Portable/Compilation/Compilation.cs index 824c43fd08f9ffe16d472e3398bd8f666b6a265b..99c2b28593a5306e575468edd1b112066a9fe694 100644 --- a/src/Compilers/Core/Portable/Compilation/Compilation.cs +++ b/src/Compilers/Core/Portable/Compilation/Compilation.cs @@ -1261,7 +1261,7 @@ public bool HasImplicitConversion(ITypeSymbol fromType, ITypeSymbol toType) checkInCompilationReferences(symbol, nameof(symbol)); checkInCompilationReferences(within, nameof(within)); - if (!(throughType is null)) + if (throughType is object) { checkInCompilationReferences(throughType, nameof(throughType)); } diff --git a/src/Compilers/Core/Portable/Operations/Operation.cs b/src/Compilers/Core/Portable/Operations/Operation.cs index 3a0f65915bce3fd014e789481dbc951ae261d8f5..3ad72d146e8f42a144e29fbb4be368c6d0164270 100644 --- a/src/Compilers/Core/Portable/Operations/Operation.cs +++ b/src/Compilers/Core/Portable/Operations/Operation.cs @@ -181,7 +181,7 @@ protected void SetParentOperation(IOperation parent) [Conditional("DEBUG")] internal static void VerifyParentOperation(IOperation parent, IOperation child) { - if (!(child is null)) + if (child is object) { Debug.Assert((object)child.Parent == parent); } diff --git a/src/Workspaces/Core/Portable/Workspace/Host/SyntaxTreeFactory/AbstractSyntaxTreeFactoryService.AbstractRecoverableSyntaxRoot.cs b/src/Workspaces/Core/Portable/Workspace/Host/SyntaxTreeFactory/AbstractSyntaxTreeFactoryService.AbstractRecoverableSyntaxRoot.cs index 5a6e1b3f92954dc02b9697ca720893b8e658343f..f55ab9d650063bf905d2231410898c6e70d0ec68 100644 --- a/src/Workspaces/Core/Portable/Workspace/Host/SyntaxTreeFactory/AbstractSyntaxTreeFactoryService.AbstractRecoverableSyntaxRoot.cs +++ b/src/Workspaces/Core/Portable/Workspace/Host/SyntaxTreeFactory/AbstractSyntaxTreeFactoryService.AbstractRecoverableSyntaxRoot.cs @@ -32,7 +32,7 @@ internal struct SyntaxTreeInfo int length, ImmutableDictionary diagnosticOptions) { - Debug.Assert(!(diagnosticOptions is null)); + Debug.Assert(diagnosticOptions is object); FilePath = filePath ?? string.Empty; Options = options; @@ -86,7 +86,7 @@ internal SyntaxTreeInfo WithOptionsAndLength(ParseOptions options, int length) internal SyntaxTreeInfo WithDiagnosticOptions(ImmutableDictionary options) { - Debug.Assert(!(options is null)); + Debug.Assert(options is object); return new SyntaxTreeInfo( FilePath, Options,