-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Do not require activity when creating a completed progress record #18474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not require activity when creating a completed progress record #18474
Conversation
|
It doesn't seem possible to fix this with parametersets without making a breaking change. It seems like the only option left is to keep the current parameterset and simply make |
|
I'll queue this up for discussion on Cmdlets WG |
|
This script example seems to work? [cmdletbinding(DefaultParameterSetName='two')]
param(
[parameter(ParameterSetName='one', mandatory=$true)]
[parameter(ParameterSetName='two', mandatory=$false)]
[string]$activity,
[parameter(ParameterSetName='two')]
[switch]$completed
)
$activity
$completed |
|
That's not an accurate example though. This example is more accurate: but by making parameter set "two" the default set and the "completed" switch optional we allow people to call it without any parameters at all: |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
@PowerShell/wg-powershell-cmdlets reviewed this. We agreed to make |
…and set a default value instead.
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteProgressCmdlet.cs
Outdated
Show resolved
Hide resolved
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteProgressCmdlet.cs
Outdated
Show resolved
Hide resolved
|
The Cmdlet working group has reviewed this and we recognize the benefit of the requested behavior, and we have seen other scenarios where omitting activity and status is useful. |
I don't understand where you want this check. I can't find |
|
@MartinGC94 you are correct, when we discussed this in the WG, I had forgotten about the remoting scenario. Let me bring it up to the WG one more time. Sorry about this. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
The WG hasn't changed our mind about our earlier opinion, but we believe that the serialization of the progress record could be altered so it ensures that a space would be provided during the serialization process instead of changing the default value of the parameter. It looks like this could be done around line 486 in System.Management.Automation/engine/ProgressRecord.cs. |
|
I've applied the WG suggestions with a slight modification: I added the runtime check to ProcessRecord instead of the setter for Activity because parameters can be bound in any order so we can't know for certain if the |
SteveL-MSFT
left a comment
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.
Sorry for the back-and-forth on this, but we wanted to make sure we have the right long term design as well as addressing the app-compat issue. This looks good to me. Thanks!
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteProgressCmdlet.cs
Show resolved
Hide resolved
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
JamesWTruher
left a comment
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
|
🎉 Handy links: |
PR Summary
Fixes #15252
Allows you to complete progress records with
Write-Progresswithout specifying an activity.This is done by using a predefined string in the activity for
Completerecords because the API expects a non-empty string and updating the API would cause issues in remoting scenarios with a different PowerShell host.PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.Write-Progressthat theActivityparameter is optional MicrosoftDocs/PowerShell-Docs#9864(which runs in a different PS Host).