mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix some style issues in engine code (#7246)
The PR resolves some style issues in engine code. (Moved from PR #7242. )
This commit is contained in:
@@ -81,8 +81,6 @@ namespace System.Management.Automation
|
||||
Init(scriptCommandInfo);
|
||||
}
|
||||
|
||||
// CommandProcessor
|
||||
|
||||
#endregion ctor
|
||||
|
||||
#region internal members
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the base command processor class with the command metadata
|
||||
/// Initializes the base command processor class with the command metadata.
|
||||
/// </summary>
|
||||
/// <param name="commandInfo">
|
||||
/// The metadata about the command to run.
|
||||
@@ -64,12 +64,12 @@ namespace System.Management.Automation
|
||||
|
||||
private InternalCommand _command;
|
||||
|
||||
// marker of whether BeginProcessing() has already run,
|
||||
// also used by CommandProcessor
|
||||
// Marker of whether BeginProcessing() has already run,
|
||||
// also used by CommandProcessor.
|
||||
internal bool RanBeginAlready;
|
||||
|
||||
// marker of whether this command has already been added to
|
||||
// a PipelineProcessor. It is an error to add the same command
|
||||
// Marker of whether this command has already been added to
|
||||
// a PipelineProcessor. It is an error to add the same command
|
||||
// more than once.
|
||||
internal bool AddedToPipelineAlready
|
||||
{
|
||||
@@ -107,9 +107,8 @@ namespace System.Management.Automation
|
||||
/// <summary>
|
||||
/// If this flag is true, the commands in this Pipeline will redirect
|
||||
/// the global error output pipe to the command's error output pipe.
|
||||
///
|
||||
/// (see the comment in Pipeline.RedirectShellErrorOutputPipe for an
|
||||
/// explanation of why this flag is needed)
|
||||
/// (See the comment in Pipeline.RedirectShellErrorOutputPipe for an
|
||||
/// explanation of why this flag is needed).
|
||||
/// </summary>
|
||||
internal bool RedirectShellErrorOutputPipe { get; set; } = false;
|
||||
|
||||
@@ -176,7 +175,8 @@ namespace System.Management.Automation
|
||||
/// <param name="scriptBlock">The script block being dotted</param>
|
||||
/// <param name="languageMode">The current language mode</param>
|
||||
/// <param name="invocationInfo">The invocation info about the command</param>
|
||||
protected static void ValidateCompatibleLanguageMode(ScriptBlock scriptBlock,
|
||||
protected static void ValidateCompatibleLanguageMode(
|
||||
ScriptBlock scriptBlock,
|
||||
PSLanguageMode languageMode,
|
||||
InvocationInfo invocationInfo)
|
||||
{
|
||||
@@ -228,7 +228,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Etw activity for this pipeline
|
||||
/// Etw activity for this pipeline.
|
||||
/// </summary>
|
||||
internal Guid PipelineActivityId { get; set; } = Guid.Empty;
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a command processor for "get-help [helpTarget]"
|
||||
/// Creates a command processor for "get-help [helpTarget]".
|
||||
/// </summary>
|
||||
/// <param name="context">context for the command processor</param>
|
||||
/// <param name="helpTarget">help target</param>
|
||||
@@ -307,7 +307,7 @@ namespace System.Management.Automation
|
||||
internal SessionStateInternal CommandSessionState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets sets the session state scope for this command processor object
|
||||
/// Gets or sets the session state scope for this command processor object.
|
||||
/// </summary>
|
||||
protected internal SessionStateScope CommandScope { get; protected set; }
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace System.Management.Automation
|
||||
internal abstract void Prepare(IDictionary psDefaultParameterValues);
|
||||
|
||||
/// <summary>
|
||||
/// Write warning message for an obsolete command
|
||||
/// Write warning message for an obsolete command.
|
||||
/// </summary>
|
||||
/// <param name="obsoleteAttr"></param>
|
||||
private void HandleObsoleteCommand(ObsoleteAttribute obsoleteAttr)
|
||||
@@ -560,7 +560,7 @@ namespace System.Management.Automation
|
||||
/// Internally it calls EndProcessing() of the InternalCommand.
|
||||
/// </summary>
|
||||
/// <exception cref="PipelineStoppedException">
|
||||
/// a terminating error occurred, or the pipeline was otherwise stopped
|
||||
/// A terminating error occurred, or the pipeline was otherwise stopped.
|
||||
/// </exception>
|
||||
internal virtual void Complete()
|
||||
{
|
||||
@@ -589,7 +589,7 @@ namespace System.Management.Automation
|
||||
} // Complete
|
||||
|
||||
/// <summary>
|
||||
/// Calls the virtual Complete method after setting the appropriate session state scope
|
||||
/// Calls the virtual Complete method after setting the appropriate session state scope.
|
||||
/// </summary>
|
||||
internal void DoComplete()
|
||||
{
|
||||
@@ -652,9 +652,8 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// for diagnostic purposes
|
||||
/// For diagnostic purposes.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
if (CommandInfo != null)
|
||||
@@ -942,7 +941,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizer for class CommandProcessorBase
|
||||
/// Finalizer for class CommandProcessorBase.
|
||||
/// </summary>
|
||||
~CommandProcessorBase()
|
||||
{
|
||||
@@ -952,4 +951,3 @@ namespace System.Management.Automation
|
||||
#endregion IDispose
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Reflection;
|
||||
namespace System.Management.Automation
|
||||
{
|
||||
/// <summary>
|
||||
/// The metadata associated with a parameter
|
||||
/// The metadata associated with a parameter.
|
||||
/// </summary>
|
||||
internal class CompiledCommandParameter
|
||||
{
|
||||
@@ -18,11 +18,10 @@ namespace System.Management.Automation
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an instance of the CompiledCommandAttribute using the specified
|
||||
/// runtime-defined parameter
|
||||
/// runtime-defined parameter.
|
||||
/// </summary>
|
||||
/// <param name="runtimeDefinedParameter">
|
||||
/// A runtime defined parameter that contains the definition of the parameter and its
|
||||
/// metadata.
|
||||
/// A runtime defined parameter that contains the definition of the parameter and its metadata.
|
||||
/// </param>
|
||||
/// <param name="processingDynamicParameters">
|
||||
/// True if dynamic parameters are being processed, or false otherwise.
|
||||
@@ -197,7 +196,7 @@ namespace System.Management.Automation
|
||||
internal string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The PSTypeName from a PSTypeNameAttribute
|
||||
/// The PSTypeName from a PSTypeNameAttribute.
|
||||
/// </summary>
|
||||
internal string PSTypeName { get; private set; }
|
||||
|
||||
@@ -217,7 +216,7 @@ namespace System.Management.Automation
|
||||
internal bool IsDynamic { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter collection type information
|
||||
/// Gets the parameter collection type information.
|
||||
/// </summary>
|
||||
internal ParameterCollectionTypeInformation CollectionTypeInformation { get; private set; }
|
||||
|
||||
@@ -228,46 +227,46 @@ namespace System.Management.Automation
|
||||
internal Collection<Attribute> CompiledAttributes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of data generation attributes on this parameter
|
||||
/// Gets the collection of data generation attributes on this parameter.
|
||||
/// </summary>
|
||||
internal ArgumentTransformationAttribute[] ArgumentTransformationAttributes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of data validation attributes on this parameter
|
||||
/// Gets the collection of data validation attributes on this parameter.
|
||||
/// </summary>
|
||||
internal ValidateArgumentsAttribute[] ValidationAttributes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get and private set the obsolete attribute on this parameter
|
||||
/// Get and private set the obsolete attribute on this parameter.
|
||||
/// </summary>
|
||||
internal ObsoleteAttribute ObsoleteAttribute { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, null can be bound to the parameter even if the parameter is mandatory
|
||||
/// If true, null can be bound to the parameter even if the parameter is mandatory.
|
||||
/// </summary>
|
||||
internal bool AllowsNullArgument { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, null cannot be bound to the parameter (ValidateNotNull
|
||||
/// and/or ValidateNotNullOrEmpty has been specified)
|
||||
/// and/or ValidateNotNullOrEmpty has been specified).
|
||||
/// </summary>
|
||||
internal bool CannotBeNull { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, an empty string can be bound to the string parameter
|
||||
/// even if the parameter is mandatory
|
||||
/// even if the parameter is mandatory.
|
||||
/// </summary>
|
||||
internal bool AllowsEmptyStringArgument { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, an empty collection can be bound to the collection/array parameter
|
||||
/// even if the parameter is mandatory
|
||||
/// even if the parameter is mandatory.
|
||||
/// </summary>
|
||||
internal bool AllowsEmptyCollectionArgument { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value that tells whether this parameter
|
||||
/// is for the "all" parameter set
|
||||
/// is for the "all" parameter set.
|
||||
/// </summary>
|
||||
internal bool IsInAllSets { get; set; }
|
||||
|
||||
@@ -298,12 +297,12 @@ namespace System.Management.Automation
|
||||
internal Action<object, object> Setter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A dictionary of the parameter sets and the parameter set specific data for this parameter
|
||||
/// A dictionary of the parameter sets and the parameter set specific data for this parameter.
|
||||
/// </summary>
|
||||
internal Dictionary<string, ParameterSetSpecificMetadata> ParameterSetData { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The alias names for this parameter
|
||||
/// The alias names for this parameter.
|
||||
/// </summary>
|
||||
internal string[] Aliases { get; private set; }
|
||||
|
||||
@@ -342,7 +341,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
return false;
|
||||
} // DoesParameterSetTakePipelineInput
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter set data for this parameter for the specified parameter set
|
||||
@@ -379,7 +378,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter set data for this parameter for the specified parameter sets
|
||||
/// Gets the parameter set data for this parameter for the specified parameter sets.
|
||||
/// </summary>
|
||||
/// <param name="parameterSetFlags">
|
||||
/// The parameter sets to get the parameter set data for.
|
||||
@@ -429,10 +428,9 @@ namespace System.Management.Automation
|
||||
return;
|
||||
|
||||
CompiledAttributes.Add(attribute);
|
||||
// Now process the attribute based on it's type
|
||||
|
||||
ParameterAttribute paramAttr = attribute as ParameterAttribute;
|
||||
if (paramAttr != null)
|
||||
// Now process the attribute based on it's type
|
||||
if (attribute is ParameterAttribute paramAttr)
|
||||
{
|
||||
ProcessParameterAttribute(memberName, paramAttr);
|
||||
return;
|
||||
@@ -579,7 +577,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains the collection type information for a parameter
|
||||
/// Contains the collection type information for a parameter.
|
||||
/// </summary>
|
||||
internal class ParameterCollectionTypeInformation
|
||||
{
|
||||
@@ -668,17 +666,16 @@ namespace System.Management.Automation
|
||||
// elementType remains null
|
||||
return;
|
||||
}
|
||||
} // ctor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The collection type of the parameter
|
||||
/// The collection type of the parameter.
|
||||
/// </summary>
|
||||
internal ParameterCollectionType ParameterCollectionType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of the elements in the collection
|
||||
/// The type of the elements in the collection.
|
||||
/// </summary>
|
||||
internal Type ElementType { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace System.Management.Automation.Runspaces
|
||||
public abstract class InitialSessionStateEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// ctor so that each derived class has a name
|
||||
/// The ctor so that each derived class has a name.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
protected InitialSessionStateEntry(string name)
|
||||
@@ -88,12 +88,12 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of this entry
|
||||
/// The name of this entry.
|
||||
/// </summary>
|
||||
public string Name { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The SnapIn to load from initially
|
||||
/// The SnapIn to load from initially.
|
||||
/// </summary>
|
||||
public PSSnapInInfo PSSnapIn { get; private set; }
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SnapIn to load from initially
|
||||
/// The SnapIn to load from initially.
|
||||
/// </summary>
|
||||
public PSModuleInfo Module { get; private set; }
|
||||
|
||||
@@ -113,14 +113,14 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shallow-clone this object
|
||||
/// Shallow-clone this object.
|
||||
/// </summary>
|
||||
/// <returns>The cloned object...</returns>
|
||||
public abstract InitialSessionStateEntry Clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class to constrain session state entries
|
||||
/// Class to constrain session state entries.
|
||||
/// </summary>
|
||||
public abstract class ConstrainedSessionStateEntry : InitialSessionStateEntry
|
||||
{
|
||||
@@ -200,7 +200,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads all the types specified in the typeTable
|
||||
/// Loads all the types specified in the typeTable.
|
||||
/// </summary>
|
||||
/// <param name="typeTable"></param>
|
||||
public SessionStateTypeEntry(TypeTable typeTable)
|
||||
@@ -214,7 +214,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads all entries from the typeData
|
||||
/// Loads all entries from the typeData.
|
||||
/// </summary>
|
||||
/// <param name="typeData"></param>
|
||||
/// <param name="isRemove"></param>
|
||||
@@ -230,7 +230,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shallow-clone this object
|
||||
/// Shallow-clone this object.
|
||||
/// </summary>
|
||||
/// <returns>The cloned object</returns>
|
||||
public override InitialSessionStateEntry Clone()
|
||||
@@ -290,7 +290,7 @@ namespace System.Management.Automation.Runspaces
|
||||
public sealed class SessionStateFormatEntry : InitialSessionStateEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads the entire formats file
|
||||
/// Loads the entire formats file.
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public SessionStateFormatEntry(string fileName)
|
||||
@@ -305,7 +305,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads all the format data specified in the formatTable
|
||||
/// Loads all the format data specified in the formatTable.
|
||||
/// </summary>
|
||||
/// <param name="formattable"></param>
|
||||
public SessionStateFormatEntry(FormatTable formattable)
|
||||
@@ -319,7 +319,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads all the format data specified in the typeDefinition
|
||||
/// Loads all the format data specified in the typeDefinition.
|
||||
/// </summary>
|
||||
/// <param name="typeDefinition"></param>
|
||||
public SessionStateFormatEntry(ExtendedTypeDefinition typeDefinition)
|
||||
@@ -335,7 +335,7 @@ namespace System.Management.Automation.Runspaces
|
||||
/// <summary>
|
||||
/// Shallow-clone this object...
|
||||
/// </summary>
|
||||
/// <returns>The cloned object</returns>
|
||||
/// <returns>The cloned object.</returns>
|
||||
public override InitialSessionStateEntry Clone()
|
||||
{
|
||||
SessionStateFormatEntry entry;
|
||||
@@ -370,8 +370,8 @@ namespace System.Management.Automation.Runspaces
|
||||
public FormatTable Formattable { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The FormatData specified with constructor. This can be null if
|
||||
/// FileName or FormatTable constructor is used
|
||||
/// The FormatData specified with constructor.
|
||||
/// This can be null if the FileName or FormatTable constructors are used.
|
||||
/// </summary>
|
||||
public ExtendedTypeDefinition FormatData { get; }
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace System.Management.Automation.Runspaces
|
||||
|
||||
/// <summary>
|
||||
/// Create a named entry for the assembly to load, specifying
|
||||
/// just the name
|
||||
/// just the name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the assembly to load</param>
|
||||
public SessionStateAssemblyEntry(string name)
|
||||
@@ -410,7 +410,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shallow-clone this object
|
||||
/// Shallow-clone this object.
|
||||
/// </summary>
|
||||
/// <returns>The cloned object</returns>
|
||||
public override InitialSessionStateEntry Clone()
|
||||
@@ -428,7 +428,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List a cmdlet to add to this session state entry
|
||||
/// List a cmdlet to add to this session state entry.
|
||||
/// </summary>
|
||||
public sealed class SessionStateCmdletEntry : SessionStateCommandEntry
|
||||
{
|
||||
@@ -506,7 +506,7 @@ namespace System.Management.Automation.Runspaces
|
||||
/// <summary>
|
||||
/// Shallow-clone this object...
|
||||
/// </summary>
|
||||
/// <returns>The cloned object</returns>
|
||||
/// <returns>The cloned object.</returns>
|
||||
public override InitialSessionStateEntry Clone()
|
||||
{
|
||||
SessionStateProviderEntry entry = new SessionStateProviderEntry(Name, ImplementingType, HelpFileName, this.Visibility);
|
||||
@@ -572,10 +572,10 @@ namespace System.Management.Automation.Runspaces
|
||||
public sealed class SessionStateAliasEntry : SessionStateCommandEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Define an alias entry to add to the initial session state
|
||||
/// Define an alias entry to add to the initial session state.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the alias</param>
|
||||
/// <param name="definition">The name of the command it resolves to</param>
|
||||
/// <param name="name">The name of the alias entry to add.</param>
|
||||
/// <param name="definition">The name of the command it resolves to.</param>
|
||||
public SessionStateAliasEntry(string name, string definition)
|
||||
: base(name, SessionStateEntryVisibility.Public)
|
||||
{
|
||||
@@ -584,10 +584,10 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define an alias entry to add to the initial session state
|
||||
/// Define an alias entry to add to the initial session state.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the alias</param>
|
||||
/// <param name="definition">The name of the command it resolves to</param>
|
||||
/// <param name="name">The name of the alias entry to add.</param>
|
||||
/// <param name="definition">The name of the command it resolves to.</param>
|
||||
/// <param name="description">A description of the purpose of the alias.</param>
|
||||
public SessionStateAliasEntry(string name, string definition, string description)
|
||||
: base(name, SessionStateEntryVisibility.Public)
|
||||
@@ -598,12 +598,12 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define an alias entry to add to the initial session state
|
||||
/// Define an alias entry to add to the initial session state.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the alias</param>
|
||||
/// <param name="definition">The name of the command it resolves to</param>
|
||||
/// <param name="name">The name of the alias entry to add.</param>
|
||||
/// <param name="definition">The name of the command it resolves to.</param>
|
||||
/// <param name="description">A description of the purpose of the alias.</param>
|
||||
/// <param name="options">Options defining the scope visibility, readonly and constant</param>
|
||||
/// <param name="options">Options defining the scope visibility, readonly and constant.</param>
|
||||
public SessionStateAliasEntry(string name, string definition, string description, ScopedItemOptions options)
|
||||
: base(name, SessionStateEntryVisibility.Public)
|
||||
{
|
||||
@@ -614,12 +614,12 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define an alias entry to add to the initial session state
|
||||
/// Define an alias entry to add to the initial session state.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the alias</param>
|
||||
/// <param name="definition">The name of the command it resolves to</param>
|
||||
/// <param name="name">The name of the alias entry to add.</param>
|
||||
/// <param name="definition">The name of the command it resolves to.</param>
|
||||
/// <param name="description">A description of the purpose of the alias.</param>
|
||||
/// <param name="options">Options defining the scope visibility, readonly and constant</param>
|
||||
/// <param name="options">Options defining the scope visibility, readonly and constant.</param>
|
||||
/// <param name="visibility"></param>
|
||||
internal SessionStateAliasEntry(string name, string definition, string description,
|
||||
ScopedItemOptions options, SessionStateEntryVisibility visibility)
|
||||
@@ -665,7 +665,7 @@ namespace System.Management.Automation.Runspaces
|
||||
/// Used to define a permitted script in this session state. If the path is
|
||||
/// "*", then any path is permitted.
|
||||
/// </summary>
|
||||
/// <param name="path">The full path to the application</param>
|
||||
/// <param name="path">The full path to the application.</param>
|
||||
public SessionStateApplicationEntry(string path)
|
||||
: base(path, SessionStateEntryVisibility.Public)
|
||||
{
|
||||
@@ -729,9 +729,9 @@ namespace System.Management.Automation.Runspaces
|
||||
/// <summary>
|
||||
/// Represents a function definition in an Initial session state object.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the function</param>
|
||||
/// <param name="definition">The definition of the function</param>
|
||||
/// <param name="helpFile">The name of the help file associated with the function</param>
|
||||
/// <param name="name">The name of the function.</param>
|
||||
/// <param name="definition">The definition of the function.</param>
|
||||
/// <param name="helpFile">The name of the help file associated with the function.</param>
|
||||
public SessionStateFunctionEntry(string name, string definition, string helpFile)
|
||||
: this(name, definition, ScopedItemOptions.None, helpFile)
|
||||
{
|
||||
@@ -740,8 +740,8 @@ namespace System.Management.Automation.Runspaces
|
||||
/// <summary>
|
||||
/// Represents a function definition in an Initial session state object.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the function</param>
|
||||
/// <param name="definition">The definition of the function</param>
|
||||
/// <param name="name">The name of the function.</param>
|
||||
/// <param name="definition">The definition of the function.</param>
|
||||
public SessionStateFunctionEntry(string name, string definition)
|
||||
: this(name, definition, ScopedItemOptions.None, null)
|
||||
{
|
||||
@@ -777,7 +777,7 @@ namespace System.Management.Automation.Runspaces
|
||||
/// <summary>
|
||||
/// Shallow-clone this object...
|
||||
/// </summary>
|
||||
/// <returns>The cloned object</returns>
|
||||
/// <returns>The cloned object.</returns>
|
||||
public override InitialSessionStateEntry Clone()
|
||||
{
|
||||
SessionStateFunctionEntry entry = new SessionStateFunctionEntry(Name, Definition, Options, Visibility, ScriptBlock, HelpFile);
|
||||
@@ -988,9 +988,9 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clone this collection
|
||||
/// Clone this collection.
|
||||
/// </summary>
|
||||
/// <returns>The cloned object</returns>
|
||||
/// <returns>The cloned collection.</returns>
|
||||
public InitialSessionStateEntryCollection<T> Clone()
|
||||
{
|
||||
InitialSessionStateEntryCollection<T> result;
|
||||
@@ -1007,7 +1007,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the collection
|
||||
/// Reset the collection.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
@@ -1042,13 +1042,10 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
}
|
||||
|
||||
//To find the entries based on name.
|
||||
//Why collection - Different SnapIn/modules and same entity names.
|
||||
//If used on command collection entry, then for the same name, one can have multiple output
|
||||
/// <summary>
|
||||
/// To find the entries based on name.
|
||||
/// Why collection - Different SnapIn/modules and same entity names.
|
||||
/// If used on command collection entry, then for the same name, one can have multiple output
|
||||
/// If used on command collection entry, then for the same name, one can have multiple output.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
@@ -1318,9 +1315,9 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an initial session state from a PSSC configuration file
|
||||
/// Creates an initial session state from a PSSC configuration file.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the PSSC session configuration file</param>
|
||||
/// <param name="path">The path to the PSSC session configuration file.</param>
|
||||
/// <returns></returns>
|
||||
public static InitialSessionState CreateFromSessionConfigurationFile(string path)
|
||||
{
|
||||
@@ -1328,9 +1325,9 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an initial session state from a PSSC configuration file
|
||||
/// Creates an initial session state from a PSSC configuration file.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the PSSC session configuration file</param>
|
||||
/// <param name="path">The path to the PSSC session configuration file.</param>
|
||||
/// <param name="roleVerifier">
|
||||
/// The verifier that PowerShell should call to determine if groups in the Role entry apply to the
|
||||
/// target session. If you have a WindowsPrincipal for a user, for example, create a Function that
|
||||
@@ -1345,7 +1342,7 @@ namespace System.Management.Automation.Runspaces
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="InitialSessionState"/> instance that exposes only the minimal
|
||||
/// set of commands needed by give set of <paramref name="sessionCapabilities"/>
|
||||
/// set of commands needed by give set of <paramref name="sessionCapabilities"/>.
|
||||
/// All commands that are not needed are made private in order to minimize the attack surface.
|
||||
/// </summary>
|
||||
/// <param name="sessionCapabilities">
|
||||
@@ -1573,7 +1570,7 @@ namespace System.Management.Automation.Runspaces
|
||||
|
||||
/// <summary>
|
||||
/// Creates the default PowerShell one with default cmdlets, provider etc.
|
||||
/// The default cmdlets, provider, etc are loaded via Modules
|
||||
/// The default cmdlets, provider, etc are loaded via Modules.
|
||||
/// For loading Microsoft.PowerShell.Core module only.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
@@ -1696,7 +1693,7 @@ namespace System.Management.Automation.Runspaces
|
||||
|
||||
/// <summary>
|
||||
/// Want to get away from SnapIn and console file. Have modules and assemblies instead.
|
||||
/// Specify the registered SnapIn name or name collection
|
||||
/// Specify the registered SnapIn name or name collection.
|
||||
/// </summary>
|
||||
/// <param name="snapInName"></param>
|
||||
/// <returns></returns>
|
||||
@@ -1716,10 +1713,6 @@ namespace System.Management.Automation.Runspaces
|
||||
return new InitialSessionState();
|
||||
}
|
||||
|
||||
//This one is for module. Can take only one module, and not collection
|
||||
//public static InitialSessionState Create(Module);
|
||||
|
||||
//Specify the unregistered module/snapIn path or path collection
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="snapInPath"></param>
|
||||
@@ -1743,12 +1736,12 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the language mode to be used for this session state instance
|
||||
/// Specifies the language mode to be used for this session state instance.
|
||||
/// </summary>
|
||||
public PSLanguageMode LanguageMode { get; set; } = PSLanguageMode.NoLanguage;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the directory to be used for collection session transcripts
|
||||
/// Specifies the directory to be used for collection session transcripts.
|
||||
/// </summary>
|
||||
public string TranscriptDirectory { get; set; } = null;
|
||||
|
||||
@@ -1762,8 +1755,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User name for the user drive. This will be part of the root path
|
||||
/// for the User PSDrive.
|
||||
/// User name for the user drive. This will be part of the root path for the User PSDrive.
|
||||
/// </summary>
|
||||
internal string UserDriveUserName
|
||||
{
|
||||
@@ -1805,20 +1797,20 @@ namespace System.Management.Automation.Runspaces
|
||||
private bool _wasExecutionPolicySet = false;
|
||||
|
||||
/// <summary>
|
||||
/// If true the PowerShell debugger will use FullLanguage mode, otherwise it will use the current language mode
|
||||
/// If true the PowerShell debugger will use FullLanguage mode, otherwise it will use the current language mode.
|
||||
/// </summary>
|
||||
public bool UseFullLanguageModeInDebugger { get; set; } = false;
|
||||
|
||||
#if !CORECLR // No ApartmentState In CoreCLR
|
||||
/// <summary>
|
||||
/// ApartmentState of the thread used to execute commands
|
||||
/// ApartmentState of the thread used to execute commands.
|
||||
/// </summary>
|
||||
public ApartmentState ApartmentState { get; set; } = Runspace.DefaultApartmentState;
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// This property determines whether a new thread is create for each invocation of a command
|
||||
/// This property determines whether a new thread is created for each invocation of a command.
|
||||
/// </summary>
|
||||
public PSThreadOptions ThreadOptions { get; set; } = PSThreadOptions.Default;
|
||||
|
||||
@@ -1889,11 +1881,11 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imports all the modules from the specified module
|
||||
/// path by default
|
||||
/// Imports all the modules from the specified module path by default.
|
||||
/// </summary>
|
||||
/// <param name="path">path from which all modules need
|
||||
/// to be imported</param>
|
||||
/// <param name="path">
|
||||
/// Path from which all modules need to be imported.
|
||||
/// </param>
|
||||
public void ImportPSModulesFromPath(string path)
|
||||
{
|
||||
string expandedpath = Environment.ExpandEnvironmentVariables(path);
|
||||
@@ -1904,7 +1896,7 @@ namespace System.Management.Automation.Runspaces
|
||||
/// <summary>
|
||||
/// Add a list of core modules to import when the runspace is created.
|
||||
/// </summary>
|
||||
/// <param name="name">The modules to add</param>
|
||||
/// <param name="name">The modules to add.</param>
|
||||
/// <returns></returns>
|
||||
internal void ImportPSCoreModule(string[] name)
|
||||
{
|
||||
@@ -2576,7 +2568,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process a command modification for a specific parameter
|
||||
/// Process a command modification for a specific parameter.
|
||||
/// </summary>
|
||||
/// <param name="commandModification">The hashtable of command modifications for this command</param>
|
||||
/// <param name="metadata">The metadata for the command being processed</param>
|
||||
@@ -3390,9 +3382,9 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the type metadata loaded into this runspace
|
||||
/// Update the type metadata loaded into this runspace.
|
||||
/// </summary>
|
||||
/// <param name="context">The execution context for the runspace to update</param>
|
||||
/// <param name="context">The execution context for the runspace to update.</param>
|
||||
/// <param name="updateOnly">if true, re-initialize the metadata collection...</param>
|
||||
internal void UpdateTypes(ExecutionContext context, bool updateOnly)
|
||||
{
|
||||
@@ -3506,10 +3498,10 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the formatting information for a runspace
|
||||
/// Update the formatting information for a runspace.
|
||||
/// </summary>
|
||||
/// <param name="context">The execution context for the runspace to be updated</param>
|
||||
/// <param name="update">True if we only want to add stuff, false if we want to reinitialize</param>
|
||||
/// <param name="context">The execution context for the runspace to be updated.</param>
|
||||
/// <param name="update">True if we only want to add stuff, false if we want to reinitialize.</param>
|
||||
internal void UpdateFormats(ExecutionContext context, bool update)
|
||||
{
|
||||
if (DisableFormatUpdates || this.Formats.Count == 0)
|
||||
@@ -3617,7 +3609,7 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Need to have SnapIn support till we move to modules
|
||||
/// Need to have SnapIn support till we move to modules.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="warning"></param>
|
||||
@@ -4664,7 +4656,7 @@ end
|
||||
new SessionStateAliasEntry("type", "Get-Content"),
|
||||
// Native commands we keep because the functions act correctly on Linux
|
||||
new SessionStateAliasEntry("clear", "Clear-Host"),
|
||||
//#if !CORECLR is used to disable aliases for cmdlets which are not available on OneCore or not appropriate for PSCore6 due to conflicts
|
||||
// #if !CORECLR is used to disable aliases for cmdlets which are not available on OneCore or not appropriate for PSCore6 due to conflicts
|
||||
#if !CORECLR
|
||||
new SessionStateAliasEntry("gwmi", "Get-WmiObject", string.Empty, ReadOnly),
|
||||
new SessionStateAliasEntry("iwmi", "Invoke-WMIMethod", string.Empty, ReadOnly),
|
||||
@@ -4893,7 +4885,9 @@ end
|
||||
}
|
||||
|
||||
if (assembly != null)
|
||||
{
|
||||
return assembly;
|
||||
}
|
||||
|
||||
s_PSSnapInTracer.WriteLine("Loading assembly from path: {0}", psSnapInInfo.AssemblyName);
|
||||
|
||||
@@ -4936,9 +4930,15 @@ end
|
||||
return attribute != null;
|
||||
}
|
||||
|
||||
internal static void AnalyzePSSnapInAssembly(Assembly assembly, string name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo,
|
||||
out Dictionary<string, SessionStateCmdletEntry> cmdlets, out Dictionary<string, List<SessionStateAliasEntry>> aliases,
|
||||
out Dictionary<string, SessionStateProviderEntry> providers, out string helpFile)
|
||||
internal static void AnalyzePSSnapInAssembly(
|
||||
Assembly assembly,
|
||||
string name,
|
||||
PSSnapInInfo psSnapInInfo,
|
||||
PSModuleInfo moduleInfo,
|
||||
out Dictionary<string, SessionStateCmdletEntry> cmdlets,
|
||||
out Dictionary<string, List<SessionStateAliasEntry>> aliases,
|
||||
out Dictionary<string, SessionStateProviderEntry> providers,
|
||||
out string helpFile)
|
||||
{
|
||||
helpFile = null;
|
||||
if (assembly == null)
|
||||
@@ -5134,8 +5134,12 @@ end
|
||||
}
|
||||
}
|
||||
|
||||
private static void AnalyzeModuleAssemblyWithReflection(Assembly assembly, string name, PSSnapInInfo psSnapInInfo,
|
||||
PSModuleInfo moduleInfo, string helpFile,
|
||||
private static void AnalyzeModuleAssemblyWithReflection(
|
||||
Assembly assembly,
|
||||
string name,
|
||||
PSSnapInInfo psSnapInInfo,
|
||||
PSModuleInfo moduleInfo,
|
||||
string helpFile,
|
||||
ref Dictionary<string, SessionStateCmdletEntry> cmdlets,
|
||||
ref Dictionary<string, List<SessionStateAliasEntry>> aliases,
|
||||
ref Dictionary<string, SessionStateProviderEntry> providers)
|
||||
|
||||
@@ -20,12 +20,10 @@ namespace System.Management.Automation
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to manage the caching of analysis data.
|
||||
///
|
||||
/// For performance, module command caching is flattened after discovery. Many modules have nested
|
||||
/// modules that can only be resolved at runtime - for example,
|
||||
/// script modules that declare: $env:PATH += "; $psScriptRoot". When
|
||||
/// doing initial analysis, we include these in 'ExportedCommands'.
|
||||
///
|
||||
/// Changes to these type of modules will not be re-analyzed, unless the user re-imports the module,
|
||||
/// or runs Get-Module -List.
|
||||
/// </summary>
|
||||
|
||||
@@ -431,7 +431,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extra variables that are allowed to be referenced in module manifest file
|
||||
/// Extra variables that are allowed to be referenced in module manifest file.
|
||||
/// </summary>
|
||||
private static readonly string[] s_extraAllowedVariables = new string[] { SpecialVariables.PSScriptRoot, SpecialVariables.PSEdition, SpecialVariables.EnabledExperimentalFeatures };
|
||||
|
||||
@@ -691,8 +691,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
module = LoadUsingExtensions(
|
||||
parentModule,
|
||||
moduleSpecification.Name,
|
||||
newRootedPath, // fileBaseName
|
||||
/*extension*/ null,
|
||||
fileBaseName: newRootedPath,
|
||||
extension: null,
|
||||
newModuleBase, // not using base from tempModuleInfoFromVerification as we are looking under moduleBase directory
|
||||
prefix,
|
||||
ss,
|
||||
@@ -1507,7 +1507,10 @@ namespace Microsoft.PowerShell.Commands
|
||||
// Null out 'actualRootModule' so don't attempt to process the file like a non-workflow module later.
|
||||
actualRootModule = null;
|
||||
containedErrors = true;
|
||||
if (bailOnFirstError) { return null; }
|
||||
if (bailOnFirstError)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// extract defaultCommandPrefix from the manifest
|
||||
@@ -2028,7 +2031,10 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
containedErrors = true;
|
||||
if (bailOnFirstError) { return null; }
|
||||
if (bailOnFirstError)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2339,7 +2345,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
// Now add the metadata to the module info object for the manifest...
|
||||
string description = String.Empty;
|
||||
string description = string.Empty;
|
||||
if (data.Contains("Description"))
|
||||
{
|
||||
if (localizedData != null && localizedData.Contains("Description"))
|
||||
@@ -2614,7 +2620,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
var repositorySourceLocation = xml.Properties["RepositorySourceLocation"].Value.ToString();
|
||||
Uri repositorySourceLocationUri;
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(repositorySourceLocation) &&
|
||||
if (!string.IsNullOrWhiteSpace(repositorySourceLocation) &&
|
||||
Uri.TryCreate(repositorySourceLocation, UriKind.RelativeOrAbsolute,
|
||||
out repositorySourceLocationUri))
|
||||
{
|
||||
@@ -2784,7 +2790,10 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
bool etwEnabled = CommandDiscoveryEventSource.Log.IsEnabled();
|
||||
if (etwEnabled) CommandDiscoveryEventSource.Log.ModuleManifestAnalysisResult(manifestInfo.Path, !needToAnalyzeScriptModules);
|
||||
if (etwEnabled)
|
||||
{
|
||||
CommandDiscoveryEventSource.Log.ModuleManifestAnalysisResult(manifestInfo.Path, !needToAnalyzeScriptModules);
|
||||
}
|
||||
|
||||
if (!needToAnalyzeScriptModules)
|
||||
{
|
||||
@@ -3325,10 +3334,14 @@ namespace Microsoft.PowerShell.Commands
|
||||
// Mark stuff for export
|
||||
if (ss != null)
|
||||
{
|
||||
ModuleIntrinsics.ExportModuleMembers(this,
|
||||
ModuleIntrinsics.ExportModuleMembers(
|
||||
this,
|
||||
ss.Internal,
|
||||
exportedFunctions, exportedCmdlets,
|
||||
exportedAliases, exportedVariables, null);
|
||||
exportedFunctions,
|
||||
exportedCmdlets,
|
||||
exportedAliases,
|
||||
exportedVariables,
|
||||
doNotExportCmdlets: null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3338,8 +3351,13 @@ namespace Microsoft.PowerShell.Commands
|
||||
// implicitly export functions and cmdlets.
|
||||
if ((ss != null) && (!ss.Internal.UseExportList))
|
||||
{
|
||||
ModuleIntrinsics.ExportModuleMembers(this, ss.Internal, functionPatterns: MatchAll,
|
||||
cmdletPatterns: MatchAll, aliasPatterns: null, variablePatterns: null, doNotExportCmdlets: null);
|
||||
ModuleIntrinsics.ExportModuleMembers(this,
|
||||
sessionState: ss.Internal,
|
||||
functionPatterns: MatchAll,
|
||||
cmdletPatterns: MatchAll,
|
||||
aliasPatterns: null,
|
||||
variablePatterns: null,
|
||||
doNotExportCmdlets: null);
|
||||
}
|
||||
|
||||
// Export* fields in .psd1 subset Export-ModuleMember calls from ModuleToProcess=psm1
|
||||
@@ -3396,14 +3414,16 @@ namespace Microsoft.PowerShell.Commands
|
||||
if (ss != null)
|
||||
{
|
||||
Dbg.Assert(ss.Internal.ExportedVariables != null,
|
||||
"ss.Internal.ExportedVariables should not be null");
|
||||
"ss.Internal.ExportedVariables should not be null");
|
||||
|
||||
// Update the exports to only contain things that are also in the manifest export list
|
||||
List<PSVariable> updated = new List<PSVariable>();
|
||||
foreach (PSVariable element in ss.Internal.ExportedVariables)
|
||||
{
|
||||
if (SessionStateUtilities.MatchesAnyWildcardPattern(element.Name, exportedVariables,
|
||||
false))
|
||||
if (SessionStateUtilities.MatchesAnyWildcardPattern(
|
||||
element.Name,
|
||||
exportedVariables,
|
||||
defaultValue: false))
|
||||
{
|
||||
updated.Add(element);
|
||||
}
|
||||
@@ -3420,8 +3440,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
// In the case where there are only nested modules,
|
||||
// the members of the manifest are canonical...
|
||||
ModuleIntrinsics.ExportModuleMembers(this,
|
||||
ss.Internal,
|
||||
ModuleIntrinsics.ExportModuleMembers(
|
||||
this,
|
||||
sessionState: ss.Internal,
|
||||
functionPatterns: exportedFunctions,
|
||||
cmdletPatterns: exportedCmdlets,
|
||||
aliasPatterns: exportedAliases,
|
||||
@@ -4388,7 +4409,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable Module logging based on group policy
|
||||
/// Enable Module logging based on group policy.
|
||||
/// </summary>
|
||||
internal void SetModuleLoggingInformation(PSModuleInfo m)
|
||||
{
|
||||
@@ -4457,15 +4478,15 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Checks to see if the module manifest contains the specified key.
|
||||
/// If it does and it can be converted to the expected type, then it returns <c>true</c> and sets <paramref name="result"/> to the value.
|
||||
/// If the key is missing it returns <c>true</c> and sets <paramref name="result"/> to <c>default(<typeparam name="T"/>)</c>
|
||||
/// If the key is invalid then it returns <c>false</c>
|
||||
/// If the key is missing it returns <c>true</c> and sets <paramref name="result"/> to <c>default(<typeparam name="T"/>)</c>.
|
||||
/// If the key is invalid then it returns <c>false</c>.
|
||||
/// </summary>
|
||||
/// <param name="data">The hashtable to look for the key in</param>
|
||||
/// <param name="moduleManifestPath">The manifest that generated the hashtable</param>
|
||||
/// <param name="key">the table key to use</param>
|
||||
/// <param name="manifestProcessingFlags">Specifies how to treat errors and whether to load elements</param>
|
||||
/// <param name="result">Value from the manifest converted to the right type</param>
|
||||
/// <returns><c>true</c> if success; <c>false</c> if there were errors</returns>
|
||||
/// <param name="data">The hashtable to look for the key in.</param>
|
||||
/// <param name="moduleManifestPath">The manifest that generated the hashtable.</param>
|
||||
/// <param name="key">the table key to use.</param>
|
||||
/// <param name="manifestProcessingFlags">Specifies how to treat errors and whether to load elements.</param>
|
||||
/// <param name="result">Value from the manifest converted to the right type.</param>
|
||||
/// <returns><c>true</c> if success; <c>false</c> if there were errors.</returns>
|
||||
internal bool GetScalarFromData<T>(
|
||||
Hashtable data,
|
||||
string moduleManifestPath,
|
||||
@@ -4501,9 +4522,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility routine to fix up a file name so it's rooted and has an extension
|
||||
/// A utility routine to fix up a file name so it's rooted and has an extension.
|
||||
/// </summary>
|
||||
/// <param name="moduleBase">The base path to use if the file is not rooted</param>
|
||||
/// <param name="moduleBase">The base path to use if the file is not rooted.</param>
|
||||
/// <param name="name">The file name to resolve.</param>
|
||||
/// <param name="extension">The extension to use.</param>
|
||||
/// <returns></returns>
|
||||
@@ -4556,7 +4577,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// A utility routine to fix up a file name, if it is relative path convert it to absolute path combining moduleBase, if it is not a relative path, leave as it is.
|
||||
/// </summary>
|
||||
/// <param name="moduleBase">The base path to use if the file is not rooted</param>
|
||||
/// <param name="moduleBase">The base path to use if the file is not rooted.</param>
|
||||
/// <param name="path">The file name to resolve.</param>
|
||||
/// <returns></returns>
|
||||
internal string GetAbsolutePath(string moduleBase, string path)
|
||||
@@ -4587,9 +4608,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// This utility resolves a rooted file name using the provider
|
||||
/// routines. It will only work if the path exists.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The filename to resolve</param>
|
||||
/// <param name="context">Execution context</param>
|
||||
/// <returns>The resolved filename</returns>
|
||||
/// <param name="filePath">The filename to resolve.</param>
|
||||
/// <param name="context">Execution context.</param>
|
||||
/// <returns>The resolved filename.</returns>
|
||||
internal static String ResolveRootedFilePath(string filePath, ExecutionContext context)
|
||||
{
|
||||
// If the path is not fully qualified or relative rooted, then
|
||||
@@ -4750,19 +4771,19 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a module from the session state
|
||||
/// Removes a module from the session state.
|
||||
/// </summary>
|
||||
/// <param name="module">module to remove</param>
|
||||
/// <param name="module">module to remove.</param>
|
||||
internal void RemoveModule(PSModuleInfo module)
|
||||
{
|
||||
RemoveModule(module, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a module from the session state
|
||||
/// Removes a module from the session state.
|
||||
/// </summary>
|
||||
/// <param name="module">module to remove</param>
|
||||
/// <param name="moduleNameInRemoveModuleCmdlet">module name specified in the cmdlet</param>
|
||||
/// <param name="module">Module to remove.</param>
|
||||
/// <param name="moduleNameInRemoveModuleCmdlet">Module name specified in the cmdlet.</param>
|
||||
internal void RemoveModule(PSModuleInfo module, string moduleNameInRemoveModuleCmdlet)
|
||||
{
|
||||
bool isTopLevelModule = false;
|
||||
@@ -5056,8 +5077,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <param name="prefix"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns>
|
||||
/// Returns PSModuleInfo of an already loaded module if that module can be simply reimported and there is no need to proceed with a regular import
|
||||
/// Returns <c>null</c> if the caller should proceed with a regular import (either because there is no previously loaded module, or because the -Force flag was specified and the previously loaded module has been removed by this method)
|
||||
/// Returns PSModuleInfo of an already loaded module if that module can be simply reimported and there is no need to proceed with a regular import.
|
||||
/// Returns <c>null</c> if the caller should proceed with a regular import (either because there is no previously loaded module, or because the -Force flag was specified and the previously loaded module has been removed by this method).
|
||||
/// </returns>
|
||||
internal PSModuleInfo IsModuleImportUnnecessaryBecauseModuleIsAlreadyLoaded(string modulePath, string prefix, ImportModuleOptions options)
|
||||
{
|
||||
@@ -5122,14 +5143,14 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a module file after searching for it using the known extension list
|
||||
/// Loads a module file after searching for it using the known extension list.
|
||||
/// </summary>
|
||||
/// <param name="parentModule">The parent module for which this module is a nested module</param>
|
||||
/// <param name="moduleName">The name to use for the module</param>
|
||||
/// <param name="fileBaseName">The file basename for this module</param>
|
||||
/// <param name="extension">The module's extension</param>
|
||||
/// <param name="moduleBase">The module base which comes from the module manifest</param>
|
||||
/// <param name="prefix">Command name prefix</param>
|
||||
/// <param name="parentModule">The parent module for which this module is a nested module.</param>
|
||||
/// <param name="moduleName">The name to use for the module.</param>
|
||||
/// <param name="fileBaseName">The file basename for this module.</param>
|
||||
/// <param name="extension">The module's extension.</param>
|
||||
/// <param name="moduleBase">The module base which comes from the module manifest.</param>
|
||||
/// <param name="prefix">Command name prefix.</param>
|
||||
/// <param name="ss">
|
||||
/// The session state instance to use for this module - may be null
|
||||
/// in which case a session state will be allocated if necessary
|
||||
@@ -5148,22 +5169,22 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a module file after searching for it using the known extension list
|
||||
/// Loads a module file after searching for it using the known extension list.
|
||||
/// </summary>
|
||||
/// <param name="parentModule">The parent module for which this module is a nested module</param>
|
||||
/// <param name="moduleName">The name to use for the module</param>
|
||||
/// <param name="fileBaseName">The file basename for this module</param>
|
||||
/// <param name="extension">The module's extension</param>
|
||||
/// <param name="moduleBase">The module base which comes from the module manifest</param>
|
||||
/// <param name="prefix">Command name prefix</param>
|
||||
/// <param name="parentModule">The parent module for which this module is a nested module.</param>
|
||||
/// <param name="moduleName">The name to use for the module.</param>
|
||||
/// <param name="fileBaseName">The file basename for this module.</param>
|
||||
/// <param name="extension">The module's extension.</param>
|
||||
/// <param name="moduleBase">The module base which comes from the module manifest.</param>
|
||||
/// <param name="prefix">Command name prefix.</param>
|
||||
/// <param name="ss">
|
||||
/// The session state instance to use for this module - may be null
|
||||
/// in which case a session state will be allocated if necessary
|
||||
/// </param>
|
||||
/// <param name="options">The set of options that are used while importing a module</param>
|
||||
/// <param name="manifestProcessingFlags">The processing flags to use when processing the module</param>
|
||||
/// <param name="found">True if a module was found</param>
|
||||
/// <param name="moduleFileFound">True if a module file was found</param>
|
||||
/// <param name="options">The set of options that are used while importing a module.</param>
|
||||
/// <param name="manifestProcessingFlags">The processing flags to use when processing the module.</param>
|
||||
/// <param name="found">True if a module was found.</param>
|
||||
/// <param name="moduleFileFound">True if a module file was found.</param>
|
||||
/// <returns></returns>
|
||||
internal PSModuleInfo LoadUsingExtensions(PSModuleInfo parentModule,
|
||||
string moduleName, string fileBaseName, string extension, string moduleBase,
|
||||
@@ -5203,7 +5224,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// If the module has already been loaded, just emit it and continue...
|
||||
Context.Modules.ModuleTable.TryGetValue(fileName, out module);
|
||||
// TODO/FIXME: use IsModuleAlreadyLoaded to get consistent behavior
|
||||
//if (!BaseForce &&
|
||||
// if (!BaseForce &&
|
||||
// IsModuleAlreadyLoaded(module) &&
|
||||
// ((manifestProcessingFlags & ManifestProcessingFlags.LoadElements) == ManifestProcessingFlags.LoadElements))
|
||||
if (!BaseForce && module != null &&
|
||||
@@ -5262,7 +5283,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
(BaseGuid == null || module.Guid.Equals(BaseGuid)))
|
||||
// TODO/FIXME: use IsModuleAlreadyLoaded to get consistent behavior
|
||||
// TODO/FIXME: (for example the checks above are not lookint at this.BaseMinimumVersion)
|
||||
//if (BaseForce && IsModuleAlreadyLoaded(module))
|
||||
// if (BaseForce && IsModuleAlreadyLoaded(module))
|
||||
{
|
||||
RemoveModule(module);
|
||||
}
|
||||
@@ -5315,9 +5336,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Create an ExternalScriptInfo object from a file path.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The path to the file</param>
|
||||
/// <param name="scriptName">The base name of the script</param>
|
||||
/// <param name="checkExecutionPolicy">check the current execution policy</param>
|
||||
/// <param name="fileName">The path to the file.</param>
|
||||
/// <param name="scriptName">The base name of the script.</param>
|
||||
/// <param name="checkExecutionPolicy">check the current execution policy.</param>
|
||||
/// <returns>The ExternalScriptInfo object.</returns>
|
||||
internal ExternalScriptInfo GetScriptInfoForFile(string fileName, out string scriptName, bool checkExecutionPolicy)
|
||||
{
|
||||
@@ -5326,7 +5347,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
// Skip ShouldRun check for .psd1 files.
|
||||
// Use ValidateScriptInfo() for explicitly validating the checkpolicy for psd1 file.
|
||||
//
|
||||
if (!scriptName.EndsWith(".psd1", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (checkExecutionPolicy)
|
||||
@@ -5368,14 +5388,14 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Load a module from a file...
|
||||
/// </summary>
|
||||
/// <param name="fileName">The resolved path to load the module from</param>
|
||||
/// <param name="moduleBase">The module base path to use for this module</param>
|
||||
/// <param name="prefix">Command name prefix</param>
|
||||
/// <param name="ss">The session state instance to use for this module - may be null in which case a session state will be allocated if necessary</param>
|
||||
/// <param name="options">The set of options that are used while importing a module</param>
|
||||
/// <param name="manifestProcessingFlags">The manifest processing flags to use when processing the module</param>
|
||||
/// <param name="found">True if a module was found</param>
|
||||
/// <returns>True if the module was successfully loaded</returns>
|
||||
/// <param name="fileName">The resolved path to load the module from.</param>
|
||||
/// <param name="moduleBase">The module base path to use for this module.</param>
|
||||
/// <param name="prefix">Command name prefix.</param>
|
||||
/// <param name="ss">The session state instance to use for this module - may be null in which case a session state will be allocated if necessary.</param>
|
||||
/// <param name="options">The set of options that are used while importing a module.</param>
|
||||
/// <param name="manifestProcessingFlags">The manifest processing flags to use when processing the module.</param>
|
||||
/// <param name="found">True if a module was found.</param>
|
||||
/// <returns>True if the module was successfully loaded.</returns>
|
||||
internal PSModuleInfo LoadModule(string fileName, string moduleBase, string prefix, SessionState ss, ref ImportModuleOptions options,
|
||||
ManifestProcessingFlags manifestProcessingFlags, out bool found)
|
||||
{
|
||||
@@ -5859,7 +5879,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
#if CORECLR
|
||||
/// <summary>
|
||||
/// Analyze the module assembly to find out all cmdlets and aliases defined in that assembly
|
||||
/// Analyze the module assembly to find out all cmdlets and aliases defined in that assembly.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In CoreCLR, there is only one AppDomain, so we cannot spin up a new AppDomain to load the assembly and do analysis there.
|
||||
@@ -5899,7 +5919,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Analyze the module assembly to find out all cmdlets and aliases defined in that assembly
|
||||
/// Analyze the module assembly to find out all cmdlets and aliases defined in that assembly.
|
||||
/// </summary>
|
||||
private BinaryAnalysisResult GetCmdletsFromBinaryModuleImplementation(string path, ManifestProcessingFlags manifestProcessingFlags, out Version assemblyVersion)
|
||||
{
|
||||
@@ -6760,7 +6780,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes prefix from a command name and returns the command name
|
||||
/// Removes prefix from a command name and returns the command name.
|
||||
/// </summary>
|
||||
/// <param name="commandName">The command name from which the prefix needs to be removed.</param>
|
||||
/// <param name="prefix">The string containing the prefix.</param>
|
||||
@@ -7291,7 +7311,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search a PSSnapin with the specified name
|
||||
/// Search a PSSnapin with the specified name.
|
||||
/// </summary>
|
||||
internal static PSSnapInInfo GetEngineSnapIn(ExecutionContext context, string name)
|
||||
{
|
||||
@@ -7315,18 +7335,18 @@ namespace Microsoft.PowerShell.Commands
|
||||
} // end ModuleCmdletBase
|
||||
|
||||
/// <summary>
|
||||
/// Holds the result of a binary module analysis
|
||||
/// Holds the result of a binary module analysis.
|
||||
/// </summary>
|
||||
internal class BinaryAnalysisResult
|
||||
{
|
||||
/// <summary>
|
||||
/// The list of cmdlets detected from the binary
|
||||
/// The list of cmdlets detected from the binary.
|
||||
/// </summary>
|
||||
internal List<string> DetectedCmdlets { get; set; }
|
||||
|
||||
// The list of aliases detected from the binary
|
||||
// The list of aliases detected from the binary.
|
||||
internal List<Tuple<string, string>> DetectedAliases { get; set; }
|
||||
}
|
||||
|
||||
#endregion ModuleCmdletBase
|
||||
} // Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
@@ -537,6 +537,7 @@ namespace System.Management.Automation
|
||||
if (extension.Equals(ext, StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -587,7 +588,9 @@ namespace System.Management.Automation
|
||||
internal static string GetPSHomeModulePath()
|
||||
{
|
||||
if (s_psHomeModulePath != null)
|
||||
{
|
||||
return s_psHomeModulePath;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -607,7 +610,9 @@ namespace System.Management.Automation
|
||||
Interlocked.CompareExchange(ref s_psHomeModulePath, Path.Combine(psHome, "Modules"), null);
|
||||
}
|
||||
}
|
||||
catch (System.Security.SecurityException) { }
|
||||
catch (System.Security.SecurityException)
|
||||
{
|
||||
}
|
||||
|
||||
return s_psHomeModulePath;
|
||||
}
|
||||
@@ -630,6 +635,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
sharedModulePath = Path.Combine(sharedModulePath, Utils.ModuleDirectory);
|
||||
}
|
||||
|
||||
return sharedModulePath;
|
||||
#endif
|
||||
}
|
||||
@@ -1112,11 +1118,15 @@ namespace System.Management.Automation
|
||||
/// <param name="cmdletPatterns">Patterns describing the cmdlets to export</param>
|
||||
/// <param name="aliasPatterns">Patterns describing the aliases to export</param>
|
||||
/// <param name="variablePatterns">Patterns describing the variables to export</param>
|
||||
/// <param name="doNotExportCmdlets">List of Cmdlets that will not be exported,
|
||||
/// even if they match in cmdletPatterns.</param>
|
||||
internal static void ExportModuleMembers(PSCmdlet cmdlet, SessionStateInternal sessionState,
|
||||
List<WildcardPattern> functionPatterns, List<WildcardPattern> cmdletPatterns,
|
||||
List<WildcardPattern> aliasPatterns, List<WildcardPattern> variablePatterns, List<string> doNotExportCmdlets)
|
||||
/// <param name="doNotExportCmdlets">List of Cmdlets that will not be exported, even if they match in cmdletPatterns.</param>
|
||||
internal static void ExportModuleMembers(
|
||||
PSCmdlet cmdlet,
|
||||
SessionStateInternal sessionState,
|
||||
List<WildcardPattern> functionPatterns,
|
||||
List<WildcardPattern> cmdletPatterns,
|
||||
List<WildcardPattern> aliasPatterns,
|
||||
List<WildcardPattern> variablePatterns,
|
||||
List<string> doNotExportCmdlets)
|
||||
{
|
||||
// If this cmdlet is called, then mark that the export list should be used for exporting
|
||||
// module members...
|
||||
|
||||
@@ -209,10 +209,10 @@ namespace System.Management.Automation
|
||||
public RuntimeDefinedParameterDictionary()
|
||||
: base(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
} // ctor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the help file that documents these parameters
|
||||
/// Gets or sets the help file that documents these parameters.
|
||||
/// </summary>
|
||||
public string HelpFile
|
||||
{
|
||||
@@ -227,5 +227,5 @@ namespace System.Management.Automation
|
||||
public object Data { get; set; }
|
||||
|
||||
internal static RuntimeDefinedParameter[] EmptyParameterArray = new RuntimeDefinedParameter[0];
|
||||
} // class RuntimeDefinedParameterDictionary
|
||||
} // namespace System.Management.Automation
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1096,8 +1096,13 @@ namespace System.Management.Automation.Language
|
||||
var positionalArgCount = ast.PositionalArguments.Count;
|
||||
if (positionalArgCount > 0)
|
||||
{
|
||||
throw InterpreterError.NewInterpreterException(null, typeof(MethodException), ast.Extent,
|
||||
"MethodCountCouldNotFindBest", ExtendedTypeSystem.MethodArgumentCountException, ".ctor",
|
||||
throw InterpreterError.NewInterpreterException(
|
||||
null,
|
||||
typeof(MethodException),
|
||||
ast.Extent,
|
||||
"MethodCountCouldNotFindBest",
|
||||
ExtendedTypeSystem.MethodArgumentCountException,
|
||||
".ctor",
|
||||
positionalArgCount);
|
||||
}
|
||||
}
|
||||
@@ -1108,8 +1113,13 @@ namespace System.Management.Automation.Language
|
||||
{
|
||||
var namedArg = ast.NamedArguments[0];
|
||||
var argumentName = namedArg.ArgumentName;
|
||||
throw InterpreterError.NewInterpreterException(namedArg, typeof(RuntimeException), namedArg.Extent,
|
||||
"PropertyNotFoundForType", ParserStrings.PropertyNotFoundForType, argumentName,
|
||||
throw InterpreterError.NewInterpreterException(
|
||||
namedArg,
|
||||
typeof(RuntimeException),
|
||||
namedArg.Extent,
|
||||
"PropertyNotFoundForType",
|
||||
ParserStrings.PropertyNotFoundForType,
|
||||
argumentName,
|
||||
typeof(CmdletBindingAttribute));
|
||||
}
|
||||
}
|
||||
@@ -1168,8 +1178,13 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
else
|
||||
{
|
||||
throw InterpreterError.NewInterpreterException(namedArg, typeof(RuntimeException), namedArg.Extent,
|
||||
"PropertyNotFoundForType", ParserStrings.PropertyNotFoundForType, argumentName,
|
||||
throw InterpreterError.NewInterpreterException(
|
||||
namedArg,
|
||||
typeof(RuntimeException),
|
||||
namedArg.Extent,
|
||||
"PropertyNotFoundForType",
|
||||
ParserStrings.PropertyNotFoundForType,
|
||||
argumentName,
|
||||
typeof(CmdletBindingAttribute));
|
||||
}
|
||||
}
|
||||
@@ -1255,8 +1270,13 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
else
|
||||
{
|
||||
throw InterpreterError.NewInterpreterException(namedArg, typeof(RuntimeException), namedArg.Extent,
|
||||
"PropertyNotFoundForType", ParserStrings.PropertyNotFoundForType, argumentName,
|
||||
throw InterpreterError.NewInterpreterException(
|
||||
namedArg,
|
||||
typeof(RuntimeException),
|
||||
namedArg.Extent,
|
||||
"PropertyNotFoundForType",
|
||||
ParserStrings.PropertyNotFoundForType,
|
||||
argumentName,
|
||||
typeof(CmdletBindingAttribute));
|
||||
}
|
||||
}
|
||||
@@ -1322,8 +1342,13 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
else
|
||||
{
|
||||
throw InterpreterError.NewInterpreterException(namedArg, typeof(RuntimeException), namedArg.Extent,
|
||||
"PropertyNotFoundForType", ParserStrings.PropertyNotFoundForType, argumentName,
|
||||
throw InterpreterError.NewInterpreterException(
|
||||
namedArg,
|
||||
typeof(RuntimeException),
|
||||
namedArg.Extent,
|
||||
"PropertyNotFoundForType",
|
||||
ParserStrings.PropertyNotFoundForType,
|
||||
argumentName,
|
||||
typeof(CmdletBindingAttribute));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,9 @@ namespace System.Management.Automation
|
||||
public override string ToString()
|
||||
{
|
||||
if (_scriptText != null)
|
||||
{
|
||||
return _scriptText;
|
||||
}
|
||||
|
||||
var sbAst = _ast as ScriptBlockAst;
|
||||
if (sbAst != null)
|
||||
|
||||
Reference in New Issue
Block a user