Skip to content

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

Merged
adityapatwardhan merged 13 commits intoPowerShell: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
adityapatwardhan merged 13 commits intoPowerShell:masterfrom
mklement0:convertto-html-fix

Conversation

@mklement0
Copy link
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 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
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
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
Contributor Author

Choose a reason for hiding this comment

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

@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 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 iSazonov requested a review from markekraus December 8, 2018 10:36
Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

LGTM

@stale
Copy link

stale bot commented Jan 8, 2019

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
Contributor Author

@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.

@iSazonov iSazonov requested a review from SteveL-MSFT January 8, 2019 10:13
@stale stale bot removed the Stale label Jan 8, 2019
Copy link

@anmenaga anmenaga left a comment

Choose a reason for hiding this comment

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

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

@mklement0
Copy link
Contributor Author

Thanks, @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
Copy link
Collaborator

iSazonov commented Jan 18, 2019

@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
Copy link
Collaborator

vexx32 commented Jan 18, 2019

@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
Contributor Author

I appreciate your help, @vexx32 and @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.
@iSazonov, what could break?

@iSazonov
Copy link
Collaborator

After resolving merge conflicts we have to review again.

@iSazonov
Copy link
Collaborator

@adityapatwardhan The PR is ready to merge.

@mklement0
Copy link
Contributor Author

mklement0 commented Jan 18, 2019

Thanks, @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 @vexx32's instructions.

Correct?

@iSazonov
Copy link
Collaborator

@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
Member

@mklement0 Could you answer @iSazonov suggestion?

@mklement0
Copy link
Contributor Author

@adityapatwardhan:

@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 adityapatwardhan merged commit 20919ee into PowerShell:master Jan 18, 2019
@adityapatwardhan
Copy link
Member

@mklement0 Thanks for your contribution!

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

Comments