Summary of the new feature/enhancement
Currently PowerShell has a method that allows this, AddCommand(CommandInfo). However, there's no supported way to add a CommandInfo to a PSCommand instance directly. PowerShellEditorServices (and likely other projects) construct a PSCommand instance well before actually getting to the internal PowerShell object, so working with CommandInfo directly can only be done with reflection.
Proposed technical implementation details (optional)
using System.Management.Automation.Runspaces;
namespace System.Management.Automation
{
public partial sealed class PSCommand
{
public PSCommand AddCommand(CommandInfo commandInfo)
{
return AddCommand(new Command(commandInfo));
}
}
}
namespace System.Management.Automation.Runspaces
{
public sealed class Command
{
- internal Command(CommandInfo commandInfo) : this(commandInfo, false)
+ public Command(CommandInfo commandInfo) : this(commandInfo, false)
{
}
}
}
/cc @TylerLeonhardt @rjmholt
Summary of the new feature/enhancement
Currently
PowerShellhas a method that allows this,AddCommand(CommandInfo). However, there's no supported way to add aCommandInfoto aPSCommandinstance directly. PowerShellEditorServices (and likely other projects) construct aPSCommandinstance well before actually getting to the internalPowerShellobject, so working withCommandInfodirectly can only be done with reflection.Proposed technical implementation details (optional)
namespace System.Management.Automation.Runspaces { public sealed class Command { - internal Command(CommandInfo commandInfo) : this(commandInfo, false) + public Command(CommandInfo commandInfo) : this(commandInfo, false) { } } }/cc @TylerLeonhardt @rjmholt