Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions src/System.Management.Automation/engine/CommandDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,26 +301,7 @@ internal void AddSessionStateCmdletEntryToCache(SessionStateCmdletEntry entry, b
internal CommandProcessorBase LookupCommandProcessor(string commandName,
CommandOrigin commandOrigin, bool? useLocalScope)
{
CommandInfo commandInfo = null;
#if false
if (tokenCache.ContainsKey (commandName))
{
commandInfo = tokenCache[commandName];
}
else
{
commandInfo = LookupCommandInfo (commandName);

if (commandInfo.CommandType == CommandTypes.Alias)
{
commandInfo = ((AliasInfo)commandInfo).ResolvedCommand;
}

tokenCache[commandName] = commandInfo;
}
#else
commandInfo = LookupCommandInfo(commandName, commandOrigin);
#endif
CommandInfo commandInfo = LookupCommandInfo(commandName, commandOrigin);
CommandProcessorBase processor = LookupCommandProcessor(commandInfo, commandOrigin, useLocalScope, null);

// commandInfo.Name might be different than commandName - restore the original invocation name
Expand Down
129 changes: 0 additions & 129 deletions src/System.Management.Automation/engine/CommandFactory.cs

This file was deleted.

13 changes: 5 additions & 8 deletions src/System.Management.Automation/engine/ExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,6 @@ internal HelpSystem HelpSystem
internal Dictionary<string, ScriptBlock> CustomArgumentCompleters { get; set; }
internal Dictionary<string, ScriptBlock> NativeArgumentCompleters { get; set; }

private CommandFactory _commandFactory;

/// <summary>
/// Routine to create a command(processor) instance using the factory.
/// </summary>
Expand All @@ -556,15 +554,14 @@ internal HelpSystem HelpSystem
/// <returns>The command processor object</returns>
internal CommandProcessorBase CreateCommand(string command, bool dotSource)
{
if (_commandFactory == null)
{
_commandFactory = new CommandFactory(this);
}
CommandProcessorBase commandProcessor = _commandFactory.CreateCommand(command,
this.EngineSessionState.CurrentScope.ScopeOrigin, !dotSource);
CommandOrigin commandOrigin = this.EngineSessionState.CurrentScope.ScopeOrigin;
CommandProcessorBase commandProcessor =
CommandDiscovery.LookupCommandProcessor(command, commandOrigin, !dotSource);
// Reset the command origin for script commands... //BUGBUG - dotting can get around command origin checks???
if (commandProcessor != null && commandProcessor is ScriptCommandProcessorBase)
{
commandProcessor.Command.CommandOriginInternal = CommandOrigin.Internal;
}

return commandProcessor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ private Pipe GetRedirectionPipe(
/// Create a CommandProcessorBase for this Command
/// </summary>
/// <param name="executionContext"></param>
/// <param name="commandFactory"></param>
/// <param name="addToHistory"></param>
/// <param name="origin"></param>
/// <returns></returns>
Expand All @@ -436,14 +435,11 @@ private Pipe GetRedirectionPipe(
CreateCommandProcessor
(
ExecutionContext executionContext,
CommandFactory commandFactory,
bool addToHistory,
CommandOrigin origin
)
{
Dbg.Assert(executionContext != null, "Caller should verify the parameters");
Dbg.Assert(commandFactory != null, "Caller should verify the parameters");


CommandProcessorBase commandProcessorBase;

Expand Down Expand Up @@ -515,8 +511,7 @@ CommandOrigin origin
}
}

commandProcessorBase =
commandFactory.CreateCommand(CommandText, origin, _useLocalScope);
commandProcessorBase = executionContext.CommandDiscovery.LookupCommandProcessor(CommandText, origin, _useLocalScope);
}

CommandParameterCollection parameters = Parameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,6 @@ internal override bool InNestedPrompt
#endregion protected_properties

#region internal_properties
/// <summary>
/// CommandFactory object for this runspace.
/// </summary>
internal CommandFactory CommandFactory
{
get
{
return _commandFactory;
}
}

/// <summary>
/// Gets history manager for this runspace
Expand Down Expand Up @@ -648,7 +638,6 @@ private void DoOpenHelper()
MshLog.LogEngineLifecycleEvent(_engine.Context, EngineState.Available);
startLifeCycleEventWritten = true;

_commandFactory = new CommandFactory(_engine.Context);
_history = new History(_engine.Context);
_jobRepository = new JobRepository();
_jobManager = new JobManager();
Expand Down Expand Up @@ -902,7 +891,6 @@ private void DoCloseHelper()

//All pipelines have been canceled. Close the runspace.
_engine = null;
_commandFactory = null;

SetRunspaceState(RunspaceState.Closed);

Expand Down Expand Up @@ -1290,11 +1278,6 @@ public override void Close()

#region private fields

/// <summary>
/// CommandFactory for creating Command objects
/// </summary>
private CommandFactory _commandFactory;

/// <summary>
/// AutomationEngine instance for this runspace
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,6 @@ private PipelineProcessor CreatePipelineProcessor()
command.CreateCommandProcessor
(
LocalRunspace.ExecutionContext,
LocalRunspace.CommandFactory,
AddToHistory,
commandOrigin
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3662,7 +3662,6 @@ private SteppablePipeline GetSteppablePipeline(ExecutionContext context, Command
cmd.CreateCommandProcessor
(
Runspace.DefaultRunspace.ExecutionContext,
((LocalRunspace)Runspace.DefaultRunspace).CommandFactory,
false,
IsNested == true ? CommandOrigin.Internal : CommandOrigin.Runspace
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@
<data name="InvalidCmdletNameFormat" xml:space="preserve">
<value>Cannot process the cmdlet. A cmdlet name must consist of a verb and noun pair separated by '-'.</value>
</data>
<data name="CommandDiscoveryMissing" xml:space="preserve">
<value>Cannot retrieve an instance of CommandDiscovery.</value>
</data>
<data name="CommandNotFoundException" xml:space="preserve">
<value>The term '{0}' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</value>
Expand All @@ -151,9 +148,6 @@ Check the spelling of the name, or if a path was included, verify that the path
<data name="CommandNameNotCmdlet" xml:space="preserve">
<value>Parameter '{0}' with value '{1}' cannot be processed because it is not a cmdlet and cannot be processed by the CommandProcessor.</value>
</data>
<data name="ExecutionContextNotSet" xml:space="preserve">
<value>An ExecutionContext has not been set.</value>
</data>
<data name="DuplicateCmdletName" xml:space="preserve">
<value>A cmdlet named '{0}' already exists. Cmdlets must have unique names.</value>
</data>
Expand Down