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 — Fix Property and ScriptBlock expressions in EntrySelectedBy tags within custom controls by SeeminglyScience · Pull Request #7913 · PowerShell/PowerShell

Conversation

@SeeminglyScience

@SeeminglyScience Patrick Meinecke (SeeminglyScience) commented Oct 1, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

PR Summary

This change sends the current object to expressions defined in EntrySelectedBy tags within custom controls. Currently attempting to use property expression binding will result in a NullReferenceException, and within a script block expression binding $_/$PSItem will not be set.

Resolves #7847

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • 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: to the beginning of the title and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • User-facing Documentation needed
      • Issue filed - Issue link:
  • Testing - New and feature
    • Not Applicable 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
      • Add [feature] if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

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

All reactions
@SeeminglyScience
Enable expressions in control entry selected by
1c33d76
Send the current object when evaluating `EntrySelectedBy` in a custom control definition
@iSazonov
Ilya (iSazonov) requested review from Steve Lee (SteveL-MSFT) and Dongbo Wang (daxian-dbw) October 2, 2018 07:01
@iSazonov

Ilya (iSazonov) commented Oct 2, 2018

Copy link
Copy Markdown
Collaborator

I think we need tests.

All reactions

Sorry, something went wrong.

Uh oh!

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

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Oct 5, 2018

Copy link
Copy Markdown
Member

Patrick Meinecke (@SeeminglyScience) please add tests to Format-Custom.Tests.ps1. You can look at this as an example.

All reactions

Sorry, something went wrong.

Uh oh!

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

@SeeminglyScience
Added tests
3905128
@SeeminglyScience

Patrick Meinecke (SeeminglyScience) commented Oct 5, 2018

Copy link
Copy Markdown
Contributor Author

Steve Lee (@SteveL-MSFT) Sorry I saw your reply just a few minutes late. I've added tests, though they are in a different area. I'll go ahead and move them there.

All reactions

Sorry, something went wrong.

Uh oh!

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

@SeeminglyScience
Move tests to Format-Custom
928236e
SteveL-MSFT
Steve Lee (SteveL-MSFT) requested changes Oct 5, 2018
View reviewed changes
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Custom.Tests.ps1 Outdated
testing
'@ -replace '\r?\n', [Environment]::NewLine

$ps.Invoke()[0].Trim() | Should -BeExactly $expectedOutput

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 5, 2018

Copy link
Copy Markdown
Member

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.

Why index 0 and trim?

Sorry, something went wrong.

Uh oh!

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

All reactions

@SeeminglyScience Patrick Meinecke (SeeminglyScience) Oct 5, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

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.

Index 0 because I know the collection will only have one item. It's mostly just habit from methods that could exist on the collection as well like ToString, I can remove it.

Trim because white space isn't important to the test, and it saves some white space when declaring the expected output. That's just cosmetic and can also be changed.

Sorry, something went wrong.

Uh oh!

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

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 5, 2018

Copy link
Copy Markdown
Member

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 understand the habit, but prefer to remove the index. With regard to whitespace, I prefer to explicitly check for it as we had regressions previously with regard to whitespace in the output particularly with tables.

Sorry, something went wrong.

Uh oh!

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

SeeminglyScience reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@SeeminglyScience
Remove Trim and add whitespace to expectedOutput
a82a8d7
@iSazonov Ilya (iSazonov) self-assigned this Oct 5, 2018
@iSazonov

Ilya (iSazonov) commented Oct 11, 2018

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT) Please update your review.

All reactions

Sorry, something went wrong.

Uh oh!

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

SteveL-MSFT
Steve Lee (SteveL-MSFT) approved these changes Oct 11, 2018
View reviewed changes

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@iSazonov
Ilya (iSazonov) merged commit 680ad9c into PowerShell:master Oct 11, 2018
@iSazonov

Ilya (iSazonov) commented Oct 11, 2018

Copy link
Copy Markdown
Collaborator

Patrick Meinecke (@SeeminglyScience) Thanks for your contribution!

All reactions

Sorry, something went wrong.

Uh oh!

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

Aditya Patwardhan (adityapatwardhan) pushed a commit to adityapatwardhan/PowerShell that referenced this pull request Apr 9, 2019
@SeeminglyScience @iSazonov
Fix Property and ScriptBlock expressions in EntrySelectedBy tags with…
2f80ab1
…in custom controls (PowerShell#7913)

Send the current object when evaluating `EntrySelectedBy` in a custom control definition
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SeeminglyScience @iSazonov
Fix Property and ScriptBlock expressions in EntrySelectedBy tags with…
3320b0f
…in custom controls (PowerShell#7913)

Send the current object when evaluating `EntrySelectedBy` in a custom control definition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@SteveL-MSFT Steve Lee (SteveL-MSFT) SteveL-MSFT approved these changes
@daxian-dbw Dongbo Wang (daxian-dbw) Awaiting requested review from daxian-dbw

Uh oh!

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

Assignees

@iSazonov Ilya (iSazonov)

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

EntrySelectedBy in CustomControls do not pass on the current object to expressions

Uh oh!

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

3 participants

@SeeminglyScience @iSazonov @SteveL-MSFT
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 01402503 — 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.