Skip to content

Allow 'name' as an alias key for 'label' in ConvertTo-Html, allow the 'width' entry to be an integer - #8426

Merged
Aditya Patwardhan (adityapatwardhan) merged 13 commits into
PowerShell:masterfrom
mklement0:convertto-html-fix
Jan 18, 2019
Merged

Allow 'name' as an alias key for 'label' in ConvertTo-Html, allow the 'width' entry to be an integer#8426
Aditya Patwardhan (adityapatwardhan) merged 13 commits into
PowerShell:masterfrom
mklement0:convertto-html-fix

Conversation

@mklement0

Copy link
Copy Markdown
Contributor

PR Summary

Fixes #6994, and additionally allows key width to be specified not just as a [string] (as before), but alternatively as an [int], analogous to the use of width with Format-Table.

PR Checklist

- Allows use of 'name' as an alias for 'label' in calculated properties
- Allows specifying a 'width' value as an integer as well as a string
@mklement0 Michael Klement (mklement0) changed the title Allow 'name' as an alias key for 'label' in ConvertTo-Html, allow the 'width' value to be an integer Allow 'name' as an alias key for 'label' in ConvertTo-Html, allow the 'width' entry to be an integer Dec 8, 2018

// Accept the width both as a string and as an int.
string width;
int? widthNum = p.GetEntry(ConvertHTMLParameterDefinitionKeys.WidthEntryKey) as int?;

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.

Why not:

Suggested change
int? widthNum = p.GetEntry(ConvertHTMLParameterDefinitionKeys.WidthEntryKey) as int?;
var widthEntryKey = p.GetEntry(ConvertHTMLParameterDefinitionKeys.WidthEntryKey);
if (widthEntryKey is int widthNum)
{
width = widthNum.Value.ToString();
}
else
{
width = widthEntryKey as string;
}

$returnString | Should -Match 'AgeRenamed'
}

It "Test ConvertTo-HTML calculated property supports integer 'width' entry" {

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.

Only integer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ilya (@iSazonov): Good question: int is the type of the Alignment entry for Format-Table, and I simply amended that class to also be able to use it with ConvertTo-Html, with a string-typed width entry.

Since we're talking about UIs and column widths, my guess is that [int] is enough, but I'm not wedded to that, and if someone knows that a wider type is called for, I'm all ears.

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Dec 8, 2018

@iSazonov Ilya (iSazonov) left a comment

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.

LGTM

@stale

stale Bot commented Jan 8, 2019

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days.
Thank you for your contributions.
Community members are welcome to grab these works.

@stale stale Bot added the Stale label Jan 8, 2019
@mklement0

Copy link
Copy Markdown
Contributor Author

Steve Lee (@SteveL-MSFT), what will it take to get this merged? Another review, or just an act of merging by someone who's authorized?

I fear that the related #8427 and #8430 are about to go stale too.

@anmenaga Andrew (anmenaga) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Michael Klement (@mklement0) 'Codacy/PR Quality Review' needs a minor style update; otherwise this looks fine.

@mklement0

Copy link
Copy Markdown
Contributor Author

Thanks, Andrew (@anmenaga).

I've resolved the code-style issues.

Unfortunately, I haven't been able to resolve the merge conflict, and I'm at a loss as to how to do so.
I've copied the changes that have since been added to the master branch to my branch, yet a conflict is still reported (I've later added a small whitespace fix).

Can you help?

@iSazonov

Ilya (iSazonov) commented Jan 18, 2019

Copy link
Copy Markdown
Collaborator

Michael Klement (@mklement0) Please remove/reset last commits (merge resolve) - I'm afraid that you could break something. Then you could use "Resolve conflicts" button in GitHub or ping me for help.

# Reset to commit "ooooooo"
git reset --hard ooooooo  
# Remove last commit
git reset --hard HEAD~1

@vexx32

Rain Sallow (/u/ta11ow) (vexx32) commented Jan 18, 2019

Copy link
Copy Markdown
Collaborator

Michael Klement (@mklement0) Did you make a merge commit or just copy the changes across?

If the latter, make sure your master branch is up to date, change to this branch, and then git merge master. Resolve conflicts in your editor and make the final merge commit, then push the changes. That will usually resolve the conflict.

Also note that if you need to reset back from some commits, as Ilya mentions you may want to do, you will need a force-push to remove them from the remote once you're done.

@mklement0

Copy link
Copy Markdown
Contributor Author

I appreciate your help, Rain Sallow (/u/ta11ow) (@vexx32) and Ilya (@iSazonov).

Indeed I hadn't merged locally and had just tried to copy the changes manually.
(Merging on GitHub wasn't possible.)

I've now merged locally and pushed again, which resolves the conflict.

Do I still need to reset something?
Seems like you could now simply squash-merge.
Ilya (@iSazonov), what could break?

@iSazonov

Copy link
Copy Markdown
Collaborator

After resolving merge conflicts we have to review again.

@iSazonov

Copy link
Copy Markdown
Collaborator

Aditya Patwardhan (@adityapatwardhan) The PR is ready to merge.

@mklement0

Michael Klement (mklement0) commented Jan 18, 2019

Copy link
Copy Markdown
Contributor Author

Thanks, Ilya (@iSazonov).

Just so I get it right in the future, the procedure should be:

  • Use GitHub's own merging feature if available (it wasn't in this case).

  • Otherwise, merge locally first from an up-to-date master branch, then push, as per Rain Sallow (/u/ta11ow) (@vexx32)'s instructions.

Correct?

@iSazonov

Copy link
Copy Markdown
Collaborator

Michael Klement (@mklement0) Currently GitHub "resolve merge conflicts" feature works very well and can be used for fast resolving simple conflicts. Large and complex conflicts we have to do locally. I guess there is many ways to do this in git. You can use a way you prefer. Usually I use git pull --rebase PowerShell master then follow git hints.

@adityapatwardhan

Copy link
Copy Markdown
Member

Michael Klement (@mklement0) Could you answer Ilya (@iSazonov) suggestion?

@mklement0

Copy link
Copy Markdown
Contributor Author

Aditya Patwardhan (@adityapatwardhan):

Ilya (@iSazonov) was responding how to handle this situation in the future - duly noted by me (and acknowledged with a thumbs-up).

Is there something left to resolve for this PR?
My (superficial) understanding is that the way I've eventually resolved the merge conflict should now allow for squash-merging.

@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) merged commit 20919ee into PowerShell:master Jan 18, 2019
@adityapatwardhan

Copy link
Copy Markdown
Member

Michael Klement (@mklement0) Thanks for your contribution!

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calculated properties passed to ConvertTo-Html do not support the "n" / "name" key

5 participants