-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Cleanup uses of CommandTypes.Workflow and WorkflowInfo
#6708
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
Conversation
| MamlPossibleValueControl, | ||
| MamlTrueFalseShortControl, | ||
| MamlIndentedSyntaxControl, | ||
| CommonWorkflowParametersControl, |
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.
This entry is with the index 16 in the array sharedControls, so for an index that is greater than 16, we need to adjust it by subtracting 1. This is why you will see many index changes below.
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.
You could leave null in this entry.
In another PR - you could introduce names for each shared control to make the file more friendly to human editing now that we no longer use a tool to generate it.
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.
Will do in a separate PR #6712
| } | ||
|
|
||
| sessionState.ExportedFunctions.Add(entry.Value); | ||
| string message = StringUtil.Format(Modules.ExportingFunction, entry.Key); |
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.
Not for this PR - but the result of this format call is typically thrown away. It should be possible to check if methods like WriteVerbose will do anything before formatting, or at least add overloads that do the formatting only after deciding the formatted string is needed.
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 think it would be the best to add a few overloads to WriteVerbose, which take a format string and arguments. So we can defer the construction of message until we know for sure we are going to write out verbose messages. What do you think?
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.
That might be easiest to adopt.
Best is to use an if before the call, but folks tend to not like that style because it's verbose.
Accepting a delegate is also a clean solution, but that can allocate as well, so might not be an improvement.
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.
Open #6740 to track this investigation.
| _context.EngineHostInterface.ExternalHost, | ||
| _context.SessionState.Path.CurrentLocation, | ||
| GetFunctionToSourceMap()); | ||
| new Dictionary<string, DebugSource>()); |
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.
It's not obvious from the diffs, but it looks like this dictionary might not be needed anymore.
If it's needed and clear elsewhere in the code, then fine, but if it's not needed or unclear, a comment would be good.
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.
Yes, I noticed that too. The implementation of SetParent in RemotingJobDebugger just throws away all the arguments. However, SetParent is a virtual method, theoretically, someone could derive the Debugger class and implement SetParent that actually use the dictionary ... So, it's a breaking change that I'm not sure if I can make.
@PaulHigin Is it OK to remove the functionSourceMap parameter from public virtual void SetParent?
If it's OK, I can clean up the DebugSource type as a whole.
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.
@PaulHigin Could you please take a look and weigh in? Thanks!
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.
Yes, the GetFunctionToSourceMap() is only for the workflow debugger. You can remove the dictionary from SetParent() and also the GetFunctionSource() private method.
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.
Thanks @PaulHigin for the insight!
I have addressed your comment. Also removed the DebugSource type, which is not used anywhere else.
|
Assuming |
|
Seems if we return an empty array it will be a breaking change - in the case a throw is better then a warning. |
|
Currently, As to |
| _context.EngineHostInterface.ExternalHost, | ||
| _context.SessionState.Path.CurrentLocation, | ||
| GetFunctionToSourceMap()); | ||
| new Dictionary<string, DebugSource>()); |
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.
Yes, the GetFunctionToSourceMap() is only for the workflow debugger. You can remove the dictionary from SetParent() and also the GetFunctionSource() private method.
PR Summary
Clean up code related to the uses of
CommandTypes.WorkflowandWorkflowInfoinSystem.Management.Automation. This change mainly affects help provider code.This PR includes a few minor breaking changes:
publicconstructors ofWorkflowInfotointernal. We don't support workflow in PSCore, so I think it makes sense to not allow people to createWorkflowinstances.System.Management.Automation.DebugSourcesince it's only used for workflow debugging.SetParentfrom the abstract classDebuggerthat is only used for workflow debugging.SetParentfrom the derived classRemotingJobDebugger.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests