Skip to content

IDE0031: Use null propagation recommended by linter when taking .NET 7 preview 7 #17769

@adityapatwardhan

Description

@adityapatwardhan

Prerequisites

Steps to reproduce

Multiple places where linter expects us to use ?. instead of null checking. The full list is here:

D:\a\PowerShell\PowerShell\src\System.Management.Automation\utils\RuntimeException.cs(217,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\DscSupport\CimDSCParser.cs(985,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\DscSupport\CimDSCParser.cs(1015,29): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\utils\tracing\EtwActivity.cs(477,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemProvider.cs(4522,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemProvider.cs(4805,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(990,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(992,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(1006,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(1010,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(1012,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(1014,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(1138,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(1140,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(1142,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\FileSystemContentStream.cs(1144,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\AliasProvider.cs(198,21): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\help\UpdateHelpCommand.cs(325,21): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\help\SaveHelpCommand.cs(263,21): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\help\SaveHelpCommand.cs(410,29): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\CoreCommandContext.cs(395,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\CoreCommandContext.cs(779,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\CoreCommandContext.cs(793,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\CoreCommandContext.cs(801,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\CoreCommandContext.cs(815,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\CoreCommandContext.cs(823,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\CoreCommandContext.cs(831,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\namespaces\CoreCommandContext.cs(1157,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\commands\ReceivePSSession.cs(407,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\common\RunspaceConnectionInfo.cs(2726,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\common\RunspaceConnectionInfo.cs(2792,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\common\RunspaceConnectionInfo.cs(2794,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\common\RunspaceConnectionInfo.cs(2796,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\common\RunspaceConnectionInfo.cs(2798,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\common\RunspaceConnectionInfo.cs(2800,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\common\RunspaceConnectionInfo.cs(2802,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\common\RunspaceConnectionInfo.cs(2860,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\client\remoterunspaceinfo.cs(387,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\client\RemoteRunspacePoolInternal.cs(1829,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\client\RemoteRunspacePoolInternal.cs(1839,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\remoting\client\ClientRemotePowerShell.cs(169,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\hostifaces\LocalPipeline.cs(490,21): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\hostifaces\LocalConnection.cs(843,21): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\hostifaces\LocalConnection.cs(853,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\hostifaces\LocalConnection.cs(1275,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\hostifaces\PowerShell.cs(5727,25): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\hostifaces\AsyncResult.cs(181,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\FormatAndOutput\common\OutputManager.cs(95,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\FormatAndOutput\common\OutputManager.cs(103,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\FormatAndOutput\common\FormattingObjectsDeserializer.cs(329,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\FormatAndOutput\common\ComplexWriter.cs(242,17): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\parser\Compiler.cs(6986,13): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
D:\a\PowerShell\PowerShell\src\System.Management.Automation\engine\CommandCompletion\PseudoParameterBinder.cs(1225,25): error IDE0031: Null check can be simplified [D:\a\PowerShell\PowerShell\src\System.Management.Automation\System.Management.Automation.csproj]
Exception: D:\a\PowerShell\PowerShell\tools\buildCommon\startNativeExecution.ps1:40

Expected behavior

Build should not fail

Actual behavior

Build failure with warning

Error details

No response

Environment data

Dev environment

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions