GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use static lambda keyword by iSazonov · Pull Request #15154 · PowerShell/PowerShell

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Apr 4, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

PR Summary

Use static lambda keyword where possible to make code readability better.

No functional changes.
No changes in generated IL code (one exclusion - one delegate was converted to static).

PR Context

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
  • Tooling
    • I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
    • OR
    • I have considered the user experience from a tooling perspective and opened an issue in the relevant tool repository. This may include:
      • Impact on PowerShell Editor Services which is used in the PowerShell extension for VSCode
        (which runs in a different PS Host).
        • Issue filed:
      • Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        • Issue filed:
      • Impact on PSScriptAnalyzer (which provides linting & formatting in the editor extensions).
        • Issue filed:
      • Impact on EditorSyntax (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
        • Issue filed:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Ilya (iSazonov) added 6 commits April 4, 2021 20:31
@iSazonov
Step 1
fb50ae2
@iSazonov
Step 2
83106c6
@iSazonov
Step 3
16787a0
@iSazonov
Step 4
c52925a
@iSazonov
Step 5
ced168e
@iSazonov
Step 6
d783022
@iSazonov Ilya (iSazonov) added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Apr 4, 2021
@iSazonov
Ilya (iSazonov) requested review from Steve Lee (SteveL-MSFT), Travis Plunk (TravisEz13), Aditya Patwardhan (adityapatwardhan), Andrew (anmenaga) and Dongbo Wang (daxian-dbw) as code owners April 4, 2021 15:42
@ghost ghost assigned Aditya Patwardhan (adityapatwardhan) Apr 4, 2021
@iSazonov
Ilya (iSazonov) requested review from Rob Holt (rjmholt) and Rain Sallow (/u/ta11ow) (vexx32) April 4, 2021 15:43
vexx32
Rain Sallow (/u/ta11ow) (vexx32) approved these changes Apr 4, 2021
View reviewed changes

@vexx32 Rain Sallow (/u/ta11ow) (vexx32) left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm not super familiar with this feature, but from what I've read of it and what I can see here, this looks like a good change to make. Nice work!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iSazonov

Ilya (iSazonov) commented Apr 5, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

I'm not super familiar with this feature,

In general, Lambda does two allocations - (1) a delegate, (2) an instance of temporary class.
If a lambda uses only parameter arguments in its body Roslyn excludes second allocation (no closure created).
Roslyn already does the optimization for years. Now C# allows to add "static" keyword for such lambdas. This explicitly shows that the lambda does not use "external" variables - this makes a code readability better, also this protects from a regression (if the lambda is on hot path adding "external" variable can raise huge allocations.).

vexx32 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TravisEz13
Travis Plunk (TravisEz13) approved these changes Apr 8, 2021
View reviewed changes
@TravisEz13

Travis Plunk (TravisEz13) commented Apr 8, 2021

Copy link
Copy Markdown
Member

PoshChan-Bot (@PoshChan) Please remind me in 1 day

PoshChan reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PoshChan

PoshChan-Bot (PoshChan) commented Apr 9, 2021

Copy link
Copy Markdown
Collaborator

Travis Plunk (@TravisEz13), this is the reminder you requested 1 day ago

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13

Travis Plunk (TravisEz13) commented Apr 10, 2021

Copy link
Copy Markdown
Member

PoshChan-Bot (@PoshChan) Please remind me in 30 minutes

PoshChan reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PoshChan

PoshChan-Bot (PoshChan) commented Apr 10, 2021

Copy link
Copy Markdown
Collaborator

Travis Plunk (@TravisEz13), this is the reminder you requested 30 minutes ago

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13
Travis Plunk (TravisEz13) merged commit 91e7298 into PowerShell:master Apr 12, 2021
@TravisEz13 Travis Plunk (TravisEz13) assigned Travis Plunk (TravisEz13) and unassigned Aditya Patwardhan (adityapatwardhan) Apr 12, 2021
@TravisEz13 Travis Plunk (TravisEz13) added this to the 7.2.0-preview.5 milestone Apr 12, 2021
@iSazonov
Ilya (iSazonov) deleted the use-static-lambda branch April 13, 2021 04:03
@ghost

Deleted user (ghost) commented Apr 14, 2021

Copy link
Copy Markdown

🎉v7.2.0-preview.5 has been released which incorporates this pull request.:tada:

Handy links:

  • Release Notes
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

xtqqczze
xtqqczze reviewed Apr 15, 2021
View reviewed changes
Comment thread src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
#endregion Process_LoadedAssemblies

var grouping = entries.Values.GroupBy(t => t.Key.Count(c => c == '.')).OrderBy(g => g.Key).ToArray();
var grouping = entries.Values.GroupBy(static t => t.Key.Count(c => c == '.')).OrderBy(static g => g.Key).ToArray();

@xtqqczze xtqqczze Apr 15, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

missed one :p

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@xtqqczze

xtqqczze commented Apr 15, 2021

Copy link
Copy Markdown
Contributor

Ilya (@iSazonov) I wonder whether it would be worth proposing an analyzer for static lambda.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Apr 15, 2021

Copy link
Copy Markdown
Collaborator Author

It is ask for Roslyn repo. (I asked in .Net Runtime without answer.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xtqqczze

xtqqczze commented Apr 15, 2021

Copy link
Copy Markdown
Contributor

It is ask for Roslyn repo. (I asked in .Net Runtime without answer.)

I can't find an existing issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Apr 16, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

It was my comment in an PR. :-)

You could review rules from last version of analyzers - perhaps such rule is there.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xtqqczze

xtqqczze commented Apr 16, 2021

Copy link
Copy Markdown
Contributor

xtqqczze I have submitted a new analyzer proposal: https://github.com/dotnet/roslyn-analyzers/issues/5027.

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Travis Plunk (TravisEz13) added a commit that referenced this pull request Apr 16, 2021
@TravisEz13
Merge tag 'v7.2.0-preview.5'
32543c1
[7.2.0-preview.5] - 2021-04-14

* Breaking Changes

- Make PowerShell Linux deb and RPM packages universal (#15109)
- Enforce AppLocker Deny configuration before Execution Policy Bypass configuration (#15035)
- Disallow mixed dash and slash in command line parameter prefix (#15142) (Thanks @davidBar-On!)

* Experimental Features

- `PSNativeCommandArgumentPassing`: Use `ArgumentList` for native executable invocation (breaking change) (#14692)

* Engine Updates and Fixes

- Add `IArgumentCompleterFactory` for parameterized `ArgumentCompleters` (#12605) (Thanks @powercode!)

* General Cmdlet Updates and Fixes

- Fix SSH remoting connection never finishing with misconfigured endpoint (#15175)
- Respect `TERM` and `NO_COLOR` environment variables for `$PSStyle` rendering (#14969)
- Use `ProgressView.Classic` when Virtual Terminal is not supported (#15048)
- Fix `Get-Counter` issue with `-Computer` parameter (#15166) (Thanks @krishnayalavarthi!)
- Fix redundant iteration while splitting lines (#14851) (Thanks @hez2010!)
- Enhance `Remove-Item -Recurse` to work with OneDrive (#14902) (Thanks @iSazonov!)
- Change minimum depth to 0 for `ConvertTo-Json` (#14830) (Thanks @kvprasoon!)
- Allow `Set-Clipboard` to accept empty string (#14579)
- Turn on and off `DECCKM` to modify keyboard mode for Unix native commands to work correctly (#14943)
- Fall back to `CopyAndDelete()` when `MoveTo()` fails due to an `IOException` (#15077)

* Code Cleanup

<details>

<summary>

<p>We thank the following contributors!</p>
<p>@xtqqczze, @iSazonov, @ZhiZe-ZG</p>

</summary>

<ul>
<li>Update .NET to <code>6.0.0-preview.3</code> (#15221)</li>
<li>Add space before comma to hosting test to fix error reported by <code>SA1001</code> (#15224)</li>
<li>Add <code>SecureStringHelper.FromPlainTextString</code> helper method for efficient secure string creation (#14124) (Thanks @xtqqczze!)</li>
<li>Use static lambda keyword (#15154) (Thanks @iSazonov!)</li>
<li>Remove unnecessary <code>Array</code> -&gt; <code>List</code> -&gt; <code>Array</code> conversion in <code>ProcessBaseCommand.AllProcesses</code> (#15052) (Thanks @xtqqczze!)</li>
<li>Standardize grammar comments in Parser.cs (#15114) (Thanks @ZhiZe-ZG!)</li>
<li>Enable <code>SA1001</code>: Commas should be spaced correctly (#14171) (Thanks @xtqqczze!)</li>
<li>Refactor <code>MultipleServiceCommandBase.AllServices</code> (#15053) (Thanks @xtqqczze!)</li>
</ul>

</details>

* Tools

- Use Unix line endings for shell scripts (#15180) (Thanks @xtqqczze!)

* Tests

- Add the missing tag in Host Utilities tests (#14983)
- Update `copy-props` version in `package.json` (#15124)

* Build and Packaging Improvements

<details>

<summary>

<p>We thank the following contributors!</p>
<p>@JustinGrote</p>

</summary>

<ul>
<li>Fix <code>yarn-lock</code> for <code>copy-props</code> (#15225)</li>
<li>Make package validation regex accept universal Linux packages (#15226)</li>
<li>Bump NJsonSchema from 10.4.0 to 10.4.1 (#15190)</li>
<li>Make MSI and EXE signing always copy to fix daily build (#15191)</li>
<li>Sign internals of EXE package so that it works correctly when signed (#15132)</li>
<li>Bump Microsoft.NET.Test.Sdk from 16.9.1 to 16.9.4 (#15141)</li>
<li>Update daily release tag format to  work with new Microsoft Update work (#15164)</li>
<li>Feature: Add Ubuntu 20.04 Support to install-powershell.sh (#15095) (Thanks @JustinGrote!)</li>
<li>Treat rebuild branches like release branches (#15099)</li>
<li>Update WiX to 3.11.2 (#15097)</li>
<li>Bump NJsonSchema from 10.3.11 to 10.4.0 (#15092)</li>
<li>Allow patching of preview releases (#15074)</li>
<li>Bump Newtonsoft.Json from 12.0.3 to 13.0.1 (#15084, #15085)</li>
<li>Update the <code>minSize</code> build package filter to be explicit (#15055)</li>
<li>Bump NJsonSchema from 10.3.10 to 10.3.11 (#14965)</li>
</ul>

</details>

* Documentation and Help Content

- Merge `7.2.0-preview.4` changes to master (#15056)
- Update `README` and `metadata.json` (#15046)
- Fix broken links for `dotnet` CLI (#14937)

[7.2.0-preview.5]: v7.2.0-preview.4...v7.2.0-preview.5
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@iSazonov
Use static lambda keyword (PowerShell#15154)
0e7f09d
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@TravisEz13
Merge tag 'v7.2.0-preview.5'
1d3b900
[7.2.0-preview.5] - 2021-04-14

* Breaking Changes

- Make PowerShell Linux deb and RPM packages universal (PowerShell#15109)
- Enforce AppLocker Deny configuration before Execution Policy Bypass configuration (PowerShell#15035)
- Disallow mixed dash and slash in command line parameter prefix (PowerShell#15142) (Thanks @davidBar-On!)

* Experimental Features

- `PSNativeCommandArgumentPassing`: Use `ArgumentList` for native executable invocation (breaking change) (PowerShell#14692)

* Engine Updates and Fixes

- Add `IArgumentCompleterFactory` for parameterized `ArgumentCompleters` (PowerShell#12605) (Thanks @powercode!)

* General Cmdlet Updates and Fixes

- Fix SSH remoting connection never finishing with misconfigured endpoint (PowerShell#15175)
- Respect `TERM` and `NO_COLOR` environment variables for `$PSStyle` rendering (PowerShell#14969)
- Use `ProgressView.Classic` when Virtual Terminal is not supported (PowerShell#15048)
- Fix `Get-Counter` issue with `-Computer` parameter (PowerShell#15166) (Thanks @krishnayalavarthi!)
- Fix redundant iteration while splitting lines (PowerShell#14851) (Thanks @hez2010!)
- Enhance `Remove-Item -Recurse` to work with OneDrive (PowerShell#14902) (Thanks @iSazonov!)
- Change minimum depth to 0 for `ConvertTo-Json` (PowerShell#14830) (Thanks @kvprasoon!)
- Allow `Set-Clipboard` to accept empty string (PowerShell#14579)
- Turn on and off `DECCKM` to modify keyboard mode for Unix native commands to work correctly (PowerShell#14943)
- Fall back to `CopyAndDelete()` when `MoveTo()` fails due to an `IOException` (PowerShell#15077)

* Code Cleanup

<details>

<summary>

<p>We thank the following contributors!</p>
<p>@xtqqczze, @iSazonov, @ZhiZe-ZG</p>

</summary>

<ul>
<li>Update .NET to <code>6.0.0-preview.3</code> (PowerShell#15221)</li>
<li>Add space before comma to hosting test to fix error reported by <code>SA1001</code> (PowerShell#15224)</li>
<li>Add <code>SecureStringHelper.FromPlainTextString</code> helper method for efficient secure string creation (PowerShell#14124) (Thanks @xtqqczze!)</li>
<li>Use static lambda keyword (PowerShell#15154) (Thanks @iSazonov!)</li>
<li>Remove unnecessary <code>Array</code> -&gt; <code>List</code> -&gt; <code>Array</code> conversion in <code>ProcessBaseCommand.AllProcesses</code> (PowerShell#15052) (Thanks @xtqqczze!)</li>
<li>Standardize grammar comments in Parser.cs (PowerShell#15114) (Thanks @ZhiZe-ZG!)</li>
<li>Enable <code>SA1001</code>: Commas should be spaced correctly (PowerShell#14171) (Thanks @xtqqczze!)</li>
<li>Refactor <code>MultipleServiceCommandBase.AllServices</code> (PowerShell#15053) (Thanks @xtqqczze!)</li>
</ul>

</details>

* Tools

- Use Unix line endings for shell scripts (PowerShell#15180) (Thanks @xtqqczze!)

* Tests

- Add the missing tag in Host Utilities tests (PowerShell#14983)
- Update `copy-props` version in `package.json` (PowerShell#15124)

* Build and Packaging Improvements

<details>

<summary>

<p>We thank the following contributors!</p>
<p>@JustinGrote</p>

</summary>

<ul>
<li>Fix <code>yarn-lock</code> for <code>copy-props</code> (PowerShell#15225)</li>
<li>Make package validation regex accept universal Linux packages (PowerShell#15226)</li>
<li>Bump NJsonSchema from 10.4.0 to 10.4.1 (PowerShell#15190)</li>
<li>Make MSI and EXE signing always copy to fix daily build (PowerShell#15191)</li>
<li>Sign internals of EXE package so that it works correctly when signed (PowerShell#15132)</li>
<li>Bump Microsoft.NET.Test.Sdk from 16.9.1 to 16.9.4 (PowerShell#15141)</li>
<li>Update daily release tag format to  work with new Microsoft Update work (PowerShell#15164)</li>
<li>Feature: Add Ubuntu 20.04 Support to install-powershell.sh (PowerShell#15095) (Thanks @JustinGrote!)</li>
<li>Treat rebuild branches like release branches (PowerShell#15099)</li>
<li>Update WiX to 3.11.2 (PowerShell#15097)</li>
<li>Bump NJsonSchema from 10.3.11 to 10.4.0 (PowerShell#15092)</li>
<li>Allow patching of preview releases (PowerShell#15074)</li>
<li>Bump Newtonsoft.Json from 12.0.3 to 13.0.1 (PowerShell#15084, PowerShell#15085)</li>
<li>Update the <code>minSize</code> build package filter to be explicit (PowerShell#15055)</li>
<li>Bump NJsonSchema from 10.3.10 to 10.3.11 (PowerShell#14965)</li>
</ul>

</details>

* Documentation and Help Content

- Merge `7.2.0-preview.4` changes to master (PowerShell#15056)
- Update `README` and `metadata.json` (PowerShell#15046)
- Fix broken links for `dotnet` CLI (PowerShell#14937)

[7.2.0-preview.5]: PowerShell/PowerShell@v7.2.0-preview.4...v7.2.0-preview.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@TravisEz13 Travis Plunk (TravisEz13) TravisEz13 approved these changes
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Awaiting requested review from adityapatwardhan adityapatwardhan is a code owner
@anmenaga Andrew (anmenaga) Awaiting requested review from anmenaga
@daxian-dbw Dongbo Wang (daxian-dbw) Awaiting requested review from daxian-dbw daxian-dbw is a code owner
@SteveL-MSFT Steve Lee (SteveL-MSFT) Awaiting requested review from SteveL-MSFT
@rjmholt Rob Holt (rjmholt) Awaiting requested review from rjmholt
+2 more reviewers
@xtqqczze xtqqczze xtqqczze left review comments
@vexx32 Rain Sallow (/u/ta11ow) (vexx32) vexx32 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@TravisEz13 Travis Plunk (TravisEz13)

Labels

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

Projects

None yet

Milestone

7.2.0-preview.5

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@iSazonov @TravisEz13 @PoshChan @xtqqczze @vexx32 @adityapatwardhan
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.