From 0e759fea1fe6a8f0593ca7bca288c49cd1a11691 Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Thu, 28 May 2020 05:22:41 +0100 Subject: [PATCH 1/2] Add empty line between single-line declarations of different kind RCS0013 --- .../FilterCore/ValidatingSelectorValue.cs | 1 + .../ManagementList/PropertyValueGetter.cs | 1 + .../NewWinEventCommand.cs | 1 + .../cmdletization/cim/cimChildJobBase.cs | 5 ++ .../cim/cimCmdletDefinitionContext.cs | 1 + .../cmdletization/cim/cimWrapper.cs | 1 + .../cmdletization/cim/clientSideQuery.cs | 2 + .../commands/management/Clipboard.cs | 1 + .../commands/management/Computer.cs | 1 + .../commands/utility/AddType.cs | 2 + .../utility/ConvertFromMarkdownCommand.cs | 1 + .../OutGridView/OutGridViewCommand.cs | 1 + .../OutGridView/OutWindowProxy.cs | 1 + .../commands/utility/GetRandomCommand.cs | 1 + .../commands/utility/Join-String.cs | 1 + .../utility/MarkdownOptionCommands.cs | 1 + .../commands/utility/Select-Object.cs | 1 + .../utility/WebCmdlet/ConvertToJsonCommand.cs | 2 + .../host/msh/ConsoleControl.cs | 1 + .../host/msh/ConsoleHostUserInterface.cs | 1 + .../msh/ConsoleHostUserInterfaceProgress.cs | 2 + .../host/msh/PendingProgress.cs | 1 + .../Eventing/EventProviderTraceListener.cs | 3 + .../Eventing/UnsafeNativeMethods.cs | 1 + .../ListItemBlockRenderer.cs | 1 + .../VT100EscapeSequences.cs | 2 + .../security/CertificateProvider.cs | 1 + .../common/BaseOutputtingCommand.cs | 2 + .../common/DisplayDatabase/typeDataManager.cs | 1 + .../FormatAndOutput/common/TableWriter.cs | 2 + .../engine/CoreAdapter.cs | 2 + .../engine/EventManager.cs | 1 + .../engine/InitialSessionState.cs | 1 + .../engine/LanguagePrimitives.cs | 3 + .../engine/Modules/ScriptAnalysis.cs | 1 + .../engine/MshCommandRuntime.cs | 1 + .../engine/MshMemberInfo.cs | 1 + .../engine/PSVersionInfo.cs | 2 + .../engine/SpecialVariables.cs | 58 +++++++++++++++++++ .../engine/TypeTable_Types_Ps1Xml.cs | 1 + .../engine/Utils.cs | 1 + .../engine/debugger/debugger.cs | 2 + .../engine/hostifaces/MshHost.cs | 1 + .../engine/hostifaces/MshHostUserInterface.cs | 2 + .../engine/hostifaces/RunspacePool.cs | 1 + .../interpreter/ControlFlowInstructions.cs | 1 + .../engine/interpreter/Interpreter.cs | 1 + .../engine/interpreter/Utilities.cs | 1 + .../engine/lang/parserutils.cs | 1 + .../engine/parser/Parser.cs | 2 + .../engine/parser/SafeValues.cs | 1 + .../engine/parser/VariableAnalysis.cs | 1 + .../engine/parser/ast.cs | 2 + .../remoting/client/ClientRemotePowerShell.cs | 2 + .../engine/remoting/client/Job2.cs | 2 + .../engine/remoting/client/ThrottlingJob.cs | 1 + .../remoting/commands/CustomShellCommands.cs | 1 + .../remoting/commands/InvokeCommandCommand.cs | 1 + .../NewPSSessionConfigurationOptionCommand.cs | 10 ++++ .../remoting/commands/PSRemotingCmdlet.cs | 1 + .../remoting/common/RunspaceConnectionInfo.cs | 4 ++ .../engine/remoting/common/fragmentor.cs | 1 + .../fanin/OutOfProcTransportManager.cs | 4 ++ .../engine/remoting/fanin/WSManNativeAPI.cs | 2 + .../engine/runtime/Binding/Binders.cs | 1 + .../engine/runtime/CompiledScriptBlock.cs | 3 + .../engine/runtime/MutableTuple.cs | 1 + .../help/HelpCommentsParser.cs | 1 + .../namespaces/FileSystemContentStream.cs | 3 + .../namespaces/FileSystemProvider.cs | 4 ++ .../namespaces/RegistryWrapper.cs | 2 + .../utils/ParserException.cs | 1 + .../utils/PsUtils.cs | 1 + .../utils/StringUtil.cs | 2 + .../utils/tracing/TracingGen.cs | 1 + test/xUnit/csharp/test_PSConfiguration.cs | 1 + 76 files changed, 181 insertions(+) diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/ValidatingSelectorValue.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/ValidatingSelectorValue.cs index 89c1484cbc1..ed5389668e6 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/ValidatingSelectorValue.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/ValidatingSelectorValue.cs @@ -47,6 +47,7 @@ public IList AvailableValues #region SelectedIndex private const string SelectedIndexPropertyName = "SelectedIndex"; + private int selectedIndex; /// diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/PropertyValueGetter.cs b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/PropertyValueGetter.cs index 6875198704d..61a1a71938c 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/PropertyValueGetter.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/PropertyValueGetter.cs @@ -14,6 +14,7 @@ namespace Microsoft.Management.UI.Internal public class PropertyValueGetter : IPropertyValueGetter { private const string PropertyDescriptorColumnId = "PropertyDescriptor"; + private DataTable cachedProperties; /// diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs index 1c0acb7f45a..216e9bca7ea 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs @@ -27,6 +27,7 @@ public sealed class NewWinEventCommand : PSCmdlet private const string TemplateTag = "template"; private const string DataTag = "data"; + private ResourceManager _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); /// diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs index c09ed5287ad..8dab2f95540 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs @@ -27,6 +27,7 @@ internal abstract class CimChildJobBase : { private static long s_globalJobNumberCounter; private readonly long _myJobNumber = Interlocked.Increment(ref s_globalJobNumberCounter); + private const string CIMJobType = "CimJob"; internal CimJobContext JobContext @@ -57,6 +58,7 @@ internal CimChildJobBase(CimJobContext jobContext) } private readonly CimSensitiveValueConverter _cimSensitiveValueConverter = new CimSensitiveValueConverter(); + internal CimSensitiveValueConverter CimSensitiveValueConverter { get { return _cimSensitiveValueConverter; } } internal abstract IObservable GetCimOperation(); @@ -161,8 +163,10 @@ public virtual void OnCompleted() private readonly Random _random; private int _sleepAndRetryDelayRangeMs = 1000; private int _sleepAndRetryExtraDelayMs = 0; + private const int MaxRetryDelayMs = 15 * 1000; private const int MinRetryDelayMs = 100; + private Timer _sleepAndRetryTimer; private void SleepAndRetry_OnWakeup(object state) { @@ -527,6 +531,7 @@ internal CimOperationOptions CreateOperationOptions() } private readonly Lazy _jobSpecificCustomOptions; + internal abstract CimCustomOptionsDictionary CalculateJobSpecificCustomOptions(); private CimCustomOptionsDictionary GetJobSpecificCustomOptions() { diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs index 082a7597425..5d70edc986e 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs @@ -37,6 +37,7 @@ internal CimCmdletDefinitionContext( private readonly IDictionary _privateData; private const string QueryLanguageKey = "QueryDialect"; + private bool? _useEnumerateInstancesInsteadOfWql; public bool UseEnumerateInstancesInsteadOfWql { diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs index d78c8d631e9..a667e6da2f5 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs @@ -369,6 +369,7 @@ internal override CimSession GetSessionOfOriginFromInstance(CimInstance instance #region Handling of dynamic parameters private RuntimeDefinedParameterDictionary _dynamicParameters; + private const string CimNamespaceParameter = "CimNamespace"; private string GetDynamicNamespace() diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs index 47c538ccb6a..6b454ad8b7e 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs @@ -154,6 +154,7 @@ public virtual IEnumerable GetNotFoundErrors_IfThisIsTheOnlyFilte private abstract class CimInstancePropertyBasedFilter : CimInstanceFilterBase { private readonly List _propertyValueFilters = new List(); + protected IEnumerable PropertyValueFilters { get { return _propertyValueFilters; } } protected void AddPropertyValueFilter(PropertyValueFilter propertyValueFilter) @@ -357,6 +358,7 @@ public BehaviorOnNoMatch BehaviorOnNoMatch } protected abstract BehaviorOnNoMatch GetDefaultBehaviorWhenNoMatchesFound(object cimTypedExpectedPropertyValue); + private BehaviorOnNoMatch _behaviorOnNoMatch; public string PropertyName { get; } diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Clipboard.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Clipboard.cs index 77701a1bb70..38a1b5c48a6 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Clipboard.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Clipboard.cs @@ -197,6 +197,7 @@ public static void SetRtf(string plainText, string rtfText) private const uint CF_TEXT = 1; private const uint CF_UNICODETEXT = 13; + private static uint s_CF_RTF; private static bool GetTextImpl(out string text) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs index ece9d77e511..d8f0b96fade 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs @@ -1123,6 +1123,7 @@ public sealed class StopComputerCommand : PSCmdlet, IDisposable #region Private Members private readonly CancellationTokenSource _cancel = new CancellationTokenSource(); + private const int forcedShutdown = 5; // See https://msdn.microsoft.com/library/aa394058(v=vs.85).aspx #endregion diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index df96aba17a4..d504a43a46d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -634,7 +634,9 @@ protected override void EndProcessing() private static readonly Dictionary s_sourceAssemblyCache = new Dictionary(); private static readonly string s_defaultSdkDirectory = Utils.DefaultPowerShellAppBase; + private const ReportDiagnostic defaultDiagnosticOption = ReportDiagnostic.Error; + private static readonly string[] s_writeInformationTags = new string[] { "PSHOST" }; private int _syntaxTreesHash; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFromMarkdownCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFromMarkdownCommand.cs index efd61a6922a..dfa6bd6c4b0 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFromMarkdownCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFromMarkdownCommand.cs @@ -58,6 +58,7 @@ public class ConvertFromMarkdownCommand : PSCmdlet private const string PathParameterSet = "PathParamSet"; private const string LiteralPathParameterSet = "LiteralParamSet"; private const string InputObjParamSet = "InputObjParamSet"; + private MarkdownConversionType _conversionType = MarkdownConversionType.HTML; private PSMarkdownOptionInfo _mdOption = null; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs index 8ae81bedd24..b95e9968c5c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs @@ -43,6 +43,7 @@ public class OutGridViewCommand : PSCmdlet, IDisposable private const string DataNotQualifiedForGridView = "DataNotQualifiedForGridView"; private const string RemotingNotSupported = "RemotingNotSupported"; + private TypeInfoDataBase _typeInfoDataBase; private PSPropertyExpressionFactory _expressionFactory; private OutWindowProxy _windowProxy; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs index 871b1a1bb62..55158034368 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs @@ -20,6 +20,7 @@ internal class OutWindowProxy : IDisposable internal const string OriginalObjectPropertyName = "OutGridViewOriginalObject"; private const string ToStringValuePropertyName = "ToStringValue"; private const string IndexPropertyName = "IndexValue"; + private int _index; /// Columns definition of the underlying Management List diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs index 6e4445ba28e..01cf6534c48 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs @@ -29,6 +29,7 @@ public class GetRandomCommand : PSCmdlet private const string RandomNumberParameterSet = "RandomNumberParameterSet"; private const string RandomListItemParameterSet = "RandomListItemParameterSet"; private const string ShuffleParameterSet = "ShuffleParameterSet"; + private static readonly object[] _nullInArray = new object[] { null }; private enum MyParameterSet diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs index abc8fddc6f9..652e32652ce 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs @@ -22,6 +22,7 @@ public sealed class JoinStringCommand : PSCmdlet { /// A bigger default to not get re-allocations in common use cases. private const int DefaultOutputStringCapacity = 256; + private readonly StringBuilder _outputBuilder = new StringBuilder(DefaultOutputStringCapacity); private CultureInfo _cultureInfo = CultureInfo.InvariantCulture; private string _separator; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MarkdownOptionCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MarkdownOptionCommands.cs index d6cecf471bc..0ee80712123 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MarkdownOptionCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MarkdownOptionCommands.cs @@ -272,6 +272,7 @@ protected override void EndProcessing() internal static class PSMarkdownOptionInfoCache { private static ConcurrentDictionary markdownOptionInfoCache; + private const string MarkdownOptionInfoVariableName = "PSMarkdownOptionInfo"; static PSMarkdownOptionInfoCache() diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs index 7614278b602..bba2ac2873d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs @@ -329,6 +329,7 @@ internal UniquePSObjectHelper(PSObject o, int notePropertyCount) } internal readonly PSObject WrittenObject; + internal int NotePropertyCount { get; } } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs index 6c191fcb6e9..92e67f5681a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs @@ -26,7 +26,9 @@ public class ConvertToJsonCommand : PSCmdlet public object InputObject { get; set; } private int _depth = 2; + private const int maxDepthAllowed = 100; + private readonly CancellationTokenSource _cancellationSource = new CancellationTokenSource(); /// diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs index 2229dbb63f1..6d027620718 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs @@ -3005,6 +3005,7 @@ internal static void MimicKeyPress(INPUT[] inputs) internal static class NativeMethods { internal static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); // WinBase.h + internal const int FontTypeMask = 0x06; internal const int TrueTypeFont = 0x04; diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs index 402a3a19a25..e896674728b 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs @@ -1386,6 +1386,7 @@ public override void WriteErrorLine(string value) // We use System.Environment.NewLine because we are platform-agnostic internal static string Crlf = System.Environment.NewLine; + private const string Tab = "\x0009"; internal enum ReadLineResult diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs index f055001239f..ffc5735f35f 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs @@ -192,7 +192,9 @@ class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInt private PendingProgress _pendingProgress = null; // The timer set up 'progPaneUpdateFlag' every 'UpdateTimerThreshold' milliseconds to update 'ProgressPane' private Timer _progPaneUpdateTimer = null; + private const int UpdateTimerThreshold = 200; + private int progPaneUpdateFlag = 0; } } // namespace diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs index 0d4638cdb6f..ce4b6d95acb 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs @@ -1019,6 +1019,7 @@ internal static private ArrayList _topLevelNodes = new ArrayList(); private int _nodeCount; + private const int maxNodeCount = 128; } } // namespace diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProviderTraceListener.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProviderTraceListener.cs index 27b24de945e..97c10d167ef 100644 --- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProviderTraceListener.cs +++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProviderTraceListener.cs @@ -20,10 +20,13 @@ public class EventProviderTraceListener : TraceListener // // private EventProvider _provider; + private const string s_nullStringValue = "null"; private const string s_nullStringComaValue = "null,"; private const string s_nullCStringValue = ": null"; + private string _delimiter = ";"; + private const uint s_keyWordMask = 0xFFFFFF00; private const int s_defaultPayloadSize = 512; diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs index a902f0def73..23b867e8696 100644 --- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs +++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs @@ -14,6 +14,7 @@ internal static class UnsafeNativeMethods private const string FormatMessageDllName = "api-ms-win-core-localization-l1-2-0.dll"; private const string EventProviderDllName = "api-ms-win-eventing-provider-l1-1-0.dll"; private const string WEVTAPI = "wevtapi.dll"; + private static readonly IntPtr s_NULL = IntPtr.Zero; // WinError.h codes: diff --git a/src/Microsoft.PowerShell.MarkdownRender/ListItemBlockRenderer.cs b/src/Microsoft.PowerShell.MarkdownRender/ListItemBlockRenderer.cs index c680d9c973b..281cec47d54 100644 --- a/src/Microsoft.PowerShell.MarkdownRender/ListItemBlockRenderer.cs +++ b/src/Microsoft.PowerShell.MarkdownRender/ListItemBlockRenderer.cs @@ -61,6 +61,7 @@ private void RenderWithIndent(VT100Renderer renderer, MarkdownObject block, char // Typical padding is at most a screen's width, any more than that and we won't bother caching. private const int IndentCacheMax = 120; + private static readonly string[] IndentCache = new string[IndentCacheMax]; internal static string Padding(int countOfSpaces) diff --git a/src/Microsoft.PowerShell.MarkdownRender/VT100EscapeSequences.cs b/src/Microsoft.PowerShell.MarkdownRender/VT100EscapeSequences.cs index 8e6d5ba9967..0827fdf049f 100644 --- a/src/Microsoft.PowerShell.MarkdownRender/VT100EscapeSequences.cs +++ b/src/Microsoft.PowerShell.MarkdownRender/VT100EscapeSequences.cs @@ -273,10 +273,12 @@ private void SetCodeColor(bool isDarkTheme) public class VT100EscapeSequences { private const char Esc = (char)0x1B; + private string endSequence = Esc + "[0m"; // For code blocks, [500@ make sure that the whole line has background color. private const string LongBackgroundCodeBlock = "[500@"; + private PSMarkdownOptionInfo options; /// diff --git a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs index cde06e0ed65..1b541b87fcc 100644 --- a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs +++ b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs @@ -3177,6 +3177,7 @@ public sealed class DnsNameProperty { private List _dnsList = new List(); private System.Globalization.IdnMapping idnMapping = new System.Globalization.IdnMapping(); + private const string dnsNamePrefix = "DNS Name="; private const string distinguishedNamePrefix = "CN="; diff --git a/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs b/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs index 4467744a666..bd9098431d5 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs @@ -950,7 +950,9 @@ private sealed class TableOutputContext : TableOutputContextBase private int _rowCount = 0; private int _consoleHeight = -1; private int _consoleWidth = -1; + private const int WhitespaceAndPagerLineCount = 2; + private bool _repeatHeader = false; /// diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs index 21a180baf62..985561670f8 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs @@ -473,6 +473,7 @@ private static void LoadFormatDataHelper( } private delegate IEnumerable TypeGenerator(); + private static Dictionary> s_builtinGenerators; private static Tuple GetBuiltin(bool isForHelp, TypeGenerator generator) diff --git a/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs b/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs index 7eaeef24c26..e01be6f5b8c 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs @@ -40,8 +40,10 @@ private class ScreenInfo } private ScreenInfo _si; + private const char ESC = '\u001b'; private const string ResetConsoleVt100Code = "\u001b[m"; + private List _header; internal static int ComputeWideViewBestItemsPerRowFit(int stringLen, int screenColumns) diff --git a/src/System.Management.Automation/engine/CoreAdapter.cs b/src/System.Management.Automation/engine/CoreAdapter.cs index 44361ffa04f..e048fd648ae 100644 --- a/src/System.Management.Automation/engine/CoreAdapter.cs +++ b/src/System.Management.Automation/engine/CoreAdapter.cs @@ -2101,7 +2101,9 @@ internal string methodDefinition internal bool isGeneric; private bool _useReflection; + private delegate object MethodInvoker(object target, object[] arguments); + private MethodInvoker _methodInvoker; /// diff --git a/src/System.Management.Automation/engine/EventManager.cs b/src/System.Management.Automation/engine/EventManager.cs index c524e3646c5..c2904d61d51 100644 --- a/src/System.Management.Automation/engine/EventManager.cs +++ b/src/System.Management.Automation/engine/EventManager.cs @@ -2349,6 +2349,7 @@ public class PSEventArgsCollection : IEnumerable /// The event generated when a new event is received. /// public event PSEventReceivedEventHandler PSEventReceived; + private List _eventCollection = new List(); /// diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index a26573b1cfa..b69aafe910c 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4771,6 +4771,7 @@ internal static SessionStateAliasEntry[] BuiltInAliases "; internal const string DefaultSetDriveFunctionText = "Set-Location $MyInvocation.MyCommand.Name"; + internal static ScriptBlock SetDriveScriptBlock = ScriptBlock.CreateDelayParsedScriptBlock(DefaultSetDriveFunctionText, isProductCode: true); private static PSLanguageMode systemLanguageMode = (SystemPolicy.GetSystemLockdownPolicy() == SystemEnforcementMode.Enforce) ? PSLanguageMode.ConstrainedLanguage : PSLanguageMode.FullLanguage; diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index 039761b4118..e4741126904 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -413,6 +413,7 @@ private static IEnumerable GetEnumerableFromIEnumerableT(object obj) } private delegate IEnumerable GetEnumerableDelegate(object obj); + private static Dictionary s_getEnumerableCache = new Dictionary(32); private static GetEnumerableDelegate GetOrCalculateEnumerable(Type type) @@ -1922,6 +1923,7 @@ internal EnumHashEntry(string[] names, Array values, UInt64 allValues, bool hasN // This static is thread safe based on the lock in GetEnumHashEntry // It can be shared by Runspaces in different MiniShells private static readonly Dictionary s_enumTable = new Dictionary(); + private const int maxEnumTableSize = 100; private static EnumHashEntry GetEnumHashEntry(Type enumType) @@ -3656,6 +3658,7 @@ private class PSMethodToDelegateConverter private readonly int _matchIndex; // Size of the cache. It's rare to have more than 10 overloads for a method. private const int CacheSize = 10; + private static readonly PSMethodToDelegateConverter[] s_converterCache = new PSMethodToDelegateConverter[CacheSize]; private PSMethodToDelegateConverter(int matchIndex) diff --git a/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs b/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs index 870c564244b..6ec64a4cf0f 100644 --- a/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs +++ b/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs @@ -158,6 +158,7 @@ static ExportVisitor() } private readonly bool _forCompletion; + internal List DiscoveredExports { get; set; } internal List DiscoveredModules { get; set; } internal Dictionary DiscoveredFunctions { get; set; } diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 27c3af3fc60..2c4396de1c4 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -926,6 +926,7 @@ private bool InitShouldLogPipelineExecutionDetail() /// the cmdlet. Semantically this is equivalent to : cmd | % { $pipelineVariable = $_; (...) } /// internal string PipelineVariable { get; set; } + private PSVariable _pipelineVarReference = null; internal void SetupOutVariable() diff --git a/src/System.Management.Automation/engine/MshMemberInfo.cs b/src/System.Management.Automation/engine/MshMemberInfo.cs index 4079669d94b..6a51580922f 100644 --- a/src/System.Management.Automation/engine/MshMemberInfo.cs +++ b/src/System.Management.Automation/engine/MshMemberInfo.cs @@ -173,6 +173,7 @@ public abstract class PSMemberInfo { internal object instance; internal string name; + internal bool ShouldSerialize { get; set; } internal virtual void ReplicateInstance(object particularInstance) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 78e907af5c0..78db2ca952a 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -39,6 +39,7 @@ public class PSVersionInfo internal const string PSOSName = "OS"; internal const string SerializationVersionName = "SerializationVersion"; internal const string WSManStackVersionName = "WSManStackVersion"; + private static readonly PSVersionHashTable s_psVersionTable; /// @@ -429,6 +430,7 @@ public sealed class SemanticVersion : IComparable, IComparable, private const string PreLabelPropertyName = "PSSemVerPreReleaseLabel"; private const string BuildLabelPropertyName = "PSSemVerBuildLabel"; private const string TypeNameForVersionWithLabel = "System.Version#IncludeLabel"; + private string versionString; /// diff --git a/src/System.Management.Automation/engine/SpecialVariables.cs b/src/System.Management.Automation/engine/SpecialVariables.cs index fb6a762dfe6..5c4c4ba2f49 100644 --- a/src/System.Management.Automation/engine/SpecialVariables.cs +++ b/src/System.Management.Automation/engine/SpecialVariables.cs @@ -21,190 +21,247 @@ namespace System.Management.Automation internal static class SpecialVariables { internal const string HistorySize = "MaximumHistoryCount"; + internal static readonly VariablePath HistorySizeVarPath = new VariablePath(HistorySize); internal const string MyInvocation = "MyInvocation"; + internal static readonly VariablePath MyInvocationVarPath = new VariablePath(MyInvocation); internal const string OFS = "OFS"; + internal static readonly VariablePath OFSVarPath = new VariablePath(OFS); internal const string OutputEncoding = "OutputEncoding"; + internal static readonly VariablePath OutputEncodingVarPath = new VariablePath(OutputEncoding); internal const string VerboseHelpErrors = "VerboseHelpErrors"; + internal static readonly VariablePath VerboseHelpErrorsVarPath = new VariablePath(VerboseHelpErrors); #region Logging Variables internal const string LogEngineHealthEvent = "LogEngineHealthEvent"; + internal static readonly VariablePath LogEngineHealthEventVarPath = new VariablePath(LogEngineHealthEvent); internal const string LogEngineLifecycleEvent = "LogEngineLifecycleEvent"; + internal static readonly VariablePath LogEngineLifecycleEventVarPath = new VariablePath(LogEngineLifecycleEvent); internal const string LogCommandHealthEvent = "LogCommandHealthEvent"; + internal static readonly VariablePath LogCommandHealthEventVarPath = new VariablePath(LogCommandHealthEvent); internal const string LogCommandLifecycleEvent = "LogCommandLifecycleEvent"; + internal static readonly VariablePath LogCommandLifecycleEventVarPath = new VariablePath(LogCommandLifecycleEvent); internal const string LogProviderHealthEvent = "LogProviderHealthEvent"; + internal static readonly VariablePath LogProviderHealthEventVarPath = new VariablePath(LogProviderHealthEvent); internal const string LogProviderLifecycleEvent = "LogProviderLifecycleEvent"; + internal static readonly VariablePath LogProviderLifecycleEventVarPath = new VariablePath(LogProviderLifecycleEvent); internal const string LogSettingsEvent = "LogSettingsEvent"; + internal static readonly VariablePath LogSettingsEventVarPath = new VariablePath(LogSettingsEvent); internal const string PSLogUserData = "PSLogUserData"; + internal static readonly VariablePath PSLogUserDataPath = new VariablePath(PSLogUserData); #endregion Logging Variables internal const string NestedPromptLevel = "NestedPromptLevel"; + internal static readonly VariablePath NestedPromptCounterVarPath = new VariablePath("global:" + NestedPromptLevel); internal const string CurrentlyExecutingCommand = "CurrentlyExecutingCommand"; + internal static readonly VariablePath CurrentlyExecutingCommandVarPath = new VariablePath(CurrentlyExecutingCommand); internal const string PSBoundParameters = "PSBoundParameters"; + internal static readonly VariablePath PSBoundParametersVarPath = new VariablePath(PSBoundParameters); internal const string Matches = "Matches"; + internal static readonly VariablePath MatchesVarPath = new VariablePath(Matches); internal const string LastExitCode = "LASTEXITCODE"; + internal static readonly VariablePath LastExitCodeVarPath = new VariablePath("global:" + LastExitCode); internal const string PSDebugContext = "PSDebugContext"; + internal static readonly VariablePath PSDebugContextVarPath = new VariablePath(PSDebugContext); internal const string StackTrace = "StackTrace"; + internal static readonly VariablePath StackTraceVarPath = new VariablePath("global:" + StackTrace); internal const string FirstToken = "^"; + internal static readonly VariablePath FirstTokenVarPath = new VariablePath("global:" + FirstToken); internal const string LastToken = "$"; + internal static readonly VariablePath LastTokenVarPath = new VariablePath("global:" + LastToken); internal static bool IsUnderbar(string name) { return name.Length == 1 && name[0] == '_'; } internal const string PSItem = "PSItem"; // simple alias for $_ internal const string Underbar = "_"; + internal static readonly VariablePath UnderbarVarPath = new VariablePath(Underbar); internal const string Question = "?"; + internal static readonly VariablePath QuestionVarPath = new VariablePath(Question); internal const string Args = "args"; + internal static readonly VariablePath ArgsVarPath = new VariablePath("local:" + Args); internal const string This = "this"; + internal static readonly VariablePath ThisVarPath = new VariablePath("this"); internal const string Input = "input"; + internal static readonly VariablePath InputVarPath = new VariablePath("local:" + Input); internal const string PSCmdlet = "PSCmdlet"; + internal static readonly VariablePath PSCmdletVarPath = new VariablePath("PSCmdlet"); internal const string Error = "error"; + internal static readonly VariablePath ErrorVarPath = new VariablePath("global:" + Error); internal const string EventError = "error"; + internal static readonly VariablePath EventErrorVarPath = new VariablePath("script:" + EventError); #if !UNIX internal const string PathExt = "env:PATHEXT"; + internal static readonly VariablePath PathExtVarPath = new VariablePath(PathExt); #endif internal const string PSEmailServer = "PSEmailServer"; + internal static readonly VariablePath PSEmailServerVarPath = new VariablePath(PSEmailServer); internal const string PSDefaultParameterValues = "PSDefaultParameterValues"; + internal static readonly VariablePath PSDefaultParameterValuesVarPath = new VariablePath(PSDefaultParameterValues); internal const string PSScriptRoot = "PSScriptRoot"; + internal static readonly VariablePath PSScriptRootVarPath = new VariablePath(PSScriptRoot); internal const string PSCommandPath = "PSCommandPath"; + internal static readonly VariablePath PSCommandPathVarPath = new VariablePath(PSCommandPath); internal const string PSSenderInfo = "PSSenderInfo"; + internal static readonly VariablePath PSSenderInfoVarPath = new VariablePath(PSSenderInfo); internal const string @foreach = "foreach"; + internal static readonly VariablePath foreachVarPath = new VariablePath("local:" + @foreach); internal const string @switch = "switch"; + internal static readonly VariablePath switchVarPath = new VariablePath("local:" + @switch); internal const string pwd = "PWD"; + internal static VariablePath PWDVarPath = new VariablePath("global:" + pwd); internal const string Null = "null"; + internal static VariablePath NullVarPath = new VariablePath("null"); internal const string True = "true"; + internal static VariablePath TrueVarPath = new VariablePath("true"); internal const string False = "false"; + internal static VariablePath FalseVarPath = new VariablePath("false"); internal const string PSModuleAutoLoading = "PSModuleAutoLoadingPreference"; + internal static VariablePath PSModuleAutoLoadingPreferenceVarPath = new VariablePath("global:" + PSModuleAutoLoading); #region Platform Variables internal const string IsLinux = "IsLinux"; + internal static VariablePath IsLinuxPath = new VariablePath("IsLinux"); internal const string IsMacOS = "IsMacOS"; + internal static VariablePath IsMacOSPath = new VariablePath("IsMacOS"); internal const string IsWindows = "IsWindows"; + internal static VariablePath IsWindowsPath = new VariablePath("IsWindows"); internal const string IsCoreCLR = "IsCoreCLR"; + internal static VariablePath IsCoreCLRPath = new VariablePath("IsCoreCLR"); #endregion #region Preference Variables internal const string DebugPreference = "DebugPreference"; + internal static readonly VariablePath DebugPreferenceVarPath = new VariablePath(DebugPreference); internal const string ErrorActionPreference = "ErrorActionPreference"; + internal static readonly VariablePath ErrorActionPreferenceVarPath = new VariablePath(ErrorActionPreference); internal const string ProgressPreference = "ProgressPreference"; + internal static readonly VariablePath ProgressPreferenceVarPath = new VariablePath(ProgressPreference); internal const string VerbosePreference = "VerbosePreference"; + internal static readonly VariablePath VerbosePreferenceVarPath = new VariablePath(VerbosePreference); internal const string WarningPreference = "WarningPreference"; + internal static readonly VariablePath WarningPreferenceVarPath = new VariablePath(WarningPreference); internal const string WhatIfPreference = "WhatIfPreference"; + internal static readonly VariablePath WhatIfPreferenceVarPath = new VariablePath(WhatIfPreference); internal const string ConfirmPreference = "ConfirmPreference"; + internal static readonly VariablePath ConfirmPreferenceVarPath = new VariablePath(ConfirmPreference); internal const string InformationPreference = "InformationPreference"; + internal static readonly VariablePath InformationPreferenceVarPath = new VariablePath(InformationPreference); #endregion Preference Variables internal const string ErrorView = "ErrorView"; + internal static readonly VariablePath ErrorViewVarPath = new VariablePath(ErrorView); /// /// Shell environment variable. /// internal const string PSSessionConfigurationName = "PSSessionConfigurationName"; + internal static readonly VariablePath PSSessionConfigurationNameVarPath = new VariablePath("global:" + PSSessionConfigurationName); /// @@ -212,6 +269,7 @@ internal static class SpecialVariables /// application name for the connection uri. /// internal const string PSSessionApplicationName = "PSSessionApplicationName"; + internal static readonly VariablePath PSSessionApplicationNameVarPath = new VariablePath("global:" + PSSessionApplicationName); #region AllScope variables created in every session diff --git a/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs b/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs index 6dbf181051a..3867f4773b3 100644 --- a/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs +++ b/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs @@ -12,6 +12,7 @@ namespace System.Management.Automation.Runspaces public sealed partial class TypeTable { private const int ValueFactoryCacheCount = 6; + private static readonly Func>[] s_valueFactoryCache; private static Func> GetValueFactoryBasedOnInitCapacity(int capacity) diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index a188a091e34..6d2ad21b5dc 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -1877,6 +1877,7 @@ internal class PipelineForBatchingChecker : AstVisitor { internal readonly HashSet ValidVariables = new HashSet(StringComparer.OrdinalIgnoreCase); internal readonly HashSet Commands = new HashSet(StringComparer.OrdinalIgnoreCase); + internal ScriptBlockAst ScriptBeingConverted { get; set; } public override AstVisitAction VisitVariableExpression(VariableExpressionAst variableExpressionAst) diff --git a/src/System.Management.Automation/engine/debugger/debugger.cs b/src/System.Management.Automation/engine/debugger/debugger.cs index 0bc4595c390..e93e6092933 100644 --- a/src/System.Management.Automation/engine/debugger/debugger.cs +++ b/src/System.Management.Automation/engine/debugger/debugger.cs @@ -1723,8 +1723,10 @@ internal void Clear() // Runspace debugger integration. private Dictionary _runningRunspaces; + private const int _jobCallStackOffset = 2; private const int _runspaceCallStackOffset = 1; + private bool _preserveUnhandledDebugStopEvent; private ManualResetEventSlim _preserveDebugStopEvent; diff --git a/src/System.Management.Automation/engine/hostifaces/MshHost.cs b/src/System.Management.Automation/engine/hostifaces/MshHost.cs index 356e2adb03f..0c5ef87436f 100644 --- a/src/System.Management.Automation/engine/hostifaces/MshHost.cs +++ b/src/System.Management.Automation/engine/hostifaces/MshHost.cs @@ -41,6 +41,7 @@ public abstract class PSHost /// The powershell spec states that 128 is the maximum nesting depth. /// internal const int MaximumNestedPromptLevel = 128; + internal static bool IsStdOutputRedirected; /// diff --git a/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs index 1f3b857af21..42d225fcde8 100644 --- a/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs @@ -391,7 +391,9 @@ internal void IgnoreCommand(string commandText, InvocationInfo invocation) /// make it to the actual host. /// internal bool TranscribeOnly => Interlocked.CompareExchange(ref _transcribeOnlyCount, 0, 0) != 0; + private int _transcribeOnlyCount = 0; + internal IDisposable SetTranscribeOnly() => new TranscribeOnlyCookie(this); private sealed class TranscribeOnlyCookie : IDisposable { diff --git a/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs b/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs index 58268db59e5..ae97cd8e334 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs @@ -506,6 +506,7 @@ public sealed class RunspacePool : IDisposable private RunspacePoolInternal _internalPool; private object _syncObject = new object(); + private event EventHandler InternalStateChanged = null; private event EventHandler InternalForwardEvent = null; private event EventHandler InternalRunspaceCreated = null; diff --git a/src/System.Management.Automation/engine/interpreter/ControlFlowInstructions.cs b/src/System.Management.Automation/engine/interpreter/ControlFlowInstructions.cs index 1c2523874c1..56aca65df37 100644 --- a/src/System.Management.Automation/engine/interpreter/ControlFlowInstructions.cs +++ b/src/System.Management.Automation/engine/interpreter/ControlFlowInstructions.cs @@ -253,6 +253,7 @@ public override string ToString() internal sealed class GotoInstruction : IndexedBranchInstruction { private const int Variants = 4; + private static readonly GotoInstruction[] s_cache = new GotoInstruction[Variants * CacheSize]; private readonly bool _hasResult; diff --git a/src/System.Management.Automation/engine/interpreter/Interpreter.cs b/src/System.Management.Automation/engine/interpreter/Interpreter.cs index 622364184e0..8afdfe69b3d 100644 --- a/src/System.Management.Automation/engine/interpreter/Interpreter.cs +++ b/src/System.Management.Automation/engine/interpreter/Interpreter.cs @@ -31,6 +31,7 @@ namespace System.Management.Automation.Interpreter internal sealed class Interpreter { internal static readonly object NoValue = new object(); + internal const int RethrowOnReturn = Int32.MaxValue; // zero: sync compilation diff --git a/src/System.Management.Automation/engine/interpreter/Utilities.cs b/src/System.Management.Automation/engine/interpreter/Utilities.cs index 2ea3258120f..baba0a41fa4 100644 --- a/src/System.Management.Automation/engine/interpreter/Utilities.cs +++ b/src/System.Management.Automation/engine/interpreter/Utilities.cs @@ -375,6 +375,7 @@ internal class HybridReferenceDictionary where TKey : class private KeyValuePair[] _keysAndValues; private Dictionary _dict; private int _count; + private const int _arraySize = 10; public HybridReferenceDictionary() diff --git a/src/System.Management.Automation/engine/lang/parserutils.cs b/src/System.Management.Automation/engine/lang/parserutils.cs index d2203f8b90e..083d36454d7 100644 --- a/src/System.Management.Automation/engine/lang/parserutils.cs +++ b/src/System.Management.Automation/engine/lang/parserutils.cs @@ -278,6 +278,7 @@ static ParserOps() private const int _MinCache = -100; private const int _MaxCache = 1000; + private static readonly object[] s_integerCache = new object[_MaxCache - _MinCache]; private static readonly string[] s_chars = new string[255]; internal static readonly object _TrueObject = (object)true; diff --git a/src/System.Management.Automation/engine/parser/Parser.cs b/src/System.Management.Automation/engine/parser/Parser.cs index 845b7f89e47..df95f478075 100644 --- a/src/System.Management.Automation/engine/parser/Parser.cs +++ b/src/System.Management.Automation/engine/parser/Parser.cs @@ -39,6 +39,7 @@ public sealed class Parser private ParseMode _parseMode; internal string _fileName; + internal bool ProduceV2Tokens { get; set; } internal const string VERBATIM_ARGUMENT = "--%"; @@ -8083,6 +8084,7 @@ public override string ToString() internal class ParserEventSource : EventSource { internal static ParserEventSource Log = new ParserEventSource(); + internal const int MaxScriptLengthToLog = 50; public void ParseStart(string FileName, int Length) { WriteEvent(1, FileName, Length); } diff --git a/src/System.Management.Automation/engine/parser/SafeValues.cs b/src/System.Management.Automation/engine/parser/SafeValues.cs index d91ec35356d..37320de83d1 100644 --- a/src/System.Management.Automation/engine/parser/SafeValues.cs +++ b/src/System.Management.Automation/engine/parser/SafeValues.cs @@ -64,6 +64,7 @@ internal bool IsAstSafe(Ast ast) // This is a check of the number of visits private uint _visitCount = 0; + private const uint MaxVisitCount = 5000; private const int MaxHashtableKeyCount = 500; diff --git a/src/System.Management.Automation/engine/parser/VariableAnalysis.cs b/src/System.Management.Automation/engine/parser/VariableAnalysis.cs index 4cae1d361d2..f7140bba50c 100644 --- a/src/System.Management.Automation/engine/parser/VariableAnalysis.cs +++ b/src/System.Management.Automation/engine/parser/VariableAnalysis.cs @@ -353,6 +353,7 @@ private class Block internal object _visitData; internal bool _throws; internal bool _returns; + internal bool _unreachable { get; private set; } // Only Entry block, that can be constructed via NewEntryBlock() is reachable initially. diff --git a/src/System.Management.Automation/engine/parser/ast.cs b/src/System.Management.Automation/engine/parser/ast.cs index 8877109a51c..79bee88fc41 100644 --- a/src/System.Management.Automation/engine/parser/ast.cs +++ b/src/System.Management.Automation/engine/parser/ast.cs @@ -58,6 +58,7 @@ internal interface IParameterMetadataProvider IEnumerable GetExperimentalAttributes(); bool UsesCmdletBinding(); + ReadOnlyCollection Parameters { get; } ScriptBlockAst Body { get; } @@ -6931,6 +6932,7 @@ internal DynamicKeyword Keyword } private DynamicKeyword _keyword; + internal Token LCurly { get; set; } internal Token FunctionName { get; set; } internal ExpressionAst InstanceName { get; set; } diff --git a/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs b/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs index 5ae081bc3a7..092eb224e04 100644 --- a/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs +++ b/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs @@ -924,10 +924,12 @@ private void HandleRobustConnectionNotification( protected bool stopCalled = false; protected PSHost hostToUse; protected RemoteRunspacePoolInternal runspacePool; + protected const string WRITE_DEBUG_LINE = "WriteDebugLine"; protected const string WRITE_VERBOSE_LINE = "WriteVerboseLine"; protected const string WRITE_WARNING_LINE = "WriteWarningLine"; protected const string WRITE_PROGRESS = "WriteProgress"; + protected bool initialized = false; /// /// This queue is for the state change events that resulted in closing the underlying diff --git a/src/System.Management.Automation/engine/remoting/client/Job2.cs b/src/System.Management.Automation/engine/remoting/client/Job2.cs index 7b972cf5a1a..11eb30437d7 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job2.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job2.cs @@ -502,9 +502,11 @@ public sealed class ContainerParentJob : Job2 #region Private Members private const string TraceClassName = "ContainerParentJob"; + private bool _moreData = true; private readonly object _syncObject = new object(); private int _isDisposed = 0; + private const int DisposedTrue = 1; private const int DisposedFalse = 0; // This variable is set to true if atleast one child job failed. diff --git a/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs b/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs index a6ad69843cc..21a1cb94016 100644 --- a/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs +++ b/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs @@ -448,6 +448,7 @@ private void childJob_ResultsAdded(object sender, DataAddedEventArgs e) private readonly object _alreadyWroteFlowControlBuffersHighMemoryUsageWarningLock = new object(); private bool _alreadyWroteFlowControlBuffersHighMemoryUsageWarning; + private const long FlowControlBuffersHighMemoryUsageThreshold = 30000; private void WriteWarningAboutHighUsageOfFlowControlBuffers(long currentCount) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 3a7d1e5a9e4..24a79df1299 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -2787,6 +2787,7 @@ function ExtractPluginProperties([string]$pluginDir, $objectToWriteTo) "; private const string MODULEPATH = "ModulesToImport"; + private static readonly ScriptBlock s_getPluginSb; #endregion diff --git a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs index 86734f85fc4..bd7729acbd4 100644 --- a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs @@ -2003,6 +2003,7 @@ private void PreProcessStreamObject(PSStreamObject streamObject) private bool _inputStreamClosed = false; private const string InProcParameterSet = "InProcess"; + private PSDataCollection _input = new PSDataCollection(); private bool _needToCollect = false; private bool _needToStartSteppablePipelineOnServer = false; diff --git a/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs b/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs index 963259b91ff..c96f974763d 100644 --- a/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs @@ -18,42 +18,52 @@ public class WSManConfigurationOption : PSTransportOption private const string QuotasToken = ""; internal const string AttribOutputBufferingMode = "OutputBufferingMode"; + internal static System.Management.Automation.Runspaces.OutputBufferingMode? DefaultOutputBufferingMode = System.Management.Automation.Runspaces.OutputBufferingMode.Block; private System.Management.Automation.Runspaces.OutputBufferingMode? _outputBufferingMode = null; private const string AttribProcessIdleTimeout = "ProcessIdleTimeoutSec"; + internal static readonly int? DefaultProcessIdleTimeout_ForPSRemoting = 0; // in seconds private int? _processIdleTimeoutSec = null; internal const string AttribMaxIdleTimeout = "MaxIdleTimeoutms"; + internal static readonly int? DefaultMaxIdleTimeout = int.MaxValue; private int? _maxIdleTimeoutSec = null; internal const string AttribIdleTimeout = "IdleTimeoutms"; + internal static readonly int? DefaultIdleTimeout = 7200; // 2 hours in seconds private int? _idleTimeoutSec = null; private const string AttribMaxConcurrentUsers = "MaxConcurrentUsers"; + internal static readonly int? DefaultMaxConcurrentUsers = int.MaxValue; private int? _maxConcurrentUsers = null; private const string AttribMaxProcessesPerSession = "MaxProcessesPerShell"; + internal static readonly int? DefaultMaxProcessesPerSession = int.MaxValue; private int? _maxProcessesPerSession = null; private const string AttribMaxMemoryPerSessionMB = "MaxMemoryPerShellMB"; + internal static readonly int? DefaultMaxMemoryPerSessionMB = int.MaxValue; private int? _maxMemoryPerSessionMB = null; private const string AttribMaxSessions = "MaxShells"; + internal static readonly int? DefaultMaxSessions = int.MaxValue; private int? _maxSessions = null; private const string AttribMaxSessionsPerUser = "MaxShellsPerUser"; + internal static readonly int? DefaultMaxSessionsPerUser = int.MaxValue; private int? _maxSessionsPerUser = null; private const string AttribMaxConcurrentCommandsPerSession = "MaxConcurrentCommandsPerShell"; + internal static readonly int? DefaultMaxConcurrentCommandsPerSession = int.MaxValue; private int? _maxConcurrentCommandsPerSession = null; diff --git a/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs b/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs index ef9236f5bfd..0abb3c24837 100644 --- a/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs +++ b/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs @@ -673,6 +673,7 @@ public virtual PSSessionOption SessionOption } private PSSessionOption _sessionOption; + internal const string DEFAULT_SESSION_OPTION = "PSSessionOption"; // Quota related variables. diff --git a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs index 1ae89dfd4ef..2485b857752 100644 --- a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs +++ b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs @@ -232,6 +232,7 @@ public int OpenTimeout } private int _openTimeout = DefaultOpenTimeout; + internal const int DefaultOpenTimeout = 3 * 60 * 1000; // 3 minutes internal const int DefaultTimeout = -1; internal const int InfiniteTimeout = 0; @@ -1645,6 +1646,7 @@ public sealed class NamedPipeConnectionInfo : RunspaceConnectionInfo private PSCredential _credential; private AuthenticationMechanism _authMechanism; private string _appDomainName = string.Empty; + private const int _defaultOpenTimeout = 60000; /* 60 seconds. */ #endregion @@ -2704,6 +2706,7 @@ public sealed class VMConnectionInfo : RunspaceConnectionInfo private AuthenticationMechanism _authMechanism; private PSCredential _credential; + private const int _defaultOpenTimeout = 20000; /* 20 seconds. */ #endregion @@ -2833,6 +2836,7 @@ public sealed class ContainerConnectionInfo : RunspaceConnectionInfo private AuthenticationMechanism _authMechanism; private PSCredential _credential; + private const int _defaultOpenTimeout = 20000; /* 20 seconds. */ #endregion diff --git a/src/System.Management.Automation/engine/remoting/common/fragmentor.cs b/src/System.Management.Automation/engine/remoting/common/fragmentor.cs index 72feecefdc9..2ebe434ea04 100644 --- a/src/System.Management.Automation/engine/remoting/common/fragmentor.cs +++ b/src/System.Management.Automation/engine/remoting/common/fragmentor.cs @@ -467,6 +467,7 @@ internal class SerializedDataStream : Stream, IDisposable /// true if data represents EndFragment of an object. /// internal delegate void OnDataAvailableCallback(byte[] data, bool isEndFragment); + private OnDataAvailableCallback _onDataAvailableCallback; #endregion diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs index eefe68521b7..4c3961748eb 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs @@ -1309,6 +1309,7 @@ internal abstract class HyperVSocketClientSessionTransportManagerBase : OutOfPro #region Data protected RemoteSessionHyperVSocketClient _client; + private const string _threadName = "HyperVSocketTransport Reader Thread"; #endregion @@ -1576,6 +1577,7 @@ internal sealed class SSHClientSessionTransportManager : OutOfProcessClientSessi private StreamReader _stdOutReader; private StreamReader _stdErrReader; private bool _connectionEstablished; + private const string _threadName = "SSHTransport Reader Thread"; #endregion @@ -1986,6 +1988,7 @@ internal sealed class NamedPipeClientSessionTransportManager : NamedPipeClientSe #region Private Data private NamedPipeConnectionInfo _connectionInfo; + private const string _threadName = "NamedPipeTransport Reader Thread"; #endregion @@ -2053,6 +2056,7 @@ internal sealed class ContainerNamedPipeClientSessionTransportManager : NamedPip #region Private Data private ContainerConnectionInfo _connectionInfo; + private const string _threadName = "ContainerNamedPipeTransport Reader Thread"; #endregion diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs index fca6eb12a51..7d10fd0e4b1 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs @@ -23,7 +23,9 @@ internal static class WSManNativeApi internal const string ResourceURIPrefix = @"http://schemas.microsoft.com/powershell/"; internal const string NoProfile = "WINRS_NOPROFILE"; internal const string CodePage = "WINRS_CODEPAGE"; + internal static readonly Version WSMAN_STACK_VERSION = new Version(3, 0); + internal const int WSMAN_FLAG_REQUESTED_API_VERSION_1_1 = 1; // WSMan's default max env size in V2 internal const int WSMAN_DEFAULT_MAX_ENVELOPE_SIZE_KB_V2 = 150; diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index fddf9235bd6..78bf52e195c 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -4969,6 +4969,7 @@ static PSGetMemberBinder() internal int _version; private bool _hasInstanceMember; + internal bool HasInstanceMember { get { return _hasInstanceMember; } } internal static void SetHasInstanceMember(string memberName) diff --git a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs index 5ffa9cf1af4..bde7a04e9b4 100644 --- a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs +++ b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs @@ -283,6 +283,7 @@ bool IsScriptBlockInFactASafeHashtable() // We delay parsing scripts loaded on startup, so we save the text. private string _scriptText; + internal IParameterMetadataProvider Ast { get => _ast ?? DelayParseScriptText(); } private IParameterMetadataProvider _ast; @@ -324,6 +325,7 @@ private IParameterMetadataProvider DelayParseScriptText() internal Action UnoptimizedEndBlock { get; set; } internal IScriptExtent[] SequencePoints { get; set; } + private RuntimeDefinedParameterDictionary _runtimeDefinedParameterDictionary; private Attribute[] _attributes; private bool _usesCmdletBinding; @@ -331,6 +333,7 @@ private IParameterMetadataProvider DelayParseScriptText() private bool _compiledUnoptimized; private bool _hasSuspiciousContent; private bool? _isProductCode; + internal bool DebuggerHidden { get; set; } internal bool DebuggerStepThrough { get; set; } internal Guid Id { get; private set; } diff --git a/src/System.Management.Automation/engine/runtime/MutableTuple.cs b/src/System.Management.Automation/engine/runtime/MutableTuple.cs index 2982cdf53d6..c9055e2edc1 100644 --- a/src/System.Management.Automation/engine/runtime/MutableTuple.cs +++ b/src/System.Management.Automation/engine/runtime/MutableTuple.cs @@ -30,6 +30,7 @@ namespace System.Management.Automation internal abstract class MutableTuple { private const int MaxSize = 128; + private static readonly Dictionary s_sizeDict = new Dictionary(); private int _size; diff --git a/src/System.Management.Automation/help/HelpCommentsParser.cs b/src/System.Management.Automation/help/HelpCommentsParser.cs index 62cbfdd9557..77347527ab4 100644 --- a/src/System.Management.Automation/help/HelpCommentsParser.cs +++ b/src/System.Management.Automation/help/HelpCommentsParser.cs @@ -70,6 +70,7 @@ private HelpCommentsParser(CommandInfo commandInfo, List parameterDescri internal static readonly string mamlURI = "http://schemas.microsoft.com/maml/2004/10"; internal static readonly string commandURI = "http://schemas.microsoft.com/maml/dev/command/2004/10"; internal static readonly string devURI = "http://schemas.microsoft.com/maml/dev/2004/10"; + private const string directive = @"^\s*\.(\w+)(\s+(\S.*))?\s*$"; private const string blankline = @"^\s*$"; // Although "http://msh" is the default namespace, it still must be explicitly qualified with non-empty prefix, diff --git a/src/System.Management.Automation/namespaces/FileSystemContentStream.cs b/src/System.Management.Automation/namespaces/FileSystemContentStream.cs index fc60be64a41..5ee65158233 100644 --- a/src/System.Management.Automation/namespaces/FileSystemContentStream.cs +++ b/src/System.Management.Automation/namespaces/FileSystemContentStream.cs @@ -56,7 +56,9 @@ internal class FileSystemContentReaderWriter : IContentReader, IContentWriter private StreamReader _reader; private StreamWriter _writer; private bool _usingByteEncoding; + private const char DefaultDelimiter = '\n'; + private string _delimiter = $"{DefaultDelimiter}"; private int[] _offsetDictionary; private bool _usingDelimiter; @@ -1156,6 +1158,7 @@ internal FileStreamBackReader(FileStream fileStream, Encoding encoding) private readonly Encoding _defaultAnsiEncoding; private const int BuffSize = 4096; + private readonly byte[] _byteBuff = new byte[BuffSize]; private readonly char[] _charBuff = new char[BuffSize]; private int _byteCount = 0; diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 081e51228b6..3516013f9a5 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -8679,6 +8679,7 @@ internal static void SetZoneOfOrigin(string path, SecurityZone securityZone) internal static class NativeMethods { internal const int ERROR_HANDLE_EOF = 38; + internal enum StreamInfoLevels { FindStreamInfoStandard = 0 } [DllImport(PinvokeDllNames.CreateFileDllName, CharSet = CharSet.Unicode, SetLastError = true)] @@ -8750,6 +8751,7 @@ internal static class CopyFileRemoteUtils #region PSCopyToSessionHelper internal const string PSCopyToSessionHelperName = @"PSCopyToSessionHelper"; + private static string s_driveMaxSizeErrorFormatString = FileSystemProviderStrings.DriveMaxSizeError; private static string s_PSCopyToSessionHelperDefinition = StringUtil.Format(PSCopyToSessionHelperDefinitionFormat, @"[ValidateNotNullOrEmpty()]", s_driveMaxSizeErrorFormatString); private static string s_PSCopyToSessionHelperDefinitionRestricted = StringUtil.Format(PSCopyToSessionHelperDefinitionFormat, @"[ValidateUserDrive()]", s_driveMaxSizeErrorFormatString); @@ -9216,6 +9218,7 @@ function PSCreateDirectoryOnRemoteSession #region PSCopyFromSessionHelper internal const string PSCopyFromSessionHelperName = @"PSCopyFromSessionHelper"; + private static string s_PSCopyFromSessionHelperDefinition = StringUtil.Format(PSCopyFromSessionHelperDefinitionFormat, @"[ValidateNotNullOrEmpty()]"); private static string s_PSCopyFromSessionHelperDefinitionRestricted = StringUtil.Format(PSCopyFromSessionHelperDefinitionFormat, @"[ValidateUserDrive()]"); private const string PSCopyFromSessionHelperDefinitionFormat = @" @@ -9705,6 +9708,7 @@ PSGetPathDirAndFiles @params #region PSCopyRemoteUtils internal const string PSCopyRemoteUtilsName = @"PSCopyRemoteUtils"; + internal static string PSCopyRemoteUtilsDefinition = StringUtil.Format(PSCopyRemoteUtilsDefinitionFormat, @"[ValidateNotNullOrEmpty()]", PSValidatePathFunction); private static string s_PSCopyRemoteUtilsDefinitionRestricted = StringUtil.Format(PSCopyRemoteUtilsDefinitionFormat, @"[ValidateUserDrive()]", PSValidatePathFunction); private const string PSCopyRemoteUtilsDefinitionFormat = @" diff --git a/src/System.Management.Automation/namespaces/RegistryWrapper.cs b/src/System.Management.Automation/namespaces/RegistryWrapper.cs index 13f451a539c..6f0c3e3d66f 100644 --- a/src/System.Management.Automation/namespaces/RegistryWrapper.cs +++ b/src/System.Management.Automation/namespaces/RegistryWrapper.cs @@ -30,11 +30,13 @@ internal interface IRegistryWrapper object GetValue(string name); object GetValue(string name, object defaultValue, RegistryValueOptions options); RegistryValueKind GetValueKind(string name); + object RegistryKey { get; } void SetAccessControl(ObjectSecurity securityDescriptor); ObjectSecurity GetAccessControl(AccessControlSections includeSections); void Close(); + string Name { get; } int SubKeyCount { get; } diff --git a/src/System.Management.Automation/utils/ParserException.cs b/src/System.Management.Automation/utils/ParserException.cs index 098617d0fdd..22010873d9f 100644 --- a/src/System.Management.Automation/utils/ParserException.cs +++ b/src/System.Management.Automation/utils/ParserException.cs @@ -15,6 +15,7 @@ namespace System.Management.Automation public class ParseException : RuntimeException { private const string errorIdString = "Parse"; + private ParseError[] _errors; /// diff --git a/src/System.Management.Automation/utils/PsUtils.cs b/src/System.Management.Automation/utils/PsUtils.cs index b27f6f7e149..50fafe53c91 100644 --- a/src/System.Management.Automation/utils/PsUtils.cs +++ b/src/System.Management.Automation/utils/PsUtils.cs @@ -566,6 +566,7 @@ internal class CRC32Hash { // CRC-32C polynomial representations private const uint polynomial = 0x1EDC6F41; + private static uint[] table; static CRC32Hash() diff --git a/src/System.Management.Automation/utils/StringUtil.cs b/src/System.Management.Automation/utils/StringUtil.cs index 5b87d106f5c..03bd41816e2 100644 --- a/src/System.Management.Automation/utils/StringUtil.cs +++ b/src/System.Management.Automation/utils/StringUtil.cs @@ -66,6 +66,7 @@ internal static // Typical padding is at most a screen's width, any more than that and we won't bother caching. private const int IndentCacheMax = 120; + private static readonly string[] IndentCache = new string[IndentCacheMax]; internal static string Padding(int countOfSpaces) { @@ -84,6 +85,7 @@ internal static string Padding(int countOfSpaces) } private const int DashCacheMax = 120; + private static readonly string[] DashCache = new string[DashCacheMax]; internal static string DashPadding(int count) { diff --git a/src/System.Management.Automation/utils/tracing/TracingGen.cs b/src/System.Management.Automation/utils/tracing/TracingGen.cs index 09b712714ae..ea369e4513a 100644 --- a/src/System.Management.Automation/utils/tracing/TracingGen.cs +++ b/src/System.Management.Automation/utils/tracing/TracingGen.cs @@ -36,6 +36,7 @@ public sealed partial class Tracer : System.Management.Automation.Tracing.EtwAct /// Keyword all. /// public const long KeywordAll = 0xFFFFFFFF; + private static Guid providerId = Guid.Parse("a0c1853b-5c40-4b15-8766-3cf1c58f985a"); private static EventDescriptor WriteTransferEventEvent; private static EventDescriptor DebugMessageEvent; diff --git a/test/xUnit/csharp/test_PSConfiguration.cs b/test/xUnit/csharp/test_PSConfiguration.cs index 4bc38bdcfb4..45e057bea75 100644 --- a/test/xUnit/csharp/test_PSConfiguration.cs +++ b/test/xUnit/csharp/test_PSConfiguration.cs @@ -18,6 +18,7 @@ namespace PSTests.Sequential public class PowerShellPolicyFixture : IDisposable { private const string ConfigFileName = "powershell.config.json"; + private readonly string systemWideConfigFile; private readonly string currentUserConfigFile; From 684429831947fc7f7212633d41b6ddf978acd70f Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Thu, 28 May 2020 05:27:02 +0100 Subject: [PATCH 2/2] Add empty line between declarations RCS0010 --- .../CimCommandBase.cs | 1 + .../CimSessionProxy.cs | 3 ++ .../NewCimSessionOptionCommand.cs | 2 ++ .../Utils.cs | 2 ++ .../GetCounterCommand.cs | 2 ++ .../cimSupport/cmdletization/cim/QueryJob.cs | 1 + .../cmdletization/cim/cimChildJobBase.cs | 2 ++ .../cim/cimCmdletDefinitionContext.cs | 3 ++ .../commands/management/Process.cs | 3 ++ .../commands/utility/AddMember.cs | 1 + .../commands/utility/Compare-Object.cs | 3 ++ .../FormatAndOutput/format-hex/Format-Hex.cs | 1 + .../utility/ImplicitRemotingCommands.cs | 8 +++++ .../commands/utility/ImportAliasCommand.cs | 1 + .../commands/utility/Update-TypeData.cs | 1 + .../WebCmdlet/CoreCLR/HttpKnownHeaderNames.cs | 1 + .../WindowsTaskbarJumpList/ComInterfaces.cs | 24 +++++++++++++ .../host/msh/ConsoleControl.cs | 1 + .../host/msh/ConsoleHostUserInterface.cs | 1 + .../DotNetCode/Eventing/EventDescriptor.cs | 6 ++++ .../DotNetCode/Eventing/EventProvider.cs | 4 +++ .../Eventing/UnsafeNativeMethods.cs | 36 +++++++++++++++++++ .../security/CertificateProvider.cs | 2 ++ .../ConfigProvider.cs | 1 + .../WSManInstance.cs | 1 + .../CoreCLR/CorePsAssemblyLoadContext.cs | 1 + .../DscSupport/CimDSCParser.cs | 2 ++ .../displayDescriptionData_Table.cs | 1 + .../displayDescriptionData_Wide.cs | 1 + .../common/Utilities/MshParameter.cs | 1 + .../cimSupport/cmdletization/ScriptWriter.cs | 1 + .../engine/COM/ComInvoker.cs | 25 +++++++++++++ .../CommandCompletion/CommandCompletion.cs | 1 + .../CommandCompletion/CompletionCompleters.cs | 4 +++ .../engine/CommandMetadata.cs | 1 + .../engine/CommandProcessor.cs | 1 + .../engine/CommandProcessorBase.cs | 2 ++ .../engine/CoreAdapter.cs | 7 ++++ .../engine/DataStoreAdapter.cs | 1 + .../engine/DataStoreAdapterProvider.cs | 1 + .../engine/ErrorPackage.cs | 1 + .../engine/EventManager.cs | 1 + .../engine/InitialSessionState.cs | 2 ++ .../engine/InternalCommands.cs | 1 + .../engine/LanguagePrimitives.cs | 1 + .../engine/Modules/ImportModuleCommand.cs | 1 + .../engine/Modules/RemoteDiscoveryHelper.cs | 2 ++ .../engine/MshObject.cs | 2 ++ .../engine/NativeCommand.cs | 1 + .../engine/NativeCommandProcessor.cs | 4 +++ .../engine/PSVersionInfo.cs | 1 + .../engine/ParameterBinderBase.cs | 3 ++ .../engine/ReflectionParameterBinder.cs | 1 + .../engine/ScriptCommandProcessor.cs | 1 + .../engine/SessionStateScope.cs | 1 + .../engine/ShellVariable.cs | 1 + .../engine/Utils.cs | 2 ++ .../engine/debugger/debugger.cs | 1 + .../engine/hostifaces/Connection.cs | 1 + .../engine/hostifaces/InformationalRecord.cs | 1 + .../engine/hostifaces/LocalPipeline.cs | 1 + .../engine/hostifaces/MshHostUserInterface.cs | 3 ++ .../engine/interpreter/InterpretedFrame.cs | 1 + .../engine/lang/parserutils.cs | 2 ++ .../engine/parser/Compiler.cs | 13 +++++++ .../engine/parser/PSType.cs | 3 ++ .../engine/parser/SemanticChecks.cs | 3 ++ .../engine/parser/VariableAnalysis.cs | 3 ++ .../engine/parser/ast.cs | 12 +++++++ .../engine/parser/tokenizer.cs | 2 ++ .../engine/pipeline.cs | 2 ++ .../engine/regex.cs | 1 + .../engine/remoting/client/Job.cs | 1 + .../engine/remoting/client/Job2.cs | 3 ++ .../remoting/client/RemotingProtocol2.cs | 1 + .../engine/remoting/client/ThrottlingJob.cs | 5 +++ .../engine/remoting/client/remoterunspace.cs | 1 + .../client/remotingprotocolimplementation.cs | 1 + .../remoting/commands/CustomShellCommands.cs | 9 +++++ .../engine/remoting/commands/ReceiveJob.cs | 1 + .../engine/remoting/commands/RemoveJob.cs | 1 + .../engine/remoting/commands/StopJob.cs | 1 + .../remoting/commands/newrunspacecommand.cs | 1 + .../fanin/InitialSessionStateProvider.cs | 3 ++ .../engine/remoting/fanin/WSManNativeAPI.cs | 26 ++++++++++++++ .../remoting/fanin/WSManPluginFacade.cs | 1 + .../remoting/fanin/WSManPluginShellSession.cs | 1 + .../remoting/fanin/WSManTransportManager.cs | 9 +++++ .../server/ServerRemotingProtocol2.cs | 1 + .../server/ServerRunspacePoolDriver.cs | 1 + .../server/serverremotesessionstatemachine.cs | 1 + .../engine/runtime/Binding/Binders.cs | 2 ++ .../engine/runtime/CompiledScriptBlock.cs | 2 ++ .../engine/runtime/MutableTuple.cs | 1 + .../engine/scriptparameterbinder.cs | 1 + .../engine/serialization.cs | 2 ++ .../help/UpdatableHelpSystem.cs | 1 + .../namespaces/FileSystemProvider.cs | 15 ++++++++ .../security/SecuritySupport.cs | 1 + .../security/nativeMethods.cs | 20 +++++++++++ .../security/wldpNativeMethods.cs | 1 + .../config/MshConsoleLoadException.cs | 1 + .../utils/EncodingUtils.cs | 1 + .../utils/IObjectWriter.cs | 3 ++ .../utils/MshInvalidOperationException.cs | 1 + .../utils/PlatformInvokes.cs | 5 +++ .../utils/PsUtils.cs | 1 + .../utils/ResourceManagerCache.cs | 1 + .../utils/RuntimeException.cs | 1 + .../utils/StringUtil.cs | 2 ++ 110 files changed, 366 insertions(+) diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs index 6420fe28909..d39bbc6c4ce 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs @@ -703,6 +703,7 @@ protected virtual void DisposeInternal() /// Whether at begin process time, false means in processrecord. /// private bool atBeginProcess = true; + internal bool AtBeginProcess { get diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs index a8e4fcd977f..cd319d242d3 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs @@ -1066,6 +1066,7 @@ private static void AddShowComputerNameMarker(object o) #if DEBUG private static bool isCliXmlTestabilityHookActive = GetIsCliXmlTestabilityHookActive(); + private static bool GetIsCliXmlTestabilityHookActive() { return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CDXML_CLIXML_TEST")); @@ -1514,6 +1515,7 @@ internal CimInstance TargetCimInstance /// Flag controls whether session object should be closed or not. /// private bool isTemporaryCimSession; + internal bool IsTemporaryCimSession { get @@ -2260,6 +2262,7 @@ protected override bool PreNewActionEvent(CmdletActionEventArgs args) #region private members private CimNewCimInstance newCimInstance = null; + internal CimNewCimInstance NewCimInstanceOperation { get diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimSessionOptionCommand.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimSessionOptionCommand.cs index be3d9aeb350..6184e7cb9ab 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimSessionOptionCommand.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/NewCimSessionOptionCommand.cs @@ -18,8 +18,10 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets public enum ProtocolType { Default, + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] Dcom, + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] Wsman }; diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs index 03bf6ce61d4..76ba5c12a49 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs @@ -141,6 +141,7 @@ internal static class DebugHelper /// Flag used to control generating log message into file. /// private static bool generateLog = true; + internal static bool GenerateLog { get { return generateLog; } @@ -157,6 +158,7 @@ internal static bool GenerateLog /// Flag used to control generating message into powershell. /// private static bool generateVerboseMessage = true; + internal static bool GenerateVerboseMessage { get { return generateVerboseMessage; } diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs index 566ae6d1d22..1c5da218afc 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs @@ -90,6 +90,7 @@ public string[] Counter @"\memory\cache faults/sec", @"\physicaldisk(_total)\% disk time", @"\physicaldisk(_total)\current disk queue length"}; + private bool _defaultCounters = true; private List _accumulatedCounters = new List(); @@ -117,6 +118,7 @@ public int SampleInterval // MaxSamples parameter // private const Int64 KEEP_ON_SAMPLING = -1; + [Parameter( ParameterSetName = "GetCounterSet", ValueFromPipeline = false, diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/QueryJob.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/QueryJob.cs index 2570f13cdf5..4297c00616c 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/QueryJob.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/QueryJob.cs @@ -18,6 +18,7 @@ internal class QueryInstancesJob : QueryJobBase { private readonly string _wqlQuery; private readonly bool _useEnumerateInstances; + internal QueryInstancesJob(CimJobContext jobContext, CimQuery cimQuery, string wqlCondition) : base(jobContext, cimQuery) { diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs index 8dab2f95540..3743d1965f0 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs @@ -168,6 +168,7 @@ public virtual void OnCompleted() private const int MinRetryDelayMs = 100; private Timer _sleepAndRetryTimer; + private void SleepAndRetry_OnWakeup(object state) { this.ExceptionSafeWrapper( @@ -533,6 +534,7 @@ internal CimOperationOptions CreateOperationOptions() private readonly Lazy _jobSpecificCustomOptions; internal abstract CimCustomOptionsDictionary CalculateJobSpecificCustomOptions(); + private CimCustomOptionsDictionary GetJobSpecificCustomOptions() { return _jobSpecificCustomOptions.Value; diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs index 5d70edc986e..6fa40516322 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs @@ -39,6 +39,7 @@ internal CimCmdletDefinitionContext( private const string QueryLanguageKey = "QueryDialect"; private bool? _useEnumerateInstancesInsteadOfWql; + public bool UseEnumerateInstancesInsteadOfWql { get @@ -113,6 +114,7 @@ public bool ClientSideShouldProcess private Uri _resourceUri; private bool _resourceUriHasBeenCalculated; + public Uri ResourceUri { get @@ -141,6 +143,7 @@ public bool SkipTestConnection } private CimOperationFlags? _schemaConformanceLevel; + public CimOperationFlags SchemaConformanceLevel { get diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index b17dfa02058..3a23322fff2 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -2776,6 +2776,7 @@ internal class SECURITY_ATTRIBUTES public int nLength; public SafeLocalMemHandle lpSecurityDescriptor; public bool bInheritHandle; + public SECURITY_ATTRIBUTES() { this.nLength = 12; @@ -2801,6 +2802,7 @@ internal SafeLocalMemHandle(IntPtr existingHandle, bool ownsHandle) [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport(PinvokeDllNames.LocalFreeDllName)] private static extern IntPtr LocalFree(IntPtr hMem); + protected override bool ReleaseHandle() { return (LocalFree(base.handle) == IntPtr.Zero); @@ -2828,6 +2830,7 @@ internal class STARTUPINFO public SafeFileHandle hStdInput; public SafeFileHandle hStdOutput; public SafeFileHandle hStdError; + public STARTUPINFO() { this.lpReserved = IntPtr.Zero; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddMember.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddMember.cs index 9bbde6cac81..2ea6d6e20ae 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddMember.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddMember.cs @@ -21,6 +21,7 @@ namespace Microsoft.PowerShell.Commands public class AddMemberCommand : PSCmdlet { private static readonly object s_notSpecified = new object(); + private static bool HasBeenSpecified(object obj) { return !System.Object.ReferenceEquals(obj, s_notSpecified); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Compare-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Compare-Object.cs index ae6e48180e5..5a1b944792d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Compare-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Compare-Object.cs @@ -99,10 +99,13 @@ public SwitchParameter PassThru #region Internal private List _referenceEntries; + private readonly List _referenceEntryBacklog = new List(); + private readonly List _differenceEntryBacklog = new List(); + private OrderByProperty _orderByProperty = null; private OrderByPropertyComparer _comparer = null; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs index 3a4a43fa205..a0225c8ea6a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs @@ -280,6 +280,7 @@ private void ProcessString(string originalString) } private static readonly Random _idGenerator = new Random(); + private static string GetGroupLabel(Type inputType) => string.Format("{0} ({1}) <{2:X8}>", inputType.Name, inputType.FullName, _idGenerator.Next()); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs index a1bc3762fcb..2e1d8988496 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs @@ -794,6 +794,7 @@ private ErrorRecord GetErrorNoResultsFromRemoteEnd(string commandName) } private List _commandsSkippedBecauseOfShadowing = new List(); + private void ReportSkippedCommands() { if (_commandsSkippedBecauseOfShadowing.Count != 0) @@ -825,6 +826,7 @@ private bool IsCommandNameMatchingParameters(string commandName) } private Dictionary _existingCommands; + private Dictionary ExistingCommands { get @@ -2119,6 +2121,7 @@ function Write-PSImplicitRemotingMessage try { & $script:WriteHost -Object $message -ErrorAction SilentlyContinue } catch { } } "; + private void GenerateHelperFunctionsWriteMessage(TextWriter writer) { if (writer == null) @@ -2173,6 +2176,7 @@ function Set-PSImplicitRemotingSession if ($PSSessionOverride) {{ Set-PSImplicitRemotingSession $PSSessionOverride }} "; + private void GenerateHelperFunctionsSetImplicitRunspace(TextWriter writer) { if (writer == null) @@ -2204,6 +2208,7 @@ function Get-PSImplicitRemotingSessionOption }} }} "; + private void GenerateHelperFunctionsGetSessionOption(TextWriter writer) { if (writer == null) @@ -2434,6 +2439,7 @@ private void GenerateHelperFunctionsGetImplicitRunspace(TextWriter writer) }} -ErrorAction SilentlyContinue }} catch {{ }} "; + private string GenerateReimportingOfModules() { StringBuilder result = new StringBuilder(); @@ -2543,6 +2549,7 @@ private string GenerateNewRunspaceExpression() private const string ComputerNameParameterTemplate = @"-ComputerName '{0}' ` -ApplicationName '{1}' {2} {3} "; + private const string VMIdParameterTemplate = @"-VMId '{0}' "; private const string ContainerIdParameterTemplate = @"-ContainerId '{0}' "; @@ -2748,6 +2755,7 @@ function Get-PSImplicitRemotingClientSideParameters return $clientSideParameters } "; + private void GenerateHelperFunctionsClientSideParameters(TextWriter writer) { if (writer == null) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImportAliasCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImportAliasCommand.cs index c4b4a9d3d4e..3da62e88d25 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImportAliasCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImportAliasCommand.cs @@ -225,6 +225,7 @@ protected override void ProcessRecord() } private Dictionary _existingCommands; + private Dictionary ExistingCommands { get diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Update-TypeData.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Update-TypeData.cs index 817c4306b44..de7d2590176 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Update-TypeData.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Update-TypeData.cs @@ -29,6 +29,7 @@ public class UpdateTypeDataCommand : UpdateData private const string TypeDataSet = "TypeDataSet"; private static object s_notSpecified = new object(); + private static bool HasBeenSpecified(object obj) { return !System.Object.ReferenceEquals(obj, s_notSpecified); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/HttpKnownHeaderNames.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/HttpKnownHeaderNames.cs index 30ad227c7aa..80d07a54ddf 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/HttpKnownHeaderNames.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/HttpKnownHeaderNames.cs @@ -79,6 +79,7 @@ internal static class HttpKnownHeaderNames #endregion Known_HTTP_Header_Names private static HashSet s_contentHeaderSet = null; + internal static HashSet ContentHeaders { get diff --git a/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/ComInterfaces.cs b/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/ComInterfaces.cs index 82b3756d32b..761c6f6e26f 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/ComInterfaces.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/ComInterfaces.cs @@ -56,39 +56,52 @@ void GetPath( int cchMaxPath, IntPtr pfd, uint fFlags); + void GetIDList(out IntPtr ppidl); void SetIDList(IntPtr pidl); + void GetDescription( [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxName); + void SetDescription( [MarshalAs(UnmanagedType.LPWStr)] string pszName); + void GetWorkingDirectory( [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath ); + void SetWorkingDirectory( [MarshalAs(UnmanagedType.LPWStr)] string pszDir); + void GetArguments( [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath); + void SetArguments( [MarshalAs(UnmanagedType.LPWStr)] string pszArgs); + void GetHotKey(out short wHotKey); void SetHotKey(short wHotKey); void GetShowCmd(out uint iShowCmd); void SetShowCmd(uint iShowCmd); + void GetIconLocation( [Out(), MarshalAs(UnmanagedType.LPWStr)] out StringBuilder pszIconPath, int cchIconPath, out int iIcon); + void SetIconLocation( [MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon); + void SetRelativePath( [MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, uint dwReserved); + void Resolve(IntPtr hwnd, uint fFlags); + void SetPath( [MarshalAs(UnmanagedType.LPWStr)] string pszFile); } @@ -151,26 +164,34 @@ internal interface ICustomDestinationList { void SetAppID( [MarshalAs(UnmanagedType.LPWStr)] string pszAppID); + [PreserveSig] HResult BeginList( out uint cMaxSlots, ref Guid riid, [Out(), MarshalAs(UnmanagedType.Interface)] out object ppvObject); + [PreserveSig] HResult AppendCategory( [MarshalAs(UnmanagedType.LPWStr)] string pszCategory, [MarshalAs(UnmanagedType.Interface)] IObjectArray poa); + void AppendKnownCategory( [MarshalAs(UnmanagedType.I4)] KnownDestinationCategory category); + [PreserveSig] HResult AddUserTasks( [MarshalAs(UnmanagedType.Interface)] IObjectArray poa); + void CommitList(); + void GetRemovedDestinations( ref Guid riid, [Out(), MarshalAs(UnmanagedType.Interface)] out object ppvObject); + void DeleteList( [MarshalAs(UnmanagedType.LPWStr)] string pszAppID); + void AbortList(); } @@ -186,6 +207,7 @@ internal enum KnownDestinationCategory internal interface IObjectArray { void GetCount(out uint cObjects); + void GetAt( uint iIndex, ref Guid riid, @@ -208,8 +230,10 @@ void GetAt( // IObjectCollection void AddObject( [MarshalAs(UnmanagedType.Interface)] object pvObject); + void AddFromArray( [MarshalAs(UnmanagedType.Interface)] IObjectArray poaSource); + void RemoveObject(uint uiIndex); void Clear(); } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs index 6d027620718..6159e349497 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs @@ -136,6 +136,7 @@ internal struct CONSOLE_FONT_INFO_EX internal short FontHeight; internal int FontFamily; internal int FontWeight; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] internal string FontFace; } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs index e896674728b..817fc620480 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs @@ -2130,6 +2130,7 @@ private CommandCompletion GetNewCompletionResults(string input) } private const string CustomReadlineCommand = "PSConsoleHostReadLine"; + private bool TryInvokeUserDefinedReadLine(out string input) { // We're using GetCommands instead of GetCommand so we don't auto-load a module should the command exist, but isn't loaded. diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventDescriptor.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventDescriptor.cs index 7cfef28f7e5..34fa9105085 100644 --- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventDescriptor.cs +++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventDescriptor.cs @@ -12,16 +12,22 @@ public struct EventDescriptor { [FieldOffset(0)] private ushort _id; + [FieldOffset(2)] private byte _version; + [FieldOffset(3)] private byte _channel; + [FieldOffset(4)] private byte _level; + [FieldOffset(5)] private byte _opcode; + [FieldOffset(6)] private ushort _task; + [FieldOffset(8)] private long _keywords; diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProvider.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProvider.cs index 1d2038b5bf1..a1eba143e28 100644 --- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProvider.cs +++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProvider.cs @@ -14,6 +14,7 @@ public class EventProvider : IDisposable { [SecurityCritical] private UnsafeNativeMethods.EtwEnableCallback _etwCallback; // Trace Callback function + private long _regHandle; // Trace Registration Handle private byte _level; // Tracing Level private long _anyKeywordMask; // Trace Enable Flags @@ -24,6 +25,7 @@ public class EventProvider : IDisposable [ThreadStatic] private static WriteEventErrorCode t_returnCode; // thread slot to keep last error + [ThreadStatic] private static Guid t_activityId; @@ -48,8 +50,10 @@ private struct EventData { [FieldOffset(0)] internal ulong DataPointer; + [FieldOffset(8)] internal uint Size; + [FieldOffset(12)] internal int Reserved; } diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs index 23b867e8696..5da8809897d 100644 --- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs +++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/UnsafeNativeMethods.cs @@ -240,18 +240,25 @@ internal struct SystemTime { [MarshalAs(UnmanagedType.U2)] public short Year; + [MarshalAs(UnmanagedType.U2)] public short Month; + [MarshalAs(UnmanagedType.U2)] public short DayOfWeek; + [MarshalAs(UnmanagedType.U2)] public short Day; + [MarshalAs(UnmanagedType.U2)] public short Hour; + [MarshalAs(UnmanagedType.U2)] public short Minute; + [MarshalAs(UnmanagedType.U2)] public short Second; + [MarshalAs(UnmanagedType.U2)] public short Milliseconds; } @@ -262,50 +269,73 @@ internal struct EvtVariant { [FieldOffset(0)] public UInt32 UInteger; + [FieldOffset(0)] public Int32 Integer; + [FieldOffset(0)] public byte UInt8; + [FieldOffset(0)] public short Short; + [FieldOffset(0)] public ushort UShort; + [FieldOffset(0)] public UInt32 Bool; + [FieldOffset(0)] public byte ByteVal; + [FieldOffset(0)] public byte SByte; + [FieldOffset(0)] public UInt64 ULong; + [FieldOffset(0)] public Int64 Long; + [FieldOffset(0)] public Single Single; + [FieldOffset(0)] public double Double; + [FieldOffset(0)] public IntPtr StringVal; + [FieldOffset(0)] public IntPtr AnsiString; + [FieldOffset(0)] public IntPtr SidVal; + [FieldOffset(0)] public IntPtr Binary; + [FieldOffset(0)] public IntPtr Reference; + [FieldOffset(0)] public IntPtr Handle; + [FieldOffset(0)] public IntPtr GuidReference; + [FieldOffset(0)] public UInt64 FileTime; + [FieldOffset(0)] public IntPtr SystemTime; + [FieldOffset(0)] public IntPtr SizeT; + [FieldOffset(8)] public UInt32 Count; // number of elements (not length) in bytes. + [FieldOffset(12)] public UInt32 Type; } @@ -494,12 +524,16 @@ internal struct EvtRpcLogin { [MarshalAs(UnmanagedType.LPWStr)] public string Server; + [MarshalAs(UnmanagedType.LPWStr)] public string User; + [MarshalAs(UnmanagedType.LPWStr)] public string Domain; + [SecurityCritical] public CoTaskMemUnicodeSafeHandle Password; + public int Flags; } @@ -826,8 +860,10 @@ internal struct EvtStringVariant { [MarshalAs(UnmanagedType.LPWStr), FieldOffset(0)] public string StringVal; + [FieldOffset(8)] public UInt32 Count; + [FieldOffset(12)] public UInt32 Type; }; diff --git a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs index 1b541b87fcc..6e524eff3de 100644 --- a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs +++ b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs @@ -565,6 +565,7 @@ public sealed class CertificateProvider : NavigationCmdletProvider, ICmdletProvi /// this property. /// private static Regex s_certPathRegex = null; + private static Regex CertPathRegex { get @@ -3093,6 +3094,7 @@ public static void WriteSendAsTrustedIssuerProperty(X509Certificate2 cert, strin } private static readonly char[] s_separators = new char[] { '/', '\\' }; + private static string[] GetPathElements(string path) { string[] allElts = path.Split(s_separators); diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 9ded9e76f04..a5b62bc6cb9 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -5446,6 +5446,7 @@ enum WsManElementObjectTypes #region def private static readonly string[] WinrmRootName = new string[] { "winrm/Config" }; + private static readonly string[] WinRmRootConfigs = new string[] { "Client", "Service", diff --git a/src/Microsoft.WSMan.Management/WSManInstance.cs b/src/Microsoft.WSMan.Management/WSManInstance.cs index fabac20ec78..e740fc45632 100644 --- a/src/Microsoft.WSMan.Management/WSManInstance.cs +++ b/src/Microsoft.WSMan.Management/WSManInstance.cs @@ -398,6 +398,7 @@ public SwitchParameter UseSSL # region private WSManHelper helper; + private string GetFilter() { string name; diff --git a/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs b/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs index ef210304ae9..293c3599267 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs @@ -113,6 +113,7 @@ private PowerShellAssemblyLoadContext(string basePaths) // - Value: strong name of the TPA that contains the type represented by Key. private readonly Dictionary _coreClrTypeCatalog; private readonly Lazy> _availableDotNetAssemblyNames; + private readonly HashSet _denyListedAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase){ "System.Windows.Forms" }; diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs index 908025c14e2..be547213afa 100644 --- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs +++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs @@ -656,6 +656,7 @@ private static HashSet ScriptKeywordFileCache /// [ThreadStatic] private static bool t_cacheResourcesFromMultipleModuleVersions; + private static bool CacheResourcesFromMultipleModuleVersions { get @@ -3712,6 +3713,7 @@ private static ScriptBlock CimKeywordImplementationFunction } private static ScriptBlock s_cimKeywordImplementationFunction; + private const string CimKeywordImplementationFunctionText = @" param ( [Parameter(Mandatory)] diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs index ddd8446b065..b9d1e897068 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs @@ -547,6 +547,7 @@ public TableControlBuilder EndRowDefinition() public sealed class TableControlBuilder { internal readonly TableControl _table; + internal TableControlBuilder(TableControl table) { _table = table; diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs index 0e140fa5eea..05e3e79923b 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs @@ -259,6 +259,7 @@ internal bool CompatibleWithOldPowerShell() public sealed class WideControlBuilder { private readonly WideControl _control; + internal WideControlBuilder(WideControl control) { _control = control; diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameter.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameter.cs index 15aecfacc8f..c9d509abeef 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameter.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameter.cs @@ -32,6 +32,7 @@ internal object GetEntry(string key) internal class NameEntryDefinition : HashtableEntryDefinition { internal const string NameEntryKey = "name"; + internal NameEntryDefinition() : base(NameEntryKey, new string[] { FormatParameterDefinitionKeys.LabelEntryKey }, new Type[] { typeof(string) }, false) { diff --git a/src/System.Management.Automation/cimSupport/cmdletization/ScriptWriter.cs b/src/System.Management.Automation/cimSupport/cmdletization/ScriptWriter.cs index f14eae396f8..3757319c9ab 100644 --- a/src/System.Management.Automation/cimSupport/cmdletization/ScriptWriter.cs +++ b/src/System.Management.Automation/cimSupport/cmdletization/ScriptWriter.cs @@ -2101,6 +2101,7 @@ private void WriteGetCmdlet(TextWriter output) } private static object s_enumCompilationLock = new object(); + private static void CompileEnum(EnumMetadataEnum enumMetadata) { try diff --git a/src/System.Management.Automation/engine/COM/ComInvoker.cs b/src/System.Management.Automation/engine/COM/ComInvoker.cs index 4e0d083c118..3834be3de8e 100644 --- a/src/System.Management.Automation/engine/COM/ComInvoker.cs +++ b/src/System.Management.Automation/engine/COM/ComInvoker.cs @@ -352,12 +352,16 @@ internal struct TypeUnion { [FieldOffset(0)] internal ushort _vt; + [FieldOffset(2)] internal ushort _wReserved1; + [FieldOffset(4)] internal ushort _wReserved2; + [FieldOffset(6)] internal ushort _wReserved3; + [FieldOffset(8)] internal UnionTypes _unionTypes; } @@ -374,46 +378,67 @@ internal struct UnionTypes { [FieldOffset(0)] internal sbyte _i1; + [FieldOffset(0)] internal Int16 _i2; + [FieldOffset(0)] internal Int32 _i4; + [FieldOffset(0)] internal Int64 _i8; + [FieldOffset(0)] internal byte _ui1; + [FieldOffset(0)] internal UInt16 _ui2; + [FieldOffset(0)] internal UInt32 _ui4; + [FieldOffset(0)] internal UInt64 _ui8; + [FieldOffset(0)] internal Int32 _int; + [FieldOffset(0)] internal UInt32 _uint; + [FieldOffset(0)] internal Int16 _bool; + [FieldOffset(0)] internal Int32 _error; + [FieldOffset(0)] internal Single _r4; + [FieldOffset(0)] internal double _r8; + [FieldOffset(0)] internal Int64 _cy; + [FieldOffset(0)] internal double _date; + [FieldOffset(0)] internal IntPtr _bstr; + [FieldOffset(0)] internal IntPtr _unknown; + [FieldOffset(0)] internal IntPtr _dispatch; + [FieldOffset(0)] internal IntPtr _pvarVal; + [FieldOffset(0)] internal IntPtr _byref; + [FieldOffset(0)] internal Record _record; } diff --git a/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs b/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs index e4c253e9ddd..7af3fb62fb4 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs @@ -56,6 +56,7 @@ public CommandCompletion(Collection matches, int currentMatchI public Collection CompletionMatches { get; set; } internal static readonly IList EmptyCompletionResult = Array.Empty(); + private static readonly CommandCompletion s_emptyCommandCompletion = new CommandCompletion( new Collection(EmptyCompletionResult), -1, -1, -1); diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs index 7ff17435001..e00302a1eb4 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs @@ -208,6 +208,7 @@ List ExecuteGetCommandCommand(bool useModulePrefix) private static readonly HashSet s_keywordsToExcludeFromAddingAmpersand = new HashSet(StringComparer.OrdinalIgnoreCase) { nameof(TokenKind.InlineScript), nameof(TokenKind.Configuration) }; + internal static CompletionResult GetCommandNameCompletionResult(string name, object command, bool addAmpersandIfNecessary, string quote) { string syntax = name, listItem = name; @@ -4505,6 +4506,7 @@ private struct SHARE_INFO_1 private const int ERROR_MORE_DATA = 234; private const int STYPE_DISKTREE = 0; private const int STYPE_MASK = 0x000000FF; + private static System.IO.EnumerationOptions _enumerationOptions = new System.IO.EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive, @@ -4580,6 +4582,7 @@ public static IEnumerable CompleteVariable(string variableName } private static readonly string[] s_variableScopes = new string[] { "Global:", "Local:", "Script:", "Private:" }; + private static readonly char[] s_charactersRequiringQuotes = new char[] { '-', '`', '&', '@', '\'', '"', '#', '{', '}', '(', ')', '$', ',', ';', '|', '<', '>', ' ', '.', '\\', '/', '\t', '^', }; @@ -5720,6 +5723,7 @@ private class TypeCompletionMapping } private static TypeCompletionMapping[][] s_typeCache; + private static TypeCompletionMapping[][] InitializeTypeCache() { #region Process_TypeAccelerators diff --git a/src/System.Management.Automation/engine/CommandMetadata.cs b/src/System.Management.Automation/engine/CommandMetadata.cs index 5ad657b037f..edcd9a9cd66 100644 --- a/src/System.Management.Automation/engine/CommandMetadata.cs +++ b/src/System.Management.Automation/engine/CommandMetadata.cs @@ -647,6 +647,7 @@ internal uint DefaultParameterSetFlag // The CommandType for a script cmdlet is not CommandTypes.Cmdlet, yet // proxy generation needs to know the difference between script and script cmdlet. private bool _wrappedAnyCmdlet; + internal bool WrappedAnyCmdlet { get { return _wrappedAnyCmdlet; } diff --git a/src/System.Management.Automation/engine/CommandProcessor.cs b/src/System.Management.Automation/engine/CommandProcessor.cs index 48abebc7a17..4433d75ca99 100644 --- a/src/System.Management.Automation/engine/CommandProcessor.cs +++ b/src/System.Management.Automation/engine/CommandProcessor.cs @@ -667,6 +667,7 @@ private bool ProcessInputPipelineObject(object inputObject) } private static readonly ConcurrentDictionary> s_constructInstanceCache; + private static Cmdlet ConstructInstance(Type type) { // Call the default constructor if type derives from Cmdlet. diff --git a/src/System.Management.Automation/engine/CommandProcessorBase.cs b/src/System.Management.Automation/engine/CommandProcessorBase.cs index e2c8ad46e5c..87fd4606c9f 100644 --- a/src/System.Management.Automation/engine/CommandProcessorBase.cs +++ b/src/System.Management.Automation/engine/CommandProcessorBase.cs @@ -156,6 +156,7 @@ internal virtual ObsoleteAttribute ObsoleteAttribute /// The command runtime used for this instance of a command processor. /// protected MshCommandRuntime commandRuntime; + internal MshCommandRuntime CommandRuntime { get { return commandRuntime; } @@ -230,6 +231,7 @@ protected static void ValidateCompatibleLanguageMode( /// The execution context used by the system. /// protected ExecutionContext _context; + internal ExecutionContext Context { get { return _context; } diff --git a/src/System.Management.Automation/engine/CoreAdapter.cs b/src/System.Management.Automation/engine/CoreAdapter.cs index e048fd648ae..2fd5e1868c5 100644 --- a/src/System.Management.Automation/engine/CoreAdapter.cs +++ b/src/System.Management.Automation/engine/CoreAdapter.cs @@ -2080,6 +2080,7 @@ internal class MethodInformation { internal MethodBase method; private string _cachedMethodDefinition; + internal string methodDefinition { get @@ -2557,8 +2558,10 @@ internal class DotNetAdapter : Adapter private const BindingFlags instanceBindingFlags = (BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance); + private const BindingFlags staticBindingFlags = (BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Static); + private bool _isStatic; internal DotNetAdapter() { } @@ -2628,6 +2631,7 @@ internal MethodInformation this[int i] } private bool? _isHidden; + internal override bool IsHidden { get @@ -2982,6 +2986,7 @@ internal SetterDelegate setterDelegate internal Type propertyType; private bool? _isHidden; + internal override bool IsHidden { get @@ -2996,6 +3001,7 @@ internal override bool IsHidden } private AttributeCollection _attributes; + internal AttributeCollection Attributes { get @@ -4751,6 +4757,7 @@ protected override T GetFirstMemberOrDefault(object obj, MemberNamePredicate internal class DotNetAdapterWithComTypeName : DotNetAdapter { private ComTypeInfo _comTypeInfo; + internal DotNetAdapterWithComTypeName(ComTypeInfo comTypeInfo) { _comTypeInfo = comTypeInfo; diff --git a/src/System.Management.Automation/engine/DataStoreAdapter.cs b/src/System.Management.Automation/engine/DataStoreAdapter.cs index 6b9a77f45f7..c7db11bf081 100644 --- a/src/System.Management.Automation/engine/DataStoreAdapter.cs +++ b/src/System.Management.Automation/engine/DataStoreAdapter.cs @@ -817,6 +817,7 @@ public override int GetHashCode() } private PSNoteProperty _noteProperty; + internal PSNoteProperty GetNotePropertyForProviderCmdlets(string name) { if (_noteProperty == null) diff --git a/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs b/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs index cfc7528b90b..f1e798c0edf 100644 --- a/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs +++ b/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs @@ -673,6 +673,7 @@ internal void GetOutputTypes(string cmdletname, List listToAppend) private Dictionary> _providerOutputType; private PSNoteProperty _noteProperty; + internal PSNoteProperty GetNotePropertyForProviderCmdlets(string name) { if (_noteProperty == null) diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index 1f308dc2ecd..fc346e2ee96 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -1470,6 +1470,7 @@ public Exception Exception public object TargetObject { get => _target; } private object _target /* = null */; + internal void SetTargetObject(object target) { _target = target; diff --git a/src/System.Management.Automation/engine/EventManager.cs b/src/System.Management.Automation/engine/EventManager.cs index c2904d61d51..a962f745eac 100644 --- a/src/System.Management.Automation/engine/EventManager.cs +++ b/src/System.Management.Automation/engine/EventManager.cs @@ -641,6 +641,7 @@ private void EnableTimer() #endregion OnIdleProcessing private static Dictionary s_generatedEventHandlers = new Dictionary(); + private void ProcessNewSubscriber(PSEventSubscriber subscriber, object source, string eventName, string sourceIdentifier, PSObject data, bool supportEvent, bool forwardEvent) { Delegate handlerDelegate = null; diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index b69aafe910c..6032259bea6 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4775,6 +4775,7 @@ internal static SessionStateAliasEntry[] BuiltInAliases internal static ScriptBlock SetDriveScriptBlock = ScriptBlock.CreateDelayParsedScriptBlock(DefaultSetDriveFunctionText, isProductCode: true); private static PSLanguageMode systemLanguageMode = (SystemPolicy.GetSystemLockdownPolicy() == SystemEnforcementMode.Enforce) ? PSLanguageMode.ConstrainedLanguage : PSLanguageMode.FullLanguage; + internal static SessionStateFunctionEntry[] BuiltInFunctions = new SessionStateFunctionEntry[] { // Functions that don't require full language mode @@ -4872,6 +4873,7 @@ internal static void RemoveAllDrivesForProvider(ProviderInfo pi, SessionStateInt { "Microsoft.PowerShell.Diagnostics", "Microsoft.PowerShell.Commands.Diagnostics"}, { "Microsoft.PowerShell.Host", "Microsoft.PowerShell.ConsoleHost"}, }; + internal static Dictionary NestedModuleEngineModuleMapping = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "Microsoft.PowerShell.Commands.Utility", "Microsoft.PowerShell.Utility"}, diff --git a/src/System.Management.Automation/engine/InternalCommands.cs b/src/System.Management.Automation/engine/InternalCommands.cs index 348f4b33277..7c37cc4f0eb 100644 --- a/src/System.Management.Automation/engine/InternalCommands.cs +++ b/src/System.Management.Automation/engine/InternalCommands.cs @@ -1963,6 +1963,7 @@ public SwitchParameter Not private readonly CallSite> _toBoolSite = CallSite>.Create(PSConvertBinder.Get(typeof(bool))); + private Func _operationDelegate; private static Func GetCallSiteDelegate(ExpressionType expressionType, bool ignoreCase) diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index e4741126904..83690003bf7 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -5735,6 +5735,7 @@ internal static IConversionData FigureConversion(Type fromType, Type toType) } internal class Null { }; + private static IConversionData FigureConversionFromNull(Type toType) { IConversionData data = GetConversionData(typeof(Null), toType); diff --git a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs index bec87e9a35a..1521edfc702 100644 --- a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs +++ b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs @@ -1709,6 +1709,7 @@ private PSModuleInfo ImportModule_RemotelyViaCimModuleData( #region Cancellation support private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); + private CancellationToken CancellationToken { get diff --git a/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs b/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs index fce9c2e58c8..4a1c50186eb 100644 --- a/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs +++ b/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs @@ -841,12 +841,14 @@ internal static Hashtable RewriteManifest(Hashtable originalManifest) "Description", "HelpInfoURI", }; + private static readonly string[] s_manifestEntriesToKeepAsStringArray = new[] { "FunctionsToExport", "VariablesToExport", "AliasesToExport", "CmdletsToExport", }; + internal static Hashtable RewriteManifest( Hashtable originalManifest, IEnumerable nestedModules, diff --git a/src/System.Management.Automation/engine/MshObject.cs b/src/System.Management.Automation/engine/MshObject.cs index 79824980475..12a677bdd72 100644 --- a/src/System.Management.Automation/engine/MshObject.cs +++ b/src/System.Management.Automation/engine/MshObject.cs @@ -424,6 +424,7 @@ private void CommonInitialization(object obj) #region Adapter Mappings private static readonly ConcurrentDictionary s_adapterMapping = new ConcurrentDictionary(); + private static readonly List> s_adapterSetMappers = new List> { MappedInternalAdapterSet @@ -647,6 +648,7 @@ internal static PSObject ConstructPSObjectFromSerializationInfo(SerializationInf private static readonly AdapterSet s_dotNetInstanceAdapterSet = new AdapterSet(DotNetInstanceAdapter, null); private static readonly AdapterSet s_mshMemberSetAdapter = new AdapterSet(new PSMemberSetAdapter(), null); private static readonly AdapterSet s_mshObjectAdapter = new AdapterSet(new PSObjectAdapter(), null); + private static readonly PSObject.AdapterSet s_cimInstanceAdapter = new PSObject.AdapterSet(new ThirdPartyAdapter(typeof(Microsoft.Management.Infrastructure.CimInstance), new Microsoft.PowerShell.Cim.CimInstanceAdapter()), diff --git a/src/System.Management.Automation/engine/NativeCommand.cs b/src/System.Management.Automation/engine/NativeCommand.cs index 417e257f548..822d4cf82d9 100644 --- a/src/System.Management.Automation/engine/NativeCommand.cs +++ b/src/System.Management.Automation/engine/NativeCommand.cs @@ -11,6 +11,7 @@ namespace System.Management.Automation internal sealed class NativeCommand : InternalCommand { private NativeCommandProcessor _myCommandProcessor; + internal NativeCommandProcessor MyCommandProcessor { get { return _myCommandProcessor; } diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index ef9053faf8f..f4ef83bab88 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -817,6 +817,7 @@ internal struct ProcessWithParentId { public Process OriginalProcessInstance; private int _parentId; + public int ParentId { get @@ -1407,8 +1408,10 @@ private struct SHFILEINFO public IntPtr hIcon; public int iIcon; public uint dwAttributes; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szDisplayName; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] public string szTypeName; }; @@ -2139,6 +2142,7 @@ protected RemoteException(SerializationInfo info, StreamingContext context) [NonSerialized] private PSObject _serializedRemoteException; + [NonSerialized] private PSObject _serializedRemoteInvocationInfo; diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 78db2ca952a..b1cbdf2a1cb 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -351,6 +351,7 @@ internal static SemanticVersion PSCurrentVersion public sealed class PSVersionHashTable : Hashtable, IEnumerable { private static readonly PSVersionTableComparer s_keysComparer = new PSVersionTableComparer(); + internal PSVersionHashTable(IEqualityComparer equalityComparer) : base(equalityComparer) { } diff --git a/src/System.Management.Automation/engine/ParameterBinderBase.cs b/src/System.Management.Automation/engine/ParameterBinderBase.cs index d6ecd705a30..9823c090c48 100644 --- a/src/System.Management.Automation/engine/ParameterBinderBase.cs +++ b/src/System.Management.Automation/engine/ParameterBinderBase.cs @@ -904,6 +904,7 @@ private bool ShouldContinueUncoercedBind( /// The invocation information for the code that is being bound. /// private InvocationInfo _invocationInfo; + internal InvocationInfo InvocationInfo { get @@ -916,6 +917,7 @@ internal InvocationInfo InvocationInfo /// The context of the currently running engine. /// private ExecutionContext _context; + internal ExecutionContext Context { get @@ -928,6 +930,7 @@ internal ExecutionContext Context /// An instance of InternalCommand that the binder is binding to. /// private InternalCommand _command; + internal InternalCommand Command { get diff --git a/src/System.Management.Automation/engine/ReflectionParameterBinder.cs b/src/System.Management.Automation/engine/ReflectionParameterBinder.cs index ed6421ea77d..3e5dcab2502 100644 --- a/src/System.Management.Automation/engine/ReflectionParameterBinder.cs +++ b/src/System.Management.Automation/engine/ReflectionParameterBinder.cs @@ -216,6 +216,7 @@ static ReflectionParameterBinder() private static readonly ConcurrentDictionary, Func> s_getterMethods = new ConcurrentDictionary, Func>(); + private static readonly ConcurrentDictionary, Action> s_setterMethods = new ConcurrentDictionary, Action>(); diff --git a/src/System.Management.Automation/engine/ScriptCommandProcessor.cs b/src/System.Management.Automation/engine/ScriptCommandProcessor.cs index cdba3bad0a2..89e898a5532 100644 --- a/src/System.Management.Automation/engine/ScriptCommandProcessor.cs +++ b/src/System.Management.Automation/engine/ScriptCommandProcessor.cs @@ -66,6 +66,7 @@ protected ScriptCommandProcessorBase(IScriptCommandInfo commandInfo, ExecutionCo protected ScriptBlock _scriptBlock; private ScriptParameterBinderController _scriptParameterBinderController; + internal ScriptParameterBinderController ScriptParameterBinderController { get diff --git a/src/System.Management.Automation/engine/SessionStateScope.cs b/src/System.Management.Automation/engine/SessionStateScope.cs index 382df13dd1d..434d1e0d929 100644 --- a/src/System.Management.Automation/engine/SessionStateScope.cs +++ b/src/System.Management.Automation/engine/SessionStateScope.cs @@ -1711,6 +1711,7 @@ private Dictionary GetAutomountedDrives() private Dictionary _automountedDrives; private Dictionary _variables; + private Dictionary GetPrivateVariables() { if (_variables == null) diff --git a/src/System.Management.Automation/engine/ShellVariable.cs b/src/System.Management.Automation/engine/ShellVariable.cs index fd2b8b34a6d..4be5a96f52b 100644 --- a/src/System.Management.Automation/engine/ShellVariable.cs +++ b/src/System.Management.Automation/engine/ShellVariable.cs @@ -688,6 +688,7 @@ internal virtual void SetValueRaw(object newValue, bool preserveValueTypeSemanti private readonly CallSite> _copyMutableValueSite = CallSite>.Create(PSVariableAssignmentBinder.Get()); + internal object CopyMutableValues(object o) { // The variable assignment binder copies mutable values and returns other values as is. diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index 6d2ad21b5dc..14b7f9d55bf 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -485,6 +485,7 @@ internal static string GetWindowsPowerShellVersionFromRegistry() #endif internal static string DefaultPowerShellAppBase => GetApplicationBase(DefaultPowerShellShellID); + internal static string GetApplicationBase(string shellId) { // Use the location of SMA.dll as the application base. @@ -1826,6 +1827,7 @@ private static void WriteVerbose(PowerShell ps, string msg) } private const string WhereObjectCommandAlias = "?"; + private static bool TryGetCommandInfoList(PowerShell ps, HashSet commandNames, out Collection cmdInfoList) { if (commandNames.Count == 0) diff --git a/src/System.Management.Automation/engine/debugger/debugger.cs b/src/System.Management.Automation/engine/debugger/debugger.cs index e93e6092933..6355b0d83e5 100644 --- a/src/System.Management.Automation/engine/debugger/debugger.cs +++ b/src/System.Management.Automation/engine/debugger/debugger.cs @@ -1072,6 +1072,7 @@ internal override bool IsDebuggerSteppingEnabled } private bool? _isLocalSession; + private bool IsLocalSession { get diff --git a/src/System.Management.Automation/engine/hostifaces/Connection.cs b/src/System.Management.Automation/engine/hostifaces/Connection.cs index fef195ac1a2..a57b2d4a626 100644 --- a/src/System.Management.Automation/engine/hostifaces/Connection.cs +++ b/src/System.Management.Automation/engine/hostifaces/Connection.cs @@ -1672,6 +1672,7 @@ internal SessionStateProxy() } private RunspaceBase _runspace; + internal SessionStateProxy(RunspaceBase runspace) { Dbg.Assert(runspace != null, "Caller should validate the parameter"); diff --git a/src/System.Management.Automation/engine/hostifaces/InformationalRecord.cs b/src/System.Management.Automation/engine/hostifaces/InformationalRecord.cs index c8d997d0808..9325f95ccad 100644 --- a/src/System.Management.Automation/engine/hostifaces/InformationalRecord.cs +++ b/src/System.Management.Automation/engine/hostifaces/InformationalRecord.cs @@ -158,6 +158,7 @@ internal virtual void ToPSObjectForRemoting(PSObject psObject) [DataMember()] private string _message; + private InvocationInfo _invocationInfo; private ReadOnlyCollection _pipelineIterationInfo; private bool _serializeExtendedInfo; diff --git a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs index da0877747de..93cd99d92b6 100644 --- a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs +++ b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs @@ -1320,6 +1320,7 @@ internal PipelineStopper(LocalPipeline localPipeline) /// This is set true when stop is called. /// private bool _stopping; + internal bool IsStopping { get diff --git a/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs index 42d225fcde8..9a321803a19 100644 --- a/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs @@ -395,10 +395,12 @@ internal void IgnoreCommand(string commandText, InvocationInfo invocation) private int _transcribeOnlyCount = 0; internal IDisposable SetTranscribeOnly() => new TranscribeOnlyCookie(this); + private sealed class TranscribeOnlyCookie : IDisposable { private PSHostUserInterface _ui; private bool _disposed = false; + public TranscribeOnlyCookie(PSHostUserInterface ui) { _ui = ui; @@ -952,6 +954,7 @@ internal static TranscriptionOption GetSystemTranscriptOption(TranscriptionOptio internal static TranscriptionOption systemTranscript = null; private static object s_systemTranscriptLock = new object(); + private static Lazy s_transcriptionSettingCache = new Lazy( () => Utils.GetPolicySetting(Utils.SystemWideThenCurrentUserConfig), isThreadSafe: true); diff --git a/src/System.Management.Automation/engine/interpreter/InterpretedFrame.cs b/src/System.Management.Automation/engine/interpreter/InterpretedFrame.cs index 3e15b1fbba4..d4d6923da81 100644 --- a/src/System.Management.Automation/engine/interpreter/InterpretedFrame.cs +++ b/src/System.Management.Automation/engine/interpreter/InterpretedFrame.cs @@ -35,6 +35,7 @@ internal sealed class InterpretedFrame [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")] private int[] _continuations; + private int _continuationIndex; private int _pendingContinuation; private object _pendingValue; diff --git a/src/System.Management.Automation/engine/lang/parserutils.cs b/src/System.Management.Automation/engine/lang/parserutils.cs index 083d36454d7..44eed05e518 100644 --- a/src/System.Management.Automation/engine/lang/parserutils.cs +++ b/src/System.Management.Automation/engine/lang/parserutils.cs @@ -1640,12 +1640,14 @@ internal static object CallMethod( internal class RangeEnumerator : IEnumerator { private int _lowerBound; + internal int LowerBound { get { return _lowerBound; } } private int _upperBound; + internal int UpperBound { get { return _upperBound; } diff --git a/src/System.Management.Automation/engine/parser/Compiler.cs b/src/System.Management.Automation/engine/parser/Compiler.cs index e787c9e9f9b..07e36bcdf75 100644 --- a/src/System.Management.Automation/engine/parser/Compiler.cs +++ b/src/System.Management.Automation/engine/parser/Compiler.cs @@ -169,6 +169,7 @@ internal static class CachedReflectionInfo internal static readonly MethodInfo ExceptionHandlingOps_ConvertToMethodInvocationException = typeof(ExceptionHandlingOps).GetMethod(nameof(ExceptionHandlingOps.ConvertToMethodInvocationException), StaticFlags); + internal static readonly MethodInfo ExceptionHandlingOps_FindMatchingHandler = typeof(ExceptionHandlingOps).GetMethod(nameof(ExceptionHandlingOps.FindMatchingHandler), StaticFlags); @@ -221,14 +222,19 @@ internal static class CachedReflectionInfo internal static readonly FieldInfo FunctionContext__currentSequencePointIndex = typeof(FunctionContext).GetField(nameof(FunctionContext._currentSequencePointIndex), InstanceFlags); + internal static readonly FieldInfo FunctionContext__executionContext = typeof(FunctionContext).GetField(nameof(FunctionContext._executionContext), InstanceFlags); + internal static readonly FieldInfo FunctionContext__functionName = typeof(FunctionContext).GetField(nameof(FunctionContext._functionName), InstanceFlags); + internal static readonly FieldInfo FunctionContext__localsTuple = typeof(FunctionContext).GetField(nameof(FunctionContext._localsTuple), InstanceFlags); + internal static readonly FieldInfo FunctionContext__outputPipe = typeof(FunctionContext).GetField(nameof(FunctionContext._outputPipe), InstanceFlags); + internal static readonly MethodInfo FunctionContext_PopTrapHandlers = typeof(FunctionContext).GetMethod(nameof(FunctionContext.PopTrapHandlers), InstanceFlags); @@ -275,13 +281,16 @@ internal static class CachedReflectionInfo internal static readonly MethodInfo InterpreterError_NewInterpreterException = typeof(InterpreterError).GetMethod(nameof(InterpreterError.NewInterpreterException), StaticFlags); + internal static readonly MethodInfo InterpreterError_NewInterpreterExceptionWithInnerException = typeof(InterpreterError).GetMethod(nameof(InterpreterError.NewInterpreterExceptionWithInnerException), StaticFlags); internal static readonly MethodInfo LanguagePrimitives_GetInvalidCastMessages = typeof(LanguagePrimitives).GetMethod(nameof(LanguagePrimitives.GetInvalidCastMessages), StaticFlags); + internal static readonly MethodInfo LanguagePrimitives_IsNull = typeof(LanguagePrimitives).GetMethod(nameof(LanguagePrimitives.IsNull), StaticFlags); + internal static readonly MethodInfo LanguagePrimitives_ThrowInvalidCastException = typeof(LanguagePrimitives).GetMethod(nameof(LanguagePrimitives.ThrowInvalidCastException), StaticFlags); @@ -455,6 +464,7 @@ internal static class CachedReflectionInfo internal static readonly MethodInfo PSScriptProperty_InvokeGetter = typeof(PSScriptProperty).GetMethod(nameof(PSScriptProperty.InvokeGetter), InstanceFlags); + internal static readonly MethodInfo PSScriptProperty_InvokeSetter = typeof(PSScriptProperty).GetMethod(nameof(PSScriptProperty.InvokeSetter), InstanceFlags); @@ -658,6 +668,7 @@ internal static class ExpressionCache internal static readonly Expression CatchAllType = Expression.Constant(typeof(ExceptionHandlingOps.CatchAll), typeof(Type)); // Empty expression is used at the end of blocks to give them the void expression result internal static readonly Expression Empty = Expression.Empty(); + internal static Expression GetExecutionContextFromTLS = Expression.Call(CachedReflectionInfo.LocalPipeline_GetExecutionContextFromTLS); @@ -804,8 +815,10 @@ internal class Compiler : ICustomAstVisitor2 private static readonly CatchBlock[] s_stmtCatchHandlers; internal static readonly Type DottedLocalsTupleType = MutableTuple.MakeTupleType(SpecialVariables.AutomaticVariableTypes); + internal static readonly Dictionary DottedLocalsNameIndexMap = new Dictionary(SpecialVariables.AutomaticVariableTypes.Length, StringComparer.OrdinalIgnoreCase); + internal static readonly Dictionary DottedScriptCmdletLocalsNameIndexMap = new Dictionary( SpecialVariables.AutomaticVariableTypes.Length + SpecialVariables.PreferenceVariableTypes.Length, diff --git a/src/System.Management.Automation/engine/parser/PSType.cs b/src/System.Management.Automation/engine/parser/PSType.cs index 1feb951d7b4..1064e7a0d10 100644 --- a/src/System.Management.Automation/engine/parser/PSType.cs +++ b/src/System.Management.Automation/engine/parser/PSType.cs @@ -20,11 +20,13 @@ internal class TypeDefiner internal const string DynamicClassAssemblyFullNamePrefix = "PowerShell Class Assembly,"; private static int s_globalCounter = 0; + private static readonly CustomAttributeBuilder s_hiddenCustomAttributeBuilder = new CustomAttributeBuilder(typeof(HiddenAttribute).GetConstructor(Type.EmptyTypes), Array.Empty()); private static readonly string s_sessionStateKeeperFieldName = "__sessionStateKeeper"; internal static readonly string SessionStateFieldName = "__sessionState"; + private static readonly MethodInfo s_sessionStateKeeper_GetSessionState = typeof(SessionStateKeeper).GetMethod("GetSessionState", BindingFlags.Instance | BindingFlags.Public); @@ -1298,6 +1300,7 @@ private static IEnumerable GetAssemblyAttributeBuilders( } private static int counter = 0; + internal static Assembly DefineTypes(Parser parser, Ast rootAst, TypeDefinitionAst[] typeDefinitions) { Diagnostics.Assert(rootAst.Parent == null, "Caller should only define types from the root ast"); diff --git a/src/System.Management.Automation/engine/parser/SemanticChecks.cs b/src/System.Management.Automation/engine/parser/SemanticChecks.cs index 9068a60722b..b7d3bdb8bc8 100644 --- a/src/System.Management.Automation/engine/parser/SemanticChecks.cs +++ b/src/System.Management.Automation/engine/parser/SemanticChecks.cs @@ -18,15 +18,18 @@ namespace System.Management.Automation.Language internal class SemanticChecks : AstVisitor2, IAstPostVisitHandler { private readonly Parser _parser; + private static readonly IsConstantValueVisitor s_isConstantAttributeArgVisitor = new IsConstantValueVisitor { CheckingAttributeArgument = true, }; + private static readonly IsConstantValueVisitor s_isConstantAttributeArgForClassVisitor = new IsConstantValueVisitor { CheckingAttributeArgument = true, CheckingClassAttributeArguments = true }; + private readonly Stack _memberScopeStack; private readonly Stack _scopeStack; diff --git a/src/System.Management.Automation/engine/parser/VariableAnalysis.cs b/src/System.Management.Automation/engine/parser/VariableAnalysis.cs index f7140bba50c..8b0ab3249df 100644 --- a/src/System.Management.Automation/engine/parser/VariableAnalysis.cs +++ b/src/System.Management.Automation/engine/parser/VariableAnalysis.cs @@ -37,6 +37,7 @@ internal VariableAnalysisDetails() internal class FindAllVariablesVisitor : AstVisitor { private static readonly HashSet s_hashOfPessimizingCmdlets = new HashSet(StringComparer.OrdinalIgnoreCase); + private static readonly string[] s_pessimizingCmdlets = new string[] { "New-Variable", @@ -107,6 +108,7 @@ internal static Dictionary Visit(IParameterMeta } private bool _disableOptimizations; + private readonly Dictionary _variables = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -251,6 +253,7 @@ public override AstVisitAction VisitVariableExpression(VariableExpressionAst var } private int _runtimeUsingIndex; + public override AstVisitAction VisitUsingExpression(UsingExpressionAst usingExpressionAst) { // On the local machine, we may have set the index because of a call to ScriptBlockToPowerShell or Invoke-Command. diff --git a/src/System.Management.Automation/engine/parser/ast.cs b/src/System.Management.Automation/engine/parser/ast.cs index 79bee88fc41..be4bfc6b1bc 100644 --- a/src/System.Management.Automation/engine/parser/ast.cs +++ b/src/System.Management.Automation/engine/parser/ast.cs @@ -67,6 +67,7 @@ internal interface IParameterMetadataProvider PowerShell GetPowerShell(ExecutionContext context, Dictionary variables, bool isTrustedInput, bool filterNonUsingVariables, bool? createLocalScope, params object[] args); + string GetWithInputHandlingForInvokeCommand(); /// @@ -694,10 +695,13 @@ public class ScriptRequirements { internal static readonly ReadOnlyCollection EmptySnapinCollection = Utils.EmptyReadOnlyCollection(); + internal static readonly ReadOnlyCollection EmptyAssemblyCollection = Utils.EmptyReadOnlyCollection(); + internal static readonly ReadOnlyCollection EmptyModuleCollection = Utils.EmptyReadOnlyCollection(); + internal static readonly ReadOnlyCollection EmptyEditionCollection = Utils.EmptyReadOnlyCollection(); @@ -761,6 +765,7 @@ public class ScriptBlockAst : Ast, IParameterMetadataProvider { private static readonly ReadOnlyCollection s_emptyAttributeList = Utils.EmptyReadOnlyCollection(); + private static readonly ReadOnlyCollection s_emptyUsingStatementList = Utils.EmptyReadOnlyCollection(); @@ -1604,6 +1609,7 @@ public class ParamBlockAst : Ast { private static readonly ReadOnlyCollection s_emptyAttributeList = Utils.EmptyReadOnlyCollection(); + private static readonly ReadOnlyCollection s_emptyParameterList = Utils.EmptyReadOnlyCollection(); @@ -2001,6 +2007,7 @@ public class AttributeAst : AttributeBaseAst { private static readonly ReadOnlyCollection s_emptyPositionalArguments = Utils.EmptyReadOnlyCollection(); + private static readonly ReadOnlyCollection s_emptyNamedAttributeArguments = Utils.EmptyReadOnlyCollection(); @@ -2515,8 +2522,10 @@ public class TypeDefinitionAst : StatementAst { private static readonly ReadOnlyCollection s_emptyAttributeList = Utils.EmptyReadOnlyCollection(); + private static readonly ReadOnlyCollection s_emptyMembersCollection = Utils.EmptyReadOnlyCollection(); + private static readonly ReadOnlyCollection s_emptyBaseTypesCollection = Utils.EmptyReadOnlyCollection(); @@ -3188,6 +3197,7 @@ public class FunctionMemberAst : MemberAst, IParameterMetadataProvider { private static readonly ReadOnlyCollection s_emptyAttributeList = Utils.EmptyReadOnlyCollection(); + private static readonly ReadOnlyCollection s_emptyParameterList = Utils.EmptyReadOnlyCollection(); @@ -6752,6 +6762,7 @@ private static IEnumerable ConfigurationBuildInParameters } private static List s_configurationBuildInParameters; + private static IEnumerable ConfigurationBuildInParameterAttribAsts { get @@ -6941,6 +6952,7 @@ internal DynamicKeyword Keyword internal string ElementName { get; set; } private PipelineAst _commandCallPipelineAst; + internal PipelineAst GenerateCommandCallPipelineAst() { if (_commandCallPipelineAst != null) diff --git a/src/System.Management.Automation/engine/parser/tokenizer.cs b/src/System.Management.Automation/engine/parser/tokenizer.cs index ba8fdeac87d..3d15ebf4d81 100644 --- a/src/System.Management.Automation/engine/parser/tokenizer.cs +++ b/src/System.Management.Automation/engine/parser/tokenizer.cs @@ -590,6 +590,7 @@ internal class Tokenizer { private static readonly Dictionary s_keywordTable = new Dictionary(StringComparer.OrdinalIgnoreCase); + private static readonly Dictionary s_operatorTable = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -724,6 +725,7 @@ internal Tokenizer(Parser parser) // TODO: use auto-properties when making 'ternary operator' an official feature. private bool _forceEndNumberOnTernaryOpChars; + internal bool ForceEndNumberOnTernaryOpChars { get { return _forceEndNumberOnTernaryOpChars; } diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index e118bce374d..f6c779282a9 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -156,6 +156,7 @@ internal void LogExecutionError(InvocationInfo invocationInfo, ErrorRecord error } private bool _terminatingErrorLogged = false; + internal void LogExecutionException(Exception exception) { _executionFailed = true; @@ -1559,6 +1560,7 @@ internal bool Stopping } private LocalPipeline _localPipeline; + internal LocalPipeline LocalPipeline { get { return _localPipeline; } diff --git a/src/System.Management.Automation/engine/regex.cs b/src/System.Management.Automation/engine/regex.cs index d04c3a98fba..c867f355158 100644 --- a/src/System.Management.Automation/engine/regex.cs +++ b/src/System.Management.Automation/engine/regex.cs @@ -752,6 +752,7 @@ internal class WildcardPatternToRegexParser : WildcardPatternParser private RegexOptions _regexOptions; private const string regexChars = "()[.?*{}^$+|\\"; // ']' is missing on purpose + private static bool IsRegexChar(char ch) { for (int i = 0; i < regexChars.Length; i++) diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs index 1c8daf5630e..814b547b3df 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job.cs @@ -831,6 +831,7 @@ internal virtual void WriteInformation(InformationRecord informationRecord) } private Lazy _parentActivityId; + internal void SetParentActivityIdGetter(Func parentActivityIdGetter) { Dbg.Assert(parentActivityIdGetter != null, "Caller should verify parentActivityIdGetter != null"); diff --git a/src/System.Management.Automation/engine/remoting/client/Job2.cs b/src/System.Management.Automation/engine/remoting/client/Job2.cs index 11eb30437d7..ed9e133059e 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job2.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job2.cs @@ -533,6 +533,7 @@ public sealed class ContainerParentJob : Job2 private readonly PSDataCollection _executionError = new PSDataCollection(); private PSEventManager _eventManager; + internal PSEventManager EventManager { get { return _eventManager; } @@ -545,6 +546,7 @@ internal PSEventManager EventManager } private ManualResetEvent _jobRunning; + private ManualResetEvent JobRunning { get @@ -569,6 +571,7 @@ private ManualResetEvent JobRunning } private ManualResetEvent _jobSuspendedOrAborted; + private ManualResetEvent JobSuspendedOrAborted { get diff --git a/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs b/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs index 852579e0c88..99a21bd90eb 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs @@ -876,6 +876,7 @@ private void HandleSessionCreateCompleted(object sender, CreateCompleteEventArgs private int _maxRunspaces; private PSHost _host; private PSPrimitiveDictionary _applicationArguments; + private Dictionary _associatedPowerShellDSHandlers = new Dictionary(); // data structure handlers of all ClientRemotePowerShell which are diff --git a/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs b/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs index 21a1cb94016..eb3ad0d20f8 100644 --- a/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs +++ b/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs @@ -201,6 +201,7 @@ internal enum ChildJobFlags private bool _ownerWontSubmitNewChildJobs = false; private readonly HashSet _setOfChildJobsThatCanAddMoreChildJobs = new HashSet(); + private bool IsEndOfChildJobs { get @@ -232,6 +233,7 @@ private bool IsThrottlingJobCompleted private int _countOfFailedChildJobs; private int _countOfStoppedChildJobs; private int _countOfSuccessfullyCompletedChildJobs; + private int CountOfFinishedChildJobs { get @@ -318,6 +320,7 @@ internal void AddChildJobAndPotentiallyBlock( } private bool _alreadyDisabledFlowControlForPendingJobsQueue = false; + internal void DisableFlowControlForPendingJobsQueue() { if (!_cmdletMode || _alreadyDisabledFlowControlForPendingJobsQueue) @@ -343,6 +346,7 @@ internal void DisableFlowControlForPendingJobsQueue() } private bool _alreadyDisabledFlowControlForPendingCmdletActionsQueue = false; + internal void DisableFlowControlForPendingCmdletActionsQueue() { if (!_cmdletMode || _alreadyDisabledFlowControlForPendingCmdletActionsQueue) @@ -1154,6 +1158,7 @@ private void ForwardResults(Cmdlet cmdlet) } private bool _stoppedMonitoringAllJobs; + private void StopMonitoringAllJobs() { _cancellationTokenSource.Cancel(); diff --git a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs index 61be515408f..751969d6f82 100644 --- a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs +++ b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs @@ -2946,6 +2946,7 @@ private void CheckRemoteBreakpointManagementSupport(string breakpointCommandName internal class RemoteSessionStateProxy : SessionStateProxy { private RemoteRunspace _runspace; + internal RemoteSessionStateProxy(RemoteRunspace runspace) { Dbg.Assert(runspace != null, "Caller should validate the parameter"); diff --git a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs index 42c50b42035..bfabb23b7b7 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs @@ -17,6 +17,7 @@ internal class ClientRemoteSessionDSHandlerImpl : ClientRemoteSessionDataStructu { [TraceSourceAttribute("CRSDSHdlerImpl", "ClientRemoteSessionDSHandlerImpl")] private static PSTraceSource s_trace = PSTraceSource.GetTracer("CRSDSHdlerImpl", "ClientRemoteSessionDSHandlerImpl"); + private const string resBaseName = "remotingerroridstrings"; private BaseClientSessionTransportManager _transportManager; diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 24a79df1299..dde4422de45 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -271,6 +271,7 @@ function Register-PSSessionConfiguration Register-PSSessionConfiguration -filepath $args[0] -pluginName $args[1] -shouldShowUI $args[2] -force $args[3] -whatif:$args[4] -confirm:$args[5] -restartWSManTarget $args[6] -restartWSManAction $args[7] -restartWSManRequired $args[8] -runAsUserName $args[9] -runAsPassword $args[10] -accessMode $args[11] -isSddlSpecified $args[12] -configTableSddl $args[13] -erroraction $args[14] }} "; + private static readonly ScriptBlock s_newPluginSb; private const string pluginXmlFormat = @" @@ -293,6 +294,7 @@ function Register-PSSessionConfiguration {11} "; + private const string architectureAttribFormat = @" Architecture='{0}'"; @@ -310,6 +312,7 @@ function Register-PSSessionConfiguration private const string initParamFormat = @" {2}"; + private const string privateDataFormat = @"{0}"; private const string securityElementFormat = ""; private const string SessionConfigDataFormat = @"{0}"; @@ -1658,6 +1661,7 @@ internal static string UpdateSDDLUsersWithGroupConditional( } private const string DACLPrefix = "D:"; + private static Collection ParseDACLACEs( string sddl, out string prologue, @@ -2518,6 +2522,7 @@ function Unregister-PSSessionConfiguration Unregister-PSSessionConfiguration -filter $args[0] -whatif:$args[1] -confirm:$args[2] -action $args[3] -targetTemplate $args[4] -shellNotErrMsgFormat $args[5] -force $args[6] -erroraction $args[7] }} "; + private static readonly ScriptBlock s_removePluginSb; private bool _isErrorReported; @@ -2914,6 +2919,7 @@ public sealed class SetPSSessionConfigurationCommand : PSSessionConfigurationCom private const string getCurrentIdleTimeoutmsFormat = @"(Get-Item 'WSMan:\localhost\Plugin\{0}\Quotas\IdleTimeoutms').Value"; private const string getAssemblyNameDataFormat = @"(Get-Item 'WSMan:\localhost\Plugin\{0}\InitializationParameters\assemblyname').Value"; private const string getSessionConfigurationDataSbFormat = @"(Get-Item 'WSMan:\localhost\Plugin\{0}\InitializationParameters\SessionConfigurationData').Value"; + private const string setSessionConfigurationDataSbFormat = @" function Set-SessionConfigurationData([string] $scd) {{ if (test-path 'WSMan:\localhost\Plugin\{0}\InitializationParameters\" + ConfigurationDataFromXML.SESSIONCONFIGTOKEN + @"') @@ -3179,6 +3185,7 @@ function Set-RunAsCredential{{ Set-PSSessionConfiguration $args[0] $args[1] $args[2] $args[3] $args[4] $args[5] $args[6] $args[7] $args[8] $args[9] $args[10] $args[11] "; + private const string initParamFormat = @""; private const string privateDataFormat = @"{0}"; @@ -4497,6 +4504,7 @@ function Disable-PSSessionConfiguration $_ | Disable-PSSessionConfiguration -force $args[0] -whatif:$args[1] -confirm:$args[2] -restartWinRMMessage $args[3] -setEnabledTarget $args[4] -setEnabledAction $args[5] -noServiceRestart $args[6] "; + private static ScriptBlock s_disablePluginSb; #endregion @@ -5127,6 +5135,7 @@ function Disable-PSRemoting Disable-PSRemoting -force:$args[0] -queryForSet $args[1] -captionForSet $args[2] -restartWinRMMessage $args[3] -whatif:$args[4] -confirm:$args[5] "; + private static ScriptBlock s_disableRemotingSb; #endregion Private Data diff --git a/src/System.Management.Automation/engine/remoting/commands/ReceiveJob.cs b/src/System.Management.Automation/engine/remoting/commands/ReceiveJob.cs index d6deb965849..aa804f68691 100644 --- a/src/System.Management.Automation/engine/remoting/commands/ReceiveJob.cs +++ b/src/System.Management.Automation/engine/remoting/commands/ReceiveJob.cs @@ -1493,6 +1493,7 @@ private void WriteResultsForJobsInCollection(List jobs, bool checkForRecurs } private readonly Dictionary _eventArgsWritten = new Dictionary(); + private void WriteJobStateInformation(Job job, JobStateEventArgs args = null) { // at any point there will be only one thread which will have diff --git a/src/System.Management.Automation/engine/remoting/commands/RemoveJob.cs b/src/System.Management.Automation/engine/remoting/commands/RemoveJob.cs index c63e4548e6a..2eed427a6ff 100644 --- a/src/System.Management.Automation/engine/remoting/commands/RemoveJob.cs +++ b/src/System.Management.Automation/engine/remoting/commands/RemoveJob.cs @@ -1013,6 +1013,7 @@ private void HandleStopJobCompleted(object sender, AsyncCompletedEventArgs event private HashSet _pendingJobs = new HashSet(); private readonly ManualResetEvent _waitForJobs = new ManualResetEvent(false); + private readonly Dictionary> _cleanUpActions = new Dictionary>(); diff --git a/src/System.Management.Automation/engine/remoting/commands/StopJob.cs b/src/System.Management.Automation/engine/remoting/commands/StopJob.cs index cdb1da81ed9..7890bdc54f0 100644 --- a/src/System.Management.Automation/engine/remoting/commands/StopJob.cs +++ b/src/System.Management.Automation/engine/remoting/commands/StopJob.cs @@ -253,6 +253,7 @@ var e in private readonly HashSet _pendingJobs = new HashSet(); private readonly ManualResetEvent _waitForJobs = new ManualResetEvent(false); + private readonly Dictionary> _cleanUpActions = new Dictionary>(); diff --git a/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs b/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs index 16f4af800f7..a20b6163495 100644 --- a/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs @@ -1379,6 +1379,7 @@ internal override void StopOperation() // any exceptions thrown on this thread. (ThrottleManager will not respond if it doesn't // get a start/stop complete callback). private List> _internalCallbacks = new List>(); + internal override event EventHandler OperationComplete { add diff --git a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs index 555bc974d1b..9f938ac3d4a 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs @@ -784,8 +784,10 @@ private static string private const string configProvidersKeyName = "PSConfigurationProviders"; private const string configProviderApplicationBaseKeyName = "ApplicationBase"; private const string configProviderAssemblyNameKeyName = "AssemblyName"; + private static Dictionary s_ssnStateProviders = new Dictionary(StringComparer.OrdinalIgnoreCase); + private static object s_syncObject = new object(); #endregion @@ -1786,6 +1788,7 @@ private void MergeRoleRulesIntoConfigHash(Func roleVerifier) // Takes the "RoleCapabilities" node in the config hash, and merges its values into the base configuration. private const string PSRCExtension = ".psrc"; + private void MergeRoleCapabilitiesIntoConfigHash() { List psrcFiles = new List(); diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs index 7d10fd0e4b1..1b1fe2b2163 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs @@ -625,6 +625,7 @@ internal class WSManDataStruct internal class WSManBinaryOrTextDataStruct { internal int bufferLength; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] internal IntPtr data; } @@ -635,8 +636,10 @@ internal class WSManBinaryOrTextDataStruct internal class WSManData_ManToUn : IDisposable { private WSManDataStruct _internalData; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _marshalledObject = IntPtr.Zero; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _marshalledBuffer = IntPtr.Zero; @@ -768,6 +771,7 @@ internal class WSManData_UnToMan /// Gets the type of data. /// private uint _type; + internal uint Type { get { return _type; } @@ -779,6 +783,7 @@ internal uint Type /// Gets the buffer length of data. /// private int _bufferLength; + internal int BufferLength { get { return _bufferLength; } @@ -787,6 +792,7 @@ internal int BufferLength } private string _text; + internal string Text { get @@ -799,6 +805,7 @@ internal string Text } private byte[] _data; + internal byte[] Data { get @@ -929,6 +936,7 @@ private struct WSManDWordDataInternal internal struct WSManStreamIDSetStruct { internal int streamIDsCount; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] internal IntPtr streamIDs; } @@ -1083,6 +1091,7 @@ internal struct WSManOptionSetStruct /// [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] internal IntPtr options; + internal bool optionsMustUnderstand; } @@ -1217,11 +1226,13 @@ internal struct WSManCommandArgSet : IDisposable internal struct WSManCommandArgSetInternal { internal int argsCount; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] internal IntPtr args; } private WSManCommandArgSetInternal _internalData; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private MarshalledObject _data; @@ -1549,6 +1560,7 @@ internal struct WSManEnvironmentVariableInternal { [MarshalAs(UnmanagedType.LPWStr)] internal string name; + [MarshalAs(UnmanagedType.LPWStr)] internal string value; } @@ -1724,6 +1736,7 @@ internal struct WSManShellAsyncCallback { // GC handle which prevents garbage collector from collecting this delegate. private GCHandle _gcHandle; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _asyncCallback; @@ -1961,9 +1974,12 @@ private struct WSManReceiveDataResultInternal { [MarshalAs(UnmanagedType.LPWStr)] internal string streamId; + internal WSManDataStruct data; + [MarshalAs(UnmanagedType.LPWStr)] internal string commandState; + internal int exitCode; } @@ -2068,8 +2084,10 @@ private struct WSManPluginRequestInternal /// WSManSenderDetails. /// internal IntPtr senderDetails; + [MarshalAs(UnmanagedType.LPWStr)] internal string locale; + [MarshalAs(UnmanagedType.LPWStr)] internal string resourceUri; /// @@ -2121,6 +2139,7 @@ private struct WSManSenderDetailsInternal { [MarshalAs(UnmanagedType.LPWStr)] internal string senderName; + [MarshalAs(UnmanagedType.LPWStr)] internal string authenticationMechanism; /// @@ -2128,6 +2147,7 @@ private struct WSManSenderDetailsInternal /// internal IntPtr certificateDetails; internal IntPtr clientToken; + [MarshalAs(UnmanagedType.LPWStr)] internal string httpUrl; } @@ -2170,10 +2190,13 @@ private struct WSManCertificateDetailsInternal { [MarshalAs(UnmanagedType.LPWStr)] internal string subject; + [MarshalAs(UnmanagedType.LPWStr)] internal string issuerName; + [MarshalAs(UnmanagedType.LPWStr)] internal string issuerThumbprint; + [MarshalAs(UnmanagedType.LPWStr)] internal string subjectName; } @@ -2230,6 +2253,7 @@ internal struct WSManFragmentInternal { [MarshalAs(UnmanagedType.LPWStr)] internal string path; + [MarshalAs(UnmanagedType.LPWStr)] internal string dialect; } @@ -2242,6 +2266,7 @@ internal struct WSManFilterInternal { [MarshalAs(UnmanagedType.LPWStr)] internal string filter; + [MarshalAs(UnmanagedType.LPWStr)] internal string dialect; } @@ -2301,6 +2326,7 @@ internal struct WSManKeyStruct { [MarshalAs(UnmanagedType.LPWStr)] internal string key; + [MarshalAs(UnmanagedType.LPWStr)] internal string value; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs index cd77ccedb82..727c8e231ff 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs @@ -170,6 +170,7 @@ internal sealed class WSManPluginEntryDelegates : IDisposable // Holds the delegate pointers in a structure that has identical layout to the native structure. private WSManPluginEntryDelegatesInternal _unmanagedStruct = new WSManPluginEntryDelegatesInternal(); + internal WSManPluginEntryDelegatesInternal UnmanagedStruct { get { return _unmanagedStruct; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index 9574301f415..035288443a2 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -386,6 +386,7 @@ internal void ReportSendOperationComplete() #region Pure virtual methods internal abstract void CloseOperation(WSManPluginOperationShutdownContext context, Exception reasonForClose); + internal abstract void ExecuteConnect( WSManNativeApi.WSManPluginRequest requestDetails, // in int flags, // in diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs index b8e5b127f64..39999788162 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs @@ -321,10 +321,13 @@ internal CompletionEventArgs(CompletionNotification notification) // operation handles are owned by WSMan [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _wsManSessionHandle; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _wsManShellOperationHandle; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _wsManReceiveOperationHandle; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _wsManSendOperationHandle; // this is used with WSMan callbacks to represent a session transport manager. @@ -451,6 +454,7 @@ private void ProcessShellData(string data) // callbacks. private static Dictionary s_sessionTMHandles = new Dictionary(); + private static long s_sessionTMSeed; // generate unique session id private static long GetNextSessionTMHandleId() @@ -2779,12 +2783,16 @@ internal sealed class WSManClientCommandTransportManager : BaseClientCommandTran // operation handles private IntPtr _wsManShellOperationHandle; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _wsManCmdOperationHandle; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _cmdSignalOperationHandle; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _wsManReceiveOperationHandle; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private IntPtr _wsManSendOperationHandle; // this is used with WSMan callbacks to represent a command transport manager. @@ -4110,6 +4118,7 @@ internal override void Dispose(bool isDisposing) // callbacks. private static Dictionary s_cmdTMHandles = new Dictionary(); + private static long s_cmdTMSeed; // Generate command transport manager unique id diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs b/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs index 56d41812a55..5c63ab47008 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs @@ -414,6 +414,7 @@ private void HandleRemoveAssociation(object sender, EventArgs e) // runspace pool driver handles all client // communication private AbstractServerSessionTransportManager _transportManager; + private Dictionary _associatedShells = new Dictionary(); // powershell data structure handlers associated with this diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs index 04f7da23555..13223ae1a41 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs @@ -955,6 +955,7 @@ private void HandleCreateAndInvokePowerShell(object _, RemoteDataEventArgs _processPendingEventsQueue = new Queue(); // whether some thread is actively processing events diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index 78bf52e195c..cc5dcad1805 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -1306,6 +1306,7 @@ internal static PSGetDynamicMemberBinder Get(TypeDefinitionAst classScope, bool private readonly bool _static; private readonly Type _classScope; + private PSGetDynamicMemberBinder(Type classScope, bool @static) { _static = @static; @@ -5024,6 +5025,7 @@ internal static void SetHasInstanceMember(string memberName) } private bool _hasTypeTableMember; + internal static void TypeTableMemberAdded(string memberName) { var binderList = s_binderCacheIgnoringCase.GetOrAdd(memberName, _ => new List()); diff --git a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs index bde7a04e9b4..6f69be4eb49 100644 --- a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs +++ b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs @@ -558,6 +558,7 @@ protected ScriptBlock(SerializationInfo info, StreamingContext context) private static readonly ConcurrentDictionary, ScriptBlock> s_cachedScripts = new ConcurrentDictionary, ScriptBlock>(); + internal static ScriptBlock TryGetCachedScriptBlock(string fileName, string fileContents) { if (InternalTestHooks.IgnoreScriptBlockCache) @@ -1720,6 +1721,7 @@ private static bool GetAndValidateEncryptionRecipients( private static string s_lastSeenCertificate = string.Empty; private static bool s_hasProcessedCertificate = false; private static CmsMessageRecipient[] s_encryptionRecipients = null; + private static Lazy s_sbLoggingSettingCache = new Lazy( () => Utils.GetPolicySetting(Utils.SystemWideThenCurrentUserConfig), isThreadSafe: true); diff --git a/src/System.Management.Automation/engine/runtime/MutableTuple.cs b/src/System.Management.Automation/engine/runtime/MutableTuple.cs index c9055e2edc1..de923e2df8b 100644 --- a/src/System.Management.Automation/engine/runtime/MutableTuple.cs +++ b/src/System.Management.Automation/engine/runtime/MutableTuple.cs @@ -308,6 +308,7 @@ public static int GetSize(Type tupleType) private static readonly ConcurrentDictionary> s_tupleCreators = new ConcurrentDictionary>(concurrencyLevel: 3, capacity: 100); + public static Func TupleCreator(Type type) { return s_tupleCreators.GetOrAdd(type, diff --git a/src/System.Management.Automation/engine/scriptparameterbinder.cs b/src/System.Management.Automation/engine/scriptparameterbinder.cs index 35480a96d3e..c9944678ad8 100644 --- a/src/System.Management.Automation/engine/scriptparameterbinder.cs +++ b/src/System.Management.Automation/engine/scriptparameterbinder.cs @@ -48,6 +48,7 @@ internal ScriptParameterBinder( private readonly CallSite> _copyMutableValueSite = CallSite>.Create(PSVariableAssignmentBinder.Get()); + internal object CopyMutableValues(object o) { // The variable assignment binder copies mutable values and returns other values as is. diff --git a/src/System.Management.Automation/engine/serialization.cs b/src/System.Management.Automation/engine/serialization.cs index 1b17a39a4a7..95af575cc5f 100644 --- a/src/System.Management.Automation/engine/serialization.cs +++ b/src/System.Management.Automation/engine/serialization.cs @@ -1888,6 +1888,7 @@ int depth } private Collection> _extendedMembersCollection; + private Collection> ExtendedMembersCollection { get @@ -1899,6 +1900,7 @@ private Collection> ExtendedMembersCollection } private Collection> _allPropertiesCollection; + private Collection> AllPropertiesCollection { get diff --git a/src/System.Management.Automation/help/UpdatableHelpSystem.cs b/src/System.Management.Automation/help/UpdatableHelpSystem.cs index 6bdac0afaf8..0a45b9a7605 100644 --- a/src/System.Management.Automation/help/UpdatableHelpSystem.cs +++ b/src/System.Management.Automation/help/UpdatableHelpSystem.cs @@ -510,6 +510,7 @@ private string ResolveUri(string baseUri, bool verbose) "; + private const string HelpInfoXmlNamespace = "http://schemas.microsoft.com/powershell/help/2010/05"; private const string HelpInfoXmlValidationFailure = "HelpInfoXmlValidationFailure"; diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 3516013f9a5..67cd105fc40 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -83,6 +83,7 @@ public FileSystemProvider() } private Collection _excludeMatcher = null; + private static System.IO.EnumerationOptions _enumerationOptions = new System.IO.EnumerationOptions { MatchType = MatchType.Win32, @@ -7307,12 +7308,16 @@ private struct NetResource public int Type; public int DisplayType; public int Usage; + [MarshalAs(UnmanagedType.LPWStr)] public string LocalName; + [MarshalAs(UnmanagedType.LPWStr)] public string RemoteName; + [MarshalAs(UnmanagedType.LPWStr)] public string Comment; + [MarshalAs(UnmanagedType.LPWStr)] public string Provider; } @@ -7855,6 +7860,7 @@ private struct REPARSE_DATA_BUFFER_SYMBOLICLINK public ushort PrintNameOffset; public ushort PrintNameLength; public uint Flags; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x3FF0)] public byte[] PathBuffer; } @@ -7869,6 +7875,7 @@ private struct REPARSE_DATA_BUFFER_MOUNTPOINT public ushort SubstituteNameLength; public ushort PrintNameOffset; public ushort PrintNameLength; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x3FF0)] public byte[] PathBuffer; } @@ -7880,6 +7887,7 @@ private struct REPARSE_DATA_BUFFER_APPEXECLINK public ushort ReparseDataLength; public ushort Reserved; public uint StringCount; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x3FF0)] public byte[] StringList; } @@ -7905,6 +7913,7 @@ private struct GUID public uint Data1; public ushort Data2; public ushort Data3; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public char[] Data4; } @@ -7916,6 +7925,7 @@ private struct REPARSE_GUID_DATA_BUFFER public ushort ReparseDataLength; public ushort Reserved; public GUID ReparseGuid; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_REPARSE_SIZE)] public char[] DataBuffer; } @@ -8755,6 +8765,7 @@ internal static class CopyFileRemoteUtils private static string s_driveMaxSizeErrorFormatString = FileSystemProviderStrings.DriveMaxSizeError; private static string s_PSCopyToSessionHelperDefinition = StringUtil.Format(PSCopyToSessionHelperDefinitionFormat, @"[ValidateNotNullOrEmpty()]", s_driveMaxSizeErrorFormatString); private static string s_PSCopyToSessionHelperDefinitionRestricted = StringUtil.Format(PSCopyToSessionHelperDefinitionFormat, @"[ValidateUserDrive()]", s_driveMaxSizeErrorFormatString); + private const string PSCopyToSessionHelperDefinitionFormat = @" param ( [Parameter(ParameterSetName=""PSCopyFileToRemoteSession"")] @@ -9221,6 +9232,7 @@ function PSCreateDirectoryOnRemoteSession private static string s_PSCopyFromSessionHelperDefinition = StringUtil.Format(PSCopyFromSessionHelperDefinitionFormat, @"[ValidateNotNullOrEmpty()]"); private static string s_PSCopyFromSessionHelperDefinitionRestricted = StringUtil.Format(PSCopyFromSessionHelperDefinitionFormat, @"[ValidateUserDrive()]"); + private const string PSCopyFromSessionHelperDefinitionFormat = @" param ( [Parameter(ParameterSetName=""PSCopyFileFromRemoteSession"", Mandatory=$true)] @@ -9711,6 +9723,7 @@ PSGetPathDirAndFiles @params internal static string PSCopyRemoteUtilsDefinition = StringUtil.Format(PSCopyRemoteUtilsDefinitionFormat, @"[ValidateNotNullOrEmpty()]", PSValidatePathFunction); private static string s_PSCopyRemoteUtilsDefinitionRestricted = StringUtil.Format(PSCopyRemoteUtilsDefinitionFormat, @"[ValidateUserDrive()]", PSValidatePathFunction); + private const string PSCopyRemoteUtilsDefinitionFormat = @" param ( [Parameter(ParameterSetName=""PSRemoteDirectoryExist"", Mandatory=$true)] @@ -9879,6 +9892,7 @@ function SafeGetDriveRoot #endregion internal static string AllCopyToRemoteScripts = s_PSCopyToSessionHelper + PSCopyRemoteUtils; + internal static IEnumerable GetAllCopyToRemoteScriptFunctions() { yield return s_PSCopyToSessionHelperFunction; @@ -9886,6 +9900,7 @@ internal static IEnumerable GetAllCopyToRemoteScriptFunctions() } internal static string AllCopyFromRemoteScripts = PSCopyFromSessionHelper + PSCopyRemoteUtils; + internal static IEnumerable GetAllCopyFromRemoteScriptFunctions() { yield return s_PSCopyFromSessionHelperFunction; diff --git a/src/System.Management.Automation/security/SecuritySupport.cs b/src/System.Management.Automation/security/SecuritySupport.cs index 556e1aa236d..22e553d3002 100644 --- a/src/System.Management.Automation/security/SecuritySupport.cs +++ b/src/System.Management.Automation/security/SecuritySupport.cs @@ -1559,6 +1559,7 @@ internal static void CurrentDomain_ProcessExit(object sender, EventArgs e) [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private static IntPtr s_amsiContext = IntPtr.Zero; + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] private static IntPtr s_amsiSession = IntPtr.Zero; diff --git a/src/System.Management.Automation/security/nativeMethods.cs b/src/System.Management.Automation/security/nativeMethods.cs index e109e000719..7cda5b88260 100644 --- a/src/System.Management.Automation/security/nativeMethods.cs +++ b/src/System.Management.Automation/security/nativeMethods.cs @@ -524,6 +524,7 @@ int NCryptOpenKey(IntPtr hProv, string strKeyName, uint dwLegacySpec, uint dwFlags); + [DllImport("ncrypt.dll", CharSet = CharSet.Unicode)] internal static extern unsafe int NCryptSetProperty(IntPtr hProv, string pszProperty, void* pbInput, int cbInput, int dwFlags); @@ -565,12 +566,16 @@ internal struct CRYPTUI_WIZ_DIGITAL_SIGN_INFO { internal DWORD dwSize; internal DWORD dwSubjectChoice; + [MarshalAs(UnmanagedType.LPWStr)] internal string pwszFileName; + internal DWORD dwSigningCertChoice; internal IntPtr pSigningCertContext; // PCCERT_CONTEXT + [MarshalAs(UnmanagedType.LPWStr)] internal string pwszTimestampURL; + internal DWORD dwAdditionalCertChoice; internal IntPtr pSignExtInfo; // PCCRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO }; @@ -602,10 +607,13 @@ internal struct CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO { internal DWORD dwSize; internal DWORD dwAttrFlagsNotUsed; + [MarshalAs(UnmanagedType.LPWStr)] internal string pwszDescription; + [MarshalAs(UnmanagedType.LPWStr)] internal string pwszMoreInfoLocation; + [MarshalAs(UnmanagedType.LPStr)] internal string pszHashAlg; @@ -794,8 +802,10 @@ IntPtr pWinTrustData // WINTRUST_DATA* internal struct WINTRUST_FILE_INFO { internal DWORD cbStruct; // = sizeof(WINTRUST_FILE_INFO) + [MarshalAs(UnmanagedType.LPWStr)] internal string pcwszFilePath; // LPCWSTR + internal IntPtr hFileNotUsed; // optional, HANDLE to pcwszFilePath internal IntPtr pgKnownSubjectNotUsed; // optional: GUID* : fill if the // subject type is known @@ -1935,6 +1945,7 @@ internal struct CRYPT_ATTRIBUTE_TYPE_VALUE { [MarshalAs(UnmanagedType.LPStr)] internal string pszObjId; + internal CRYPT_ATTR_BLOB Value; } @@ -1954,8 +1965,10 @@ internal struct CRYPTCATCDF private DWORD _dwCurFilePos; private DWORD _dwLastMemberOffset; private BOOL _fEOF; + [MarshalAs(UnmanagedType.LPWStr)] private string _pwszResultDir; + private IntPtr _hCATStore; }; @@ -1963,10 +1976,13 @@ internal struct CRYPTCATCDF internal struct CRYPTCATMEMBER { internal DWORD cbStruct; + [MarshalAs(UnmanagedType.LPWStr)] internal string pwszReferenceTag; + [MarshalAs(UnmanagedType.LPWStr)] internal string pwszFileName; + internal Guid gSubjectType; internal DWORD fdwMemberFlags; internal IntPtr pIndirectData; @@ -1981,8 +1997,10 @@ internal struct CRYPTCATMEMBER internal struct CRYPTCATATTRIBUTE { private DWORD _cbStruct; + [MarshalAs(UnmanagedType.LPWStr)] internal string pwszReferenceTag; + private DWORD _dwAttrTypeAndAction; internal DWORD cbValue; internal System.IntPtr pbValue; @@ -1994,8 +2012,10 @@ internal struct CRYPTCATSTORE { private DWORD _cbStruct; internal DWORD dwPublicVersion; + [MarshalAs(UnmanagedType.LPWStr)] internal string pwszP7File; + private IntPtr _hProv; private DWORD _dwEncodingType; private DWORD _fdwStoreFlags; diff --git a/src/System.Management.Automation/security/wldpNativeMethods.cs b/src/System.Management.Automation/security/wldpNativeMethods.cs index 974392424eb..608503b932f 100644 --- a/src/System.Management.Automation/security/wldpNativeMethods.cs +++ b/src/System.Management.Automation/security/wldpNativeMethods.cs @@ -176,6 +176,7 @@ private static SystemEnforcementMode GetWldpPolicy(string path, SafeHandle handl private const string AppLockerTestFileName = "__PSScriptPolicyTest_"; private const string AppLockerTestFileContents = "# PowerShell test file to determine AppLocker lockdown mode "; + private static SystemEnforcementMode GetAppLockerPolicy(string path, SafeHandle handle) { SaferPolicy result = SaferPolicy.Disallowed; diff --git a/src/System.Management.Automation/singleshell/config/MshConsoleLoadException.cs b/src/System.Management.Automation/singleshell/config/MshConsoleLoadException.cs index cbd4d8836cf..9e8c2585215 100644 --- a/src/System.Management.Automation/singleshell/config/MshConsoleLoadException.cs +++ b/src/System.Management.Automation/singleshell/config/MshConsoleLoadException.cs @@ -87,6 +87,7 @@ private void CreateErrorRecord() } private Collection _PSSnapInExceptions = new Collection(); + internal Collection PSSnapInExceptions { get diff --git a/src/System.Management.Automation/utils/EncodingUtils.cs b/src/System.Management.Automation/utils/EncodingUtils.cs index 161ac75866e..af3c1c04a86 100644 --- a/src/System.Management.Automation/utils/EncodingUtils.cs +++ b/src/System.Management.Automation/utils/EncodingUtils.cs @@ -25,6 +25,7 @@ internal static class EncodingConversion internal const string Utf32 = "utf32"; internal const string Default = "default"; internal const string OEM = "oem"; + internal static readonly string[] TabCompletionResults = { Ascii, BigEndianUnicode, BigEndianUtf32, OEM, Unicode, Utf7, Utf8, Utf8Bom, Utf8NoBom, Utf32 }; diff --git a/src/System.Management.Automation/utils/IObjectWriter.cs b/src/System.Management.Automation/utils/IObjectWriter.cs index eb011e4f3b8..5a6afad9514 100644 --- a/src/System.Management.Automation/utils/IObjectWriter.cs +++ b/src/System.Management.Automation/utils/IObjectWriter.cs @@ -125,18 +125,21 @@ public abstract int MaxCapacity internal class DiscardingPipelineWriter : PipelineWriter { private ManualResetEvent _waitHandle = new ManualResetEvent(true); + public override WaitHandle WaitHandle { get { return _waitHandle; } } private bool _isOpen = true; + public override bool IsOpen { get { return _isOpen; } } private int _count = 0; + public override int Count { get { return _count; } diff --git a/src/System.Management.Automation/utils/MshInvalidOperationException.cs b/src/System.Management.Automation/utils/MshInvalidOperationException.cs index 75d7094432e..0889fee33df 100644 --- a/src/System.Management.Automation/utils/MshInvalidOperationException.cs +++ b/src/System.Management.Automation/utils/MshInvalidOperationException.cs @@ -132,6 +132,7 @@ public ErrorRecord ErrorRecord private ErrorRecord _errorRecord; private string _errorId = "InvalidOperation"; + internal void SetErrorId(string errorId) { _errorId = errorId; diff --git a/src/System.Management.Automation/utils/PlatformInvokes.cs b/src/System.Management.Automation/utils/PlatformInvokes.cs index de45d6303da..4ffdeb41415 100644 --- a/src/System.Management.Automation/utils/PlatformInvokes.cs +++ b/src/System.Management.Automation/utils/PlatformInvokes.cs @@ -99,6 +99,7 @@ internal class SecurityAttributes internal int nLength; internal SafeLocalMemHandle lpSecurityDescriptor; internal bool bInheritHandle; + internal SecurityAttributes() { this.nLength = 12; @@ -124,6 +125,7 @@ internal SafeLocalMemHandle(IntPtr existingHandle, bool ownsHandle) [DllImport(PinvokeDllNames.LocalFreeDllName), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern IntPtr LocalFree(IntPtr hMem); + protected override bool ReleaseHandle() { return (LocalFree(base.handle) == IntPtr.Zero); @@ -602,6 +604,7 @@ internal class STARTUPINFO public SafeFileHandle hStdInput; public SafeFileHandle hStdOutput; public SafeFileHandle hStdError; + public STARTUPINFO() { this.lpReserved = IntPtr.Zero; @@ -650,6 +653,7 @@ internal class SECURITY_ATTRIBUTES public int nLength; public SafeLocalMemHandle lpSecurityDescriptor; public bool bInheritHandle; + public SECURITY_ATTRIBUTES() { this.nLength = 12; @@ -674,6 +678,7 @@ internal static extern bool CreateProcess( [DllImport(PinvokeDllNames.ResumeThreadDllName, CharSet = CharSet.Unicode, SetLastError = true)] public static extern uint ResumeThread(IntPtr threadHandle); + internal static uint RESUME_THREAD_FAILED = System.UInt32.MaxValue; // (DWORD)-1 [DllImport(PinvokeDllNames.CreateFileDllName, CharSet = CharSet.Unicode, SetLastError = true)] diff --git a/src/System.Management.Automation/utils/PsUtils.cs b/src/System.Management.Automation/utils/PsUtils.cs index 50fafe53c91..5866e3d52f9 100644 --- a/src/System.Management.Automation/utils/PsUtils.cs +++ b/src/System.Management.Automation/utils/PsUtils.cs @@ -404,6 +404,7 @@ internal static Hashtable EvaluatePowerShellDataFile( internal static readonly string[] ManifestModuleVersionPropertyName = new[] { "ModuleVersion" }; internal static readonly string[] ManifestGuidPropertyName = new[] { "GUID" }; internal static readonly string[] ManifestPrivateDataPropertyName = new[] { "PrivateData" }; + internal static readonly string[] FastModuleManifestAnalysisPropertyNames = new[] { "AliasesToExport", diff --git a/src/System.Management.Automation/utils/ResourceManagerCache.cs b/src/System.Management.Automation/utils/ResourceManagerCache.cs index c1e463f5ad9..302fd0c48cf 100644 --- a/src/System.Management.Automation/utils/ResourceManagerCache.cs +++ b/src/System.Management.Automation/utils/ResourceManagerCache.cs @@ -113,6 +113,7 @@ internal static ResourceManager GetResourceManager( /// Design For Testability -- assert on failed resource lookup. /// private static bool s_DFT_monitorFailingResourceLookup = true; + internal static bool DFT_DoMonitorFailingResourceLookup { get { return ResourceManagerCache.s_DFT_monitorFailingResourceLookup; } diff --git a/src/System.Management.Automation/utils/RuntimeException.cs b/src/System.Management.Automation/utils/RuntimeException.cs index 3b9d6ae3d73..fe5a6c3b4be 100644 --- a/src/System.Management.Automation/utils/RuntimeException.cs +++ b/src/System.Management.Automation/utils/RuntimeException.cs @@ -305,6 +305,7 @@ internal bool SuppressPromptInInterpreter #endregion Internal private Token _errorToken; + internal Token ErrorToken { get diff --git a/src/System.Management.Automation/utils/StringUtil.cs b/src/System.Management.Automation/utils/StringUtil.cs index 03bd41816e2..9b3cf3447cb 100644 --- a/src/System.Management.Automation/utils/StringUtil.cs +++ b/src/System.Management.Automation/utils/StringUtil.cs @@ -68,6 +68,7 @@ internal static private const int IndentCacheMax = 120; private static readonly string[] IndentCache = new string[IndentCacheMax]; + internal static string Padding(int countOfSpaces) { if (countOfSpaces >= IndentCacheMax) @@ -87,6 +88,7 @@ internal static string Padding(int countOfSpaces) private const int DashCacheMax = 120; private static readonly string[] DashCache = new string[DashCacheMax]; + internal static string DashPadding(int count) { if (count >= DashCacheMax)