-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Do not wrap return result to PSObject when converting ScriptBlock to delegate
#10619
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -647,16 +647,17 @@ internal ReadOnlyCollection<PSTypeName> OutputType | |
| /// <remarks> | ||
daxian-dbw marked this conversation as resolved.
Show resolved
Hide resolved
daxian-dbw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// This does normal array reduction in the case of a one-element array. | ||
| /// </remarks> | ||
| internal static object GetRawResult(List<object> result) | ||
| internal static object GetRawResult(List<object> result, bool wrapToPSObject) | ||
| { | ||
| switch (result.Count) | ||
| { | ||
| case 0: | ||
| return AutomationNull.Value; | ||
| case 1: | ||
| return LanguagePrimitives.AsPSObjectOrNull(result[0]); | ||
| return wrapToPSObject ? LanguagePrimitives.AsPSObjectOrNull(result[0]) : result[0]; | ||
| default: | ||
| return LanguagePrimitives.AsPSObjectOrNull(result.ToArray()); | ||
| object resultArray = result.ToArray(); | ||
| return wrapToPSObject ? LanguagePrimitives.AsPSObjectOrNull(resultArray) : resultArray; | ||
|
Comment on lines
+659
to
+660
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the converting to immutable array mandatory?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @iSazonov Sorry for the super long delay to respond to your comment.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the PR breaks an C# application in any case and developers have to fix their code we could weight removing
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daxian-dbw Could you please share your thoughts about my last comment?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this method is also used by |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -807,7 +808,7 @@ internal object InvokeAsDelegateHelper(object dollarUnder, object dollarThis, ob | |
| outputPipe: outputPipe, | ||
| invocationInfo: null, | ||
| args: args); | ||
| return GetRawResult(rawResult); | ||
| return GetRawResult(rawResult, wrapToPSObject: false); | ||
| } | ||
|
|
||
| #endregion | ||
|
|
@@ -934,7 +935,7 @@ internal object DoInvokeReturnAsIs( | |
| outputPipe: outputPipe, | ||
| invocationInfo: null, | ||
| args: args); | ||
| return GetRawResult(result); | ||
| return GetRawResult(result, wrapToPSObject: true); | ||
| } | ||
|
|
||
| internal void InvokeWithPipe( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.