Skip to content

ScriptMethods should know themselves, so they can optionally chain #20456

Closed

Description

Summary of the new feature / enhancement

I would like to make a ScriptMethod that chains until the last step.

Unfortunately, a ScriptMethod lacks two key pieces of information that would enable this:

  • A ScriptMethod does not know its own name
  • A ScriptMethod does not know it's calling AST

Proposed technical implementation details (optional)

These two pieces of information should be embedded into variables, if possible.

Activity

  1. SeeminglyScience commented on Oct 9, 2023

    @SeeminglyScience
    Contributor

    I can only think of one way you could mean "chain" but I'm not sure how that information would help with that. Could you elaborate?

  2. StartAutomating commented on Oct 9, 2023

    @StartAutomating
    Author

    I can only think of one way you could mean "chain" but I'm not sure how that information would help with that. Could you elaborate?

    Sure thing!

    I want a method to return an updated $this if and only if the next ScriptMethod has a value. One cannot do it without callstack peeking in each ScriptMethod and knowing the name of the method.

    I recently wanted to do something like this within Posh's "stackable" functions, which are used for prompt modifications.

    This is an example of a painful workaround (letting an additional $true boolean are be a signal to pass thru).

  3. SeeminglyScience commented on Oct 16, 2023

    @SeeminglyScience
    Contributor

    The Engine WG discussed this and decided that we're not currently interested in providing information about the method's caller. However, we do think there is value in improving InvocationInfo for the InvokeWithPipe code path. We have opened issue #20500 to track that.

  4. StartAutomating commented on Oct 16, 2023

    @StartAutomating
    Author

    Patrick Meinecke (@SeeminglyScience) thanks for the update, I hope the improved invocation info is enough to be able to accomplish the scenario.

    Close it?

  5. SeeminglyScience commented on Oct 16, 2023

    @SeeminglyScience
    Contributor

    Close it?

    The bot will do that now that the label Resolution-Declined is applied, but you're more than welcome to do so as well. Either way works!

  6. microsoft-github-policy-service commented on Oct 16, 2023

    @microsoft-github-policy-service
    Contributor

    📣 Hey James Brundage (@StartAutomating), how did we do? We would love to hear your feedback with the link below! 🗣️

    🔗 https://forms.office.com/r/P926k48jRJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions