Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use null propagation operator for windows build#17795

Merged
PaulHigin merged 7 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
fflaten:fix-nullprop-winfflaten/PowerShell:fix-nullprop-winCopy head branch name to clipboard
Jul 29, 2022
Merged

Use null propagation operator for windows build#17795
PaulHigin merged 7 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
fflaten:fix-nullprop-winfflaten/PowerShell:fix-nullprop-winCopy head branch name to clipboard

Conversation

@fflaten

@fflaten fflaten commented Jul 28, 2022

Copy link
Copy Markdown
Contributor

PR Summary

Replace if not null-checks with null propagation operator to solve IDE0031 with .NET Preview 7.
Additional findings when compiled against win7-x64 (in devcontainer).

PR Context

Related to #17769

PR Checklist

@fflaten

fflaten commented Jul 28, 2022

Copy link
Copy Markdown
Contributor Author

Don't have a Windows-machine to build on atm. but hopefully I caught most of them.

@iSazonov Any tips regarding 31408eb ?
When building in devcontainer with -Runtime win7-x64 and changing them to securityDescHandle?.Value.Free(); it failed with:

/workspaces/PowerShell/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs(2850,32): error CS1061: 'GCHandle' does not contain a definition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'GCHandle' could be found (are you missing a using directive or an assembly reference?) [/workspaces/PowerShell/src/System.Management.Automation/System.Management.Automation.csproj]
/workspaces/PowerShell/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs(507,32): error CS1061: 'GCHandle' does not contain a definition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'GCHandle' could be found (are you missing a using directive or an assembly reference?) [/workspaces/PowerShell/src/System.Management.Automation/System.Management.Automation.csproj]

Update: Never mind. ?. removes nullable from the type.

Comment thread src/Microsoft.WSMan.Management/WsManHelper.cs Outdated
Comment thread src/Microsoft.WSMan.Management/WsManHelper.cs Outdated
@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Jul 28, 2022
Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Outdated
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Jul 28, 2022

@PaulHigin PaulHigin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

{
securityDescHandle.Value.Free();
}
securityDescHandle?.Free();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It generates more efficient code. I wonder but it is great!
Compere:
before
after

@PaulHigin PaulHigin merged commit 5f4e100 into PowerShell:master Jul 29, 2022
@fflaten fflaten deleted the fix-nullprop-win branch July 29, 2022 17:54
@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Jul 31, 2022
@fflaten fflaten mentioned this pull request Aug 1, 2022
22 tasks
@ghost

ghost commented Aug 11, 2022

Copy link
Copy Markdown

🎉v7.3.0-preview.7 has been released which incorporates this pull request.:tada:

Handy links:

@TravisEz13 TravisEz13 mentioned this pull request Sep 30, 2022
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.