diff --git a/src/System.Management.Automation/engine/CommandProcessor.cs b/src/System.Management.Automation/engine/CommandProcessor.cs index 05d7b1896c8..fff572e4290 100644 --- a/src/System.Management.Automation/engine/CommandProcessor.cs +++ b/src/System.Management.Automation/engine/CommandProcessor.cs @@ -81,8 +81,6 @@ internal CommandProcessor(IScriptCommandInfo scriptCommandInfo, ExecutionContext Init(scriptCommandInfo); } - // CommandProcessor - #endregion ctor #region internal members diff --git a/src/System.Management.Automation/engine/CommandProcessorBase.cs b/src/System.Management.Automation/engine/CommandProcessorBase.cs index 6ce9dc6d019..859fc6ca1bd 100644 --- a/src/System.Management.Automation/engine/CommandProcessorBase.cs +++ b/src/System.Management.Automation/engine/CommandProcessorBase.cs @@ -25,7 +25,7 @@ internal CommandProcessorBase() } /// - /// Initializes the base command processor class with the command metadata + /// Initializes the base command processor class with the command metadata. /// /// /// The metadata about the command to run. @@ -64,12 +64,12 @@ internal CommandProcessorBase(CommandInfo commandInfo) 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 @@ internal bool AddedToPipelineAlready /// /// 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). /// internal bool RedirectShellErrorOutputPipe { get; set; } = false; @@ -176,7 +175,8 @@ internal bool UseLocalScope /// The script block being dotted /// The current language mode /// The invocation info about the command - protected static void ValidateCompatibleLanguageMode(ScriptBlock scriptBlock, + protected static void ValidateCompatibleLanguageMode( + ScriptBlock scriptBlock, PSLanguageMode languageMode, InvocationInfo invocationInfo) { @@ -228,7 +228,7 @@ internal ExecutionContext Context } /// - /// Etw activity for this pipeline + /// Etw activity for this pipeline. /// internal Guid PipelineActivityId { get; set; } = Guid.Empty; @@ -255,7 +255,7 @@ internal virtual bool IsHelpRequested(out string helpTarget, out HelpCategory he } /// - /// Creates a command processor for "get-help [helpTarget]" + /// Creates a command processor for "get-help [helpTarget]". /// /// context for the command processor /// help target @@ -307,7 +307,7 @@ internal bool IsPipelineInputExpected() internal SessionStateInternal CommandSessionState { get; set; } /// - /// Gets sets the session state scope for this command processor object + /// Gets or sets the session state scope for this command processor object. /// protected internal SessionStateScope CommandScope { get; protected set; } @@ -392,7 +392,7 @@ internal void AddParameter(CommandParameterInternal parameter) internal abstract void Prepare(IDictionary psDefaultParameterValues); /// - /// Write warning message for an obsolete command + /// Write warning message for an obsolete command. /// /// private void HandleObsoleteCommand(ObsoleteAttribute obsoleteAttr) @@ -560,7 +560,7 @@ internal void DoExecute() /// Internally it calls EndProcessing() of the InternalCommand. /// /// - /// a terminating error occurred, or the pipeline was otherwise stopped + /// A terminating error occurred, or the pipeline was otherwise stopped. /// internal virtual void Complete() { @@ -589,7 +589,7 @@ internal virtual void Complete() } // Complete /// - /// Calls the virtual Complete method after setting the appropriate session state scope + /// Calls the virtual Complete method after setting the appropriate session state scope. /// internal void DoComplete() { @@ -652,9 +652,8 @@ internal void DoComplete() } /// - /// for diagnostic purposes + /// For diagnostic purposes. /// - /// public override string ToString() { if (CommandInfo != null) @@ -942,7 +941,7 @@ private void Dispose(bool disposing) } /// - /// Finalizer for class CommandProcessorBase + /// Finalizer for class CommandProcessorBase. /// ~CommandProcessorBase() { @@ -952,4 +951,3 @@ private void Dispose(bool disposing) #endregion IDispose } } - diff --git a/src/System.Management.Automation/engine/CompiledCommandParameter.cs b/src/System.Management.Automation/engine/CompiledCommandParameter.cs index f8cd86012ae..e653e368a21 100644 --- a/src/System.Management.Automation/engine/CompiledCommandParameter.cs +++ b/src/System.Management.Automation/engine/CompiledCommandParameter.cs @@ -10,7 +10,7 @@ namespace System.Management.Automation { /// - /// The metadata associated with a parameter + /// The metadata associated with a parameter. /// internal class CompiledCommandParameter { @@ -18,11 +18,10 @@ internal class CompiledCommandParameter /// /// Constructs an instance of the CompiledCommandAttribute using the specified - /// runtime-defined parameter + /// runtime-defined parameter. /// /// - /// 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. /// /// /// True if dynamic parameters are being processed, or false otherwise. @@ -197,7 +196,7 @@ internal CompiledCommandParameter(MemberInfo member, bool processingDynamicParam internal string Name { get; private set; } /// - /// The PSTypeName from a PSTypeNameAttribute + /// The PSTypeName from a PSTypeNameAttribute. /// internal string PSTypeName { get; private set; } @@ -217,7 +216,7 @@ internal CompiledCommandParameter(MemberInfo member, bool processingDynamicParam internal bool IsDynamic { get; private set; } /// - /// Gets the parameter collection type information + /// Gets the parameter collection type information. /// internal ParameterCollectionTypeInformation CollectionTypeInformation { get; private set; } @@ -228,46 +227,46 @@ internal CompiledCommandParameter(MemberInfo member, bool processingDynamicParam internal Collection CompiledAttributes { get; private set; } /// - /// Gets the collection of data generation attributes on this parameter + /// Gets the collection of data generation attributes on this parameter. /// internal ArgumentTransformationAttribute[] ArgumentTransformationAttributes { get; private set; } /// - /// Gets the collection of data validation attributes on this parameter + /// Gets the collection of data validation attributes on this parameter. /// internal ValidateArgumentsAttribute[] ValidationAttributes { get; private set; } /// - /// Get and private set the obsolete attribute on this parameter + /// Get and private set the obsolete attribute on this parameter. /// internal ObsoleteAttribute ObsoleteAttribute { get; private set; } /// - /// 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. /// internal bool AllowsNullArgument { get; private set; } /// /// If true, null cannot be bound to the parameter (ValidateNotNull - /// and/or ValidateNotNullOrEmpty has been specified) + /// and/or ValidateNotNullOrEmpty has been specified). /// internal bool CannotBeNull { get; private set; } /// /// If true, an empty string can be bound to the string parameter - /// even if the parameter is mandatory + /// even if the parameter is mandatory. /// internal bool AllowsEmptyStringArgument { get; private set; } /// /// 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. /// internal bool AllowsEmptyCollectionArgument { get; private set; } /// /// Gets or sets the value that tells whether this parameter - /// is for the "all" parameter set + /// is for the "all" parameter set. /// internal bool IsInAllSets { get; set; } @@ -298,12 +297,12 @@ internal CompiledCommandParameter(MemberInfo member, bool processingDynamicParam internal Action Setter { get; set; } /// - /// 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. /// internal Dictionary ParameterSetData { get; private set; } /// - /// The alias names for this parameter + /// The alias names for this parameter. /// internal string[] Aliases { get; private set; } @@ -342,7 +341,7 @@ internal bool DoesParameterSetTakePipelineInput(uint validParameterSetFlags) } return false; - } // DoesParameterSetTakePipelineInput + } /// /// Gets the parameter set data for this parameter for the specified parameter set @@ -379,7 +378,7 @@ internal ParameterSetSpecificMetadata GetParameterSetData(uint parameterSetFlag) } /// - /// 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. /// /// /// The parameter sets to get the parameter set data for. @@ -429,10 +428,9 @@ private void ProcessAttribute( 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 @@ internal enum ParameterCollectionType } /// - /// Contains the collection type information for a parameter + /// Contains the collection type information for a parameter. /// internal class ParameterCollectionTypeInformation { @@ -668,17 +666,16 @@ internal ParameterCollectionTypeInformation(Type type) // elementType remains null return; } - } // ctor + } /// - /// The collection type of the parameter + /// The collection type of the parameter. /// internal ParameterCollectionType ParameterCollectionType { get; private set; } /// - /// The type of the elements in the collection + /// The type of the elements in the collection. /// internal Type ElementType { get; private set; } } } - diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index 7414f628ac3..701d9f0a856 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -79,7 +79,7 @@ internal static void Init() public abstract class InitialSessionStateEntry { /// - /// ctor so that each derived class has a name + /// The ctor so that each derived class has a name. /// /// protected InitialSessionStateEntry(string name) @@ -88,12 +88,12 @@ protected InitialSessionStateEntry(string name) } /// - /// The name of this entry + /// The name of this entry. /// public string Name { get; internal set; } /// - /// The SnapIn to load from initially + /// The SnapIn to load from initially. /// public PSSnapInInfo PSSnapIn { get; private set; } @@ -103,7 +103,7 @@ internal void SetPSSnapIn(PSSnapInInfo psSnapIn) } /// - /// The SnapIn to load from initially + /// The SnapIn to load from initially. /// public PSModuleInfo Module { get; private set; } @@ -113,14 +113,14 @@ internal void SetModule(PSModuleInfo module) } /// - /// Shallow-clone this object + /// Shallow-clone this object. /// /// The cloned object... public abstract InitialSessionStateEntry Clone(); } /// - /// Class to constrain session state entries + /// Class to constrain session state entries. /// public abstract class ConstrainedSessionStateEntry : InitialSessionStateEntry { @@ -200,7 +200,7 @@ public SessionStateTypeEntry(string fileName) } /// - /// Loads all the types specified in the typeTable + /// Loads all the types specified in the typeTable. /// /// public SessionStateTypeEntry(TypeTable typeTable) @@ -214,7 +214,7 @@ public SessionStateTypeEntry(TypeTable typeTable) } /// - /// Loads all entries from the typeData + /// Loads all entries from the typeData. /// /// /// @@ -230,7 +230,7 @@ public SessionStateTypeEntry(TypeData typeData, bool isRemove) } /// - /// Shallow-clone this object + /// Shallow-clone this object. /// /// The cloned object public override InitialSessionStateEntry Clone() @@ -290,7 +290,7 @@ public override InitialSessionStateEntry Clone() public sealed class SessionStateFormatEntry : InitialSessionStateEntry { /// - /// Loads the entire formats file + /// Loads the entire formats file. /// /// public SessionStateFormatEntry(string fileName) @@ -305,7 +305,7 @@ public SessionStateFormatEntry(string fileName) } /// - /// Loads all the format data specified in the formatTable + /// Loads all the format data specified in the formatTable. /// /// public SessionStateFormatEntry(FormatTable formattable) @@ -319,7 +319,7 @@ public SessionStateFormatEntry(FormatTable formattable) } /// - /// Loads all the format data specified in the typeDefinition + /// Loads all the format data specified in the typeDefinition. /// /// public SessionStateFormatEntry(ExtendedTypeDefinition typeDefinition) @@ -335,7 +335,7 @@ public SessionStateFormatEntry(ExtendedTypeDefinition typeDefinition) /// /// Shallow-clone this object... /// - /// The cloned object + /// The cloned object. public override InitialSessionStateEntry Clone() { SessionStateFormatEntry entry; @@ -370,8 +370,8 @@ public override InitialSessionStateEntry Clone() public FormatTable Formattable { get; } /// - /// 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. /// public ExtendedTypeDefinition FormatData { get; } @@ -400,7 +400,7 @@ public SessionStateAssemblyEntry(string name, string fileName) /// /// Create a named entry for the assembly to load, specifying - /// just the name + /// just the name. /// /// The name of the assembly to load public SessionStateAssemblyEntry(string name) @@ -410,7 +410,7 @@ public SessionStateAssemblyEntry(string name) } /// - /// Shallow-clone this object + /// Shallow-clone this object. /// /// The cloned object public override InitialSessionStateEntry Clone() @@ -428,7 +428,7 @@ public override InitialSessionStateEntry Clone() } /// - /// List a cmdlet to add to this session state entry + /// List a cmdlet to add to this session state entry. /// public sealed class SessionStateCmdletEntry : SessionStateCommandEntry { @@ -506,7 +506,7 @@ internal SessionStateProviderEntry(string name, Type implementingType, string he /// /// Shallow-clone this object... /// - /// The cloned object + /// The cloned object. public override InitialSessionStateEntry Clone() { SessionStateProviderEntry entry = new SessionStateProviderEntry(Name, ImplementingType, HelpFileName, this.Visibility); @@ -572,10 +572,10 @@ public override InitialSessionStateEntry Clone() public sealed class SessionStateAliasEntry : SessionStateCommandEntry { /// - /// Define an alias entry to add to the initial session state + /// Define an alias entry to add to the initial session state. /// - /// Name of the alias - /// The name of the command it resolves to + /// The name of the alias entry to add. + /// The name of the command it resolves to. public SessionStateAliasEntry(string name, string definition) : base(name, SessionStateEntryVisibility.Public) { @@ -584,10 +584,10 @@ public SessionStateAliasEntry(string name, string definition) } /// - /// Define an alias entry to add to the initial session state + /// Define an alias entry to add to the initial session state. /// - /// Name of the alias - /// The name of the command it resolves to + /// The name of the alias entry to add. + /// The name of the command it resolves to. /// A description of the purpose of the alias. public SessionStateAliasEntry(string name, string definition, string description) : base(name, SessionStateEntryVisibility.Public) @@ -598,12 +598,12 @@ public SessionStateAliasEntry(string name, string definition, string description } /// - /// Define an alias entry to add to the initial session state + /// Define an alias entry to add to the initial session state. /// - /// Name of the alias - /// The name of the command it resolves to + /// The name of the alias entry to add. + /// The name of the command it resolves to. /// A description of the purpose of the alias. - /// Options defining the scope visibility, readonly and constant + /// Options defining the scope visibility, readonly and constant. public SessionStateAliasEntry(string name, string definition, string description, ScopedItemOptions options) : base(name, SessionStateEntryVisibility.Public) { @@ -614,12 +614,12 @@ public SessionStateAliasEntry(string name, string definition, string description } /// - /// Define an alias entry to add to the initial session state + /// Define an alias entry to add to the initial session state. /// - /// Name of the alias - /// The name of the command it resolves to + /// The name of the alias entry to add. + /// The name of the command it resolves to. /// A description of the purpose of the alias. - /// Options defining the scope visibility, readonly and constant + /// Options defining the scope visibility, readonly and constant. /// internal SessionStateAliasEntry(string name, string definition, string description, ScopedItemOptions options, SessionStateEntryVisibility visibility) @@ -665,7 +665,7 @@ public sealed class SessionStateApplicationEntry : SessionStateCommandEntry /// Used to define a permitted script in this session state. If the path is /// "*", then any path is permitted. /// - /// The full path to the application + /// The full path to the application. public SessionStateApplicationEntry(string path) : base(path, SessionStateEntryVisibility.Public) { @@ -729,9 +729,9 @@ public SessionStateFunctionEntry(string name, string definition, ScopedItemOptio /// /// Represents a function definition in an Initial session state object. /// - /// The name of the function - /// The definition of the function - /// The name of the help file associated with the function + /// The name of the function. + /// The definition of the function. + /// The name of the help file associated with the function. public SessionStateFunctionEntry(string name, string definition, string helpFile) : this(name, definition, ScopedItemOptions.None, helpFile) { @@ -740,8 +740,8 @@ public SessionStateFunctionEntry(string name, string definition, string helpFile /// /// Represents a function definition in an Initial session state object. /// - /// The name of the function - /// The definition of the function + /// The name of the function. + /// The definition of the function. public SessionStateFunctionEntry(string name, string definition) : this(name, definition, ScopedItemOptions.None, null) { @@ -777,7 +777,7 @@ internal static SessionStateFunctionEntry GetDelayParsedFunctionEntry(string nam /// /// Shallow-clone this object... /// - /// The cloned object + /// The cloned object. public override InitialSessionStateEntry Clone() { SessionStateFunctionEntry entry = new SessionStateFunctionEntry(Name, Definition, Options, Visibility, ScriptBlock, HelpFile); @@ -988,9 +988,9 @@ public InitialSessionStateEntryCollection(IEnumerable items) } /// - /// Clone this collection + /// Clone this collection. /// - /// The cloned object + /// The cloned collection. public InitialSessionStateEntryCollection Clone() { InitialSessionStateEntryCollection result; @@ -1007,7 +1007,7 @@ public InitialSessionStateEntryCollection Clone() } /// - /// Reset the collection + /// Reset the collection. /// public void Reset() { @@ -1042,13 +1042,10 @@ public T this[int index] } } - //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 /// /// 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. /// /// /// @@ -1318,9 +1315,9 @@ private static void MakeDisallowedEntriesPrivate(InitialSessionStateEntryColl } /// - /// Creates an initial session state from a PSSC configuration file + /// Creates an initial session state from a PSSC configuration file. /// - /// The path to the PSSC session configuration file + /// The path to the PSSC session configuration file. /// public static InitialSessionState CreateFromSessionConfigurationFile(string path) { @@ -1328,9 +1325,9 @@ public static InitialSessionState CreateFromSessionConfigurationFile(string path } /// - /// Creates an initial session state from a PSSC configuration file + /// Creates an initial session state from a PSSC configuration file. /// - /// The path to the PSSC session configuration file + /// The path to the PSSC session configuration file. /// /// 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 @@ public static InitialSessionState CreateFromSessionConfigurationFile(string path /// /// Creates an instance that exposes only the minimal - /// set of commands needed by give set of + /// set of commands needed by give set of . /// All commands that are not needed are made private in order to minimize the attack surface. /// /// @@ -1573,7 +1570,7 @@ public static InitialSessionState CreateDefault() /// /// 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. /// /// @@ -1696,7 +1693,7 @@ public InitialSessionState Clone() /// /// 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. /// /// /// @@ -1716,10 +1713,6 @@ public static InitialSessionState Create(string[] snapInNameCollection, out PSCo 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 /// /// /// @@ -1743,12 +1736,12 @@ public static InitialSessionState CreateFrom(string[] snapInPathCollection, out } /// - /// Specifies the language mode to be used for this session state instance + /// Specifies the language mode to be used for this session state instance. /// public PSLanguageMode LanguageMode { get; set; } = PSLanguageMode.NoLanguage; /// - /// Specifies the directory to be used for collection session transcripts + /// Specifies the directory to be used for collection session transcripts. /// public string TranscriptDirectory { get; set; } = null; @@ -1762,8 +1755,7 @@ internal bool UserDriveEnabled } /// - /// 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. /// internal string UserDriveUserName { @@ -1805,20 +1797,20 @@ public Microsoft.PowerShell.ExecutionPolicy ExecutionPolicy private bool _wasExecutionPolicySet = false; /// - /// 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. /// public bool UseFullLanguageModeInDebugger { get; set; } = false; #if !CORECLR // No ApartmentState In CoreCLR /// - /// ApartmentState of the thread used to execute commands + /// ApartmentState of the thread used to execute commands. /// public ApartmentState ApartmentState { get; set; } = Runspace.DefaultApartmentState; #endif /// - /// 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. /// public PSThreadOptions ThreadOptions { get; set; } = PSThreadOptions.Default; @@ -1889,11 +1881,11 @@ public void ImportPSModule(IEnumerable modules) } /// - /// Imports all the modules from the specified module - /// path by default + /// Imports all the modules from the specified module path by default. /// - /// path from which all modules need - /// to be imported + /// + /// Path from which all modules need to be imported. + /// public void ImportPSModulesFromPath(string path) { string expandedpath = Environment.ExpandEnvironmentVariables(path); @@ -1904,7 +1896,7 @@ public void ImportPSModulesFromPath(string path) /// /// Add a list of core modules to import when the runspace is created. /// - /// The modules to add + /// The modules to add. /// internal void ImportPSCoreModule(string[] name) { @@ -2576,7 +2568,7 @@ private void ProcessCommandModifications(Runspace initializedRunspace) } /// - /// Process a command modification for a specific parameter + /// Process a command modification for a specific parameter. /// /// The hashtable of command modifications for this command /// The metadata for the command being processed @@ -3390,9 +3382,9 @@ internal static void RemoveTypesAndFormats(ExecutionContext context, IList - /// Update the type metadata loaded into this runspace + /// Update the type metadata loaded into this runspace. /// - /// The execution context for the runspace to update + /// The execution context for the runspace to update. /// if true, re-initialize the metadata collection... internal void UpdateTypes(ExecutionContext context, bool updateOnly) { @@ -3506,10 +3498,10 @@ ConcurrentDictionary filesProcessed } /// - /// Update the formatting information for a runspace + /// Update the formatting information for a runspace. /// - /// The execution context for the runspace to be updated - /// True if we only want to add stuff, false if we want to reinitialize + /// The execution context for the runspace to be updated. + /// True if we only want to add stuff, false if we want to reinitialize. internal void UpdateFormats(ExecutionContext context, bool update) { if (DisableFormatUpdates || this.Formats.Count == 0) @@ -3617,7 +3609,7 @@ private static void ThrowTypeOrFormatErrors(string resourceString, string errorM } /// - /// Need to have SnapIn support till we move to modules + /// Need to have SnapIn support till we move to modules. /// /// /// @@ -4664,7 +4656,7 @@ internal static SessionStateAliasEntry[] BuiltInAliases 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 @@ internal static Assembly LoadPSSnapInAssembly(PSSnapInInfo psSnapInInfo) } if (assembly != null) + { return assembly; + } s_PSSnapInTracer.WriteLine("Loading assembly from path: {0}", psSnapInInfo.AssemblyName); @@ -4936,9 +4930,15 @@ private static bool TryGetCustomAttribute(Type decoratedType, out T attribute return attribute != null; } - internal static void AnalyzePSSnapInAssembly(Assembly assembly, string name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, - out Dictionary cmdlets, out Dictionary> aliases, - out Dictionary providers, out string helpFile) + internal static void AnalyzePSSnapInAssembly( + Assembly assembly, + string name, + PSSnapInInfo psSnapInInfo, + PSModuleInfo moduleInfo, + out Dictionary cmdlets, + out Dictionary> aliases, + out Dictionary providers, + out string helpFile) { helpFile = null; if (assembly == null) @@ -5134,8 +5134,12 @@ internal static void AnalyzePSSnapInAssembly(Assembly assembly, string name, PSS } } - 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 cmdlets, ref Dictionary> aliases, ref Dictionary providers) diff --git a/src/System.Management.Automation/engine/Modules/AnalysisCache.cs b/src/System.Management.Automation/engine/Modules/AnalysisCache.cs index f90f2632252..9834f67947b 100644 --- a/src/System.Management.Automation/engine/Modules/AnalysisCache.cs +++ b/src/System.Management.Automation/engine/Modules/AnalysisCache.cs @@ -20,12 +20,10 @@ namespace System.Management.Automation { /// /// 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. /// diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index ca587201000..576a9a295ae 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -431,7 +431,7 @@ private Hashtable LoadModuleManifestData( } /// - /// Extra variables that are allowed to be referenced in module manifest file + /// Extra variables that are allowed to be referenced in module manifest file. /// private static readonly string[] s_extraAllowedVariables = new string[] { SpecialVariables.PSScriptRoot, SpecialVariables.PSEdition, SpecialVariables.EnabledExperimentalFeatures }; @@ -691,8 +691,8 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module 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 @@ internal PSModuleInfo LoadModuleManifest( // 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 @@ internal PSModuleInfo LoadModuleManifest( } containedErrors = true; - if (bailOnFirstError) { return null; } + if (bailOnFirstError) + { + return null; + } } else { @@ -2339,7 +2345,7 @@ internal PSModuleInfo LoadModuleManifest( } // 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 @@ internal PSModuleInfo LoadModuleManifest( 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 @@ internal PSModuleInfo LoadModuleManifest( } 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 @@ internal PSModuleInfo LoadModuleManifest( // 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 @@ internal PSModuleInfo LoadModuleManifest( // 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 @@ internal PSModuleInfo LoadModuleManifest( 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 updated = new List(); 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 @@ internal PSModuleInfo LoadModuleManifest( { // 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 @@ internal enum ModuleLoggingGroupPolicyStatus } /// - /// Enable Module logging based on group policy + /// Enable Module logging based on group policy. /// internal void SetModuleLoggingInformation(PSModuleInfo m) { @@ -4457,15 +4478,15 @@ internal static ModuleLoggingGroupPolicyStatus GetModuleLoggingInformation(out I /// /// 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 true and sets to the value. - /// If the key is missing it returns true and sets to default() - /// If the key is invalid then it returns false + /// If the key is missing it returns true and sets to default(). + /// If the key is invalid then it returns false. /// - /// The hashtable to look for the key in - /// The manifest that generated the hashtable - /// the table key to use - /// Specifies how to treat errors and whether to load elements - /// Value from the manifest converted to the right type - /// true if success; false if there were errors + /// The hashtable to look for the key in. + /// The manifest that generated the hashtable. + /// the table key to use. + /// Specifies how to treat errors and whether to load elements. + /// Value from the manifest converted to the right type. + /// true if success; false if there were errors. internal bool GetScalarFromData( Hashtable data, string moduleManifestPath, @@ -4501,9 +4522,9 @@ internal bool GetScalarFromData( } /// - /// 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. /// - /// The base path to use if the file is not rooted + /// The base path to use if the file is not rooted. /// The file name to resolve. /// The extension to use. /// @@ -4556,7 +4577,7 @@ internal string FixupFileName(string moduleBase, string name, string extension) /// /// 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. /// - /// The base path to use if the file is not rooted + /// The base path to use if the file is not rooted. /// The file name to resolve. /// internal string GetAbsolutePath(string moduleBase, string path) @@ -4587,9 +4608,9 @@ internal static bool IsRooted(string filePath) /// This utility resolves a rooted file name using the provider /// routines. It will only work if the path exists. /// - /// The filename to resolve - /// Execution context - /// The resolved filename + /// The filename to resolve. + /// Execution context. + /// The resolved filename. internal static String ResolveRootedFilePath(string filePath, ExecutionContext context) { // If the path is not fully qualified or relative rooted, then @@ -4750,19 +4771,19 @@ private void RemoveTypesAndFormatting( } /// - /// Removes a module from the session state + /// Removes a module from the session state. /// - /// module to remove + /// module to remove. internal void RemoveModule(PSModuleInfo module) { RemoveModule(module, null); } /// - /// Removes a module from the session state + /// Removes a module from the session state. /// - /// module to remove - /// module name specified in the cmdlet + /// Module to remove. + /// Module name specified in the cmdlet. internal void RemoveModule(PSModuleInfo module, string moduleNameInRemoveModuleCmdlet) { bool isTopLevelModule = false; @@ -5056,8 +5077,8 @@ internal bool IsModuleAlreadyLoaded(PSModuleInfo alreadyLoadedModule) /// /// /// - /// 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 null 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 null 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). /// internal PSModuleInfo IsModuleImportUnnecessaryBecauseModuleIsAlreadyLoaded(string modulePath, string prefix, ImportModuleOptions options) { @@ -5122,14 +5143,14 @@ internal PSModuleInfo IsModuleImportUnnecessaryBecauseModuleIsAlreadyLoaded(stri } /// - /// 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. /// - /// The parent module for which this module is a nested module - /// The name to use for the module - /// The file basename for this module - /// The module's extension - /// The module base which comes from the module manifest - /// Command name prefix + /// The parent module for which this module is a nested module. + /// The name to use for the module. + /// The file basename for this module. + /// The module's extension. + /// The module base which comes from the module manifest. + /// Command name prefix. /// /// 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 @@ internal PSModuleInfo LoadUsingExtensions(PSModuleInfo parentModule, } /// - /// 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. /// - /// The parent module for which this module is a nested module - /// The name to use for the module - /// The file basename for this module - /// The module's extension - /// The module base which comes from the module manifest - /// Command name prefix + /// The parent module for which this module is a nested module. + /// The name to use for the module. + /// The file basename for this module. + /// The module's extension. + /// The module base which comes from the module manifest. + /// Command name prefix. /// /// The session state instance to use for this module - may be null /// in which case a session state will be allocated if necessary /// - /// The set of options that are used while importing a module - /// The processing flags to use when processing the module - /// True if a module was found - /// True if a module file was found + /// The set of options that are used while importing a module. + /// The processing flags to use when processing the module. + /// True if a module was found. + /// True if a module file was found. /// internal PSModuleInfo LoadUsingExtensions(PSModuleInfo parentModule, string moduleName, string fileBaseName, string extension, string moduleBase, @@ -5203,7 +5224,7 @@ internal PSModuleInfo LoadUsingExtensions(PSModuleInfo parentModule, // 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 @@ internal PSModuleInfo LoadUsingExtensions(PSModuleInfo parentModule, (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 @@ internal string GetDefaultPrefix(PSModuleInfo module) /// /// Create an ExternalScriptInfo object from a file path. /// - /// The path to the file - /// The base name of the script - /// check the current execution policy + /// The path to the file. + /// The base name of the script. + /// check the current execution policy. /// The ExternalScriptInfo object. internal ExternalScriptInfo GetScriptInfoForFile(string fileName, out string scriptName, bool checkExecutionPolicy) { @@ -5326,7 +5347,6 @@ internal ExternalScriptInfo GetScriptInfoForFile(string fileName, out string scr // 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 @@ internal ExternalScriptInfo GetScriptInfoForFile(string fileName, out string scr /// /// Load a module from a file... /// - /// The resolved path to load the module from - /// The module base path to use for this module - /// Command name prefix - /// The session state instance to use for this module - may be null in which case a session state will be allocated if necessary - /// The set of options that are used while importing a module - /// The manifest processing flags to use when processing the module - /// True if a module was found - /// True if the module was successfully loaded + /// The resolved path to load the module from. + /// The module base path to use for this module. + /// Command name prefix. + /// The session state instance to use for this module - may be null in which case a session state will be allocated if necessary. + /// The set of options that are used while importing a module. + /// The manifest processing flags to use when processing the module. + /// True if a module was found. + /// True if the module was successfully loaded. internal PSModuleInfo LoadModule(string fileName, string moduleBase, string prefix, SessionState ss, ref ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, out bool found) { @@ -5859,7 +5879,7 @@ private void ClearAnalysisCaches() #if CORECLR /// - /// 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. /// /// /// 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 @@ private static BinaryAnalysisResult GetCmdletsFromBinaryModuleImplementation(str } #else /// - /// 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. /// private BinaryAnalysisResult GetCmdletsFromBinaryModuleImplementation(string path, ManifestProcessingFlags manifestProcessingFlags, out Version assemblyVersion) { @@ -6760,7 +6780,7 @@ internal static string AddPrefixToCommandName(string commandName, string prefix) } /// - /// Removes prefix from a command name and returns the command name + /// Removes prefix from a command name and returns the command name. /// /// The command name from which the prefix needs to be removed. /// The string containing the prefix. @@ -7291,7 +7311,7 @@ private static void ValidateCommandName(ModuleCmdletBase cmdlet, } /// - /// Search a PSSnapin with the specified name + /// Search a PSSnapin with the specified name. /// internal static PSSnapInInfo GetEngineSnapIn(ExecutionContext context, string name) { @@ -7315,18 +7335,18 @@ internal static PSSnapInInfo GetEngineSnapIn(ExecutionContext context, string na } // end ModuleCmdletBase /// - /// Holds the result of a binary module analysis + /// Holds the result of a binary module analysis. /// internal class BinaryAnalysisResult { /// - /// The list of cmdlets detected from the binary + /// The list of cmdlets detected from the binary. /// internal List DetectedCmdlets { get; set; } - // The list of aliases detected from the binary + // The list of aliases detected from the binary. internal List> DetectedAliases { get; set; } } #endregion ModuleCmdletBase -} // Microsoft.PowerShell.Commands +} diff --git a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs index 2e71fcda98d..b782b390177 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs @@ -537,6 +537,7 @@ internal static bool IsPowerShellModuleExtension(string extension) if (extension.Equals(ext, StringComparison.OrdinalIgnoreCase)) return true; } + return false; } @@ -587,7 +588,9 @@ internal static string GetPersonalModulePath() internal static string GetPSHomeModulePath() { if (s_psHomeModulePath != null) + { return s_psHomeModulePath; + } try { @@ -607,7 +610,9 @@ internal static string GetPSHomeModulePath() 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 @@ private static string GetSharedModulePath() { sharedModulePath = Path.Combine(sharedModulePath, Utils.ModuleDirectory); } + return sharedModulePath; #endif } @@ -1112,11 +1118,15 @@ private static void SortAndRemoveDuplicates(List input, Func ke /// Patterns describing the cmdlets to export /// Patterns describing the aliases to export /// Patterns describing the variables to export - /// List of Cmdlets that will not be exported, - /// even if they match in cmdletPatterns. - internal static void ExportModuleMembers(PSCmdlet cmdlet, SessionStateInternal sessionState, - List functionPatterns, List cmdletPatterns, - List aliasPatterns, List variablePatterns, List doNotExportCmdlets) + /// List of Cmdlets that will not be exported, even if they match in cmdletPatterns. + internal static void ExportModuleMembers( + PSCmdlet cmdlet, + SessionStateInternal sessionState, + List functionPatterns, + List cmdletPatterns, + List aliasPatterns, + List variablePatterns, + List doNotExportCmdlets) { // If this cmdlet is called, then mark that the export list should be used for exporting // module members... diff --git a/src/System.Management.Automation/engine/PseudoParameters.cs b/src/System.Management.Automation/engine/PseudoParameters.cs index b30f8a0d2cb..d847660dd98 100644 --- a/src/System.Management.Automation/engine/PseudoParameters.cs +++ b/src/System.Management.Automation/engine/PseudoParameters.cs @@ -209,10 +209,10 @@ public class RuntimeDefinedParameterDictionary : Dictionary - /// Gets or sets the help file that documents these parameters + /// Gets or sets the help file that documents these parameters. /// public string HelpFile { @@ -227,5 +227,5 @@ public string HelpFile public object Data { get; set; } internal static RuntimeDefinedParameter[] EmptyParameterArray = new RuntimeDefinedParameter[0]; - } // class RuntimeDefinedParameterDictionary -} // namespace System.Management.Automation + } +} diff --git a/src/System.Management.Automation/engine/parser/Compiler.cs b/src/System.Management.Automation/engine/parser/Compiler.cs index 38ee48322c7..92d8548e9f6 100644 --- a/src/System.Management.Automation/engine/parser/Compiler.cs +++ b/src/System.Management.Automation/engine/parser/Compiler.cs @@ -1096,8 +1096,13 @@ private static void CheckNoPositionalArgs(AttributeAst ast) 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 @@ private static void CheckNoNamedArgs(AttributeAst ast) { 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 @@ private static Attribute NewCmdletBindingAttribute(AttributeAst ast) } 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 @@ private static Attribute NewParameterAttribute(AttributeAst ast) } 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 @@ private static Attribute NewOutputTypeAttribute(AttributeAst ast) } 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)); } } diff --git a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs index 72e223a873a..fa8b2f33f38 100644 --- a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs +++ b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs @@ -387,7 +387,9 @@ public MergedCommandParameterMetadata GetParameterMetadata(ScriptBlock scriptBlo public override string ToString() { if (_scriptText != null) + { return _scriptText; + } var sbAst = _ast as ScriptBlockAst; if (sbAst != null)