Formatting: Add empty line between declarations (#12824)

# PR Summary

Automated fixes:
* RCS0013: Add empty line between single-line declarations of different kind
* RCS010: Add empty line between declarations

## PR Context


## PR Checklist

- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
    - Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress).
    - If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready.
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)**
    - [x] None
    - **OR**
    - [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md)
        - [ ] Experimental feature name(s): <!-- Experimental feature name(s) here -->
- **User-facing changes**
    - [x] Not Applicable
    - **OR**
    - [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
        - [ ] Issue filed: <!-- Number/link of that issue here -->
- **Testing - New and feature**
    - [x] N/A or can only be tested interactively
    - **OR**
    - [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting)
- **Tooling**
    - [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
    - **OR**
    - [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
        - Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell) for VSCode (which runs in a different PS Host).
        - Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        - Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) (which provides linting & formatting in the editor extensions).
        - Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
This commit is contained in:
xtqqczze 2020-05-29 05:56:33 +01:00 committed by GitHub
parent 9e0b940cfa
commit 05cab7fa5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
159 changed files with 547 additions and 0 deletions

View file

@ -703,6 +703,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Whether at begin process time, false means in processrecord.
/// </summary>
private bool atBeginProcess = true;
internal bool AtBeginProcess
{
get

View file

@ -1066,6 +1066,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
#if DEBUG
private static bool isCliXmlTestabilityHookActive = GetIsCliXmlTestabilityHookActive();
private static bool GetIsCliXmlTestabilityHookActive()
{
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CDXML_CLIXML_TEST"));
@ -1514,6 +1515,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Flag controls whether session object should be closed or not.
/// </summary>
private bool isTemporaryCimSession;
internal bool IsTemporaryCimSession
{
get
@ -2260,6 +2262,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
#region private members
private CimNewCimInstance newCimInstance = null;
internal CimNewCimInstance NewCimInstanceOperation
{
get

View file

@ -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
};

View file

@ -141,6 +141,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Flag used to control generating log message into file.
/// </summary>
private static bool generateLog = true;
internal static bool GenerateLog
{
get { return generateLog; }
@ -157,6 +158,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
/// Flag used to control generating message into powershell.
/// </summary>
private static bool generateVerboseMessage = true;
internal static bool GenerateVerboseMessage
{
get { return generateVerboseMessage; }

View file

@ -47,6 +47,7 @@ namespace Microsoft.Management.UI.Internal
#region SelectedIndex
private const string SelectedIndexPropertyName = "SelectedIndex";
private int selectedIndex;
/// <summary>

View file

@ -14,6 +14,7 @@ namespace Microsoft.Management.UI.Internal
public class PropertyValueGetter : IPropertyValueGetter
{
private const string PropertyDescriptorColumnId = "PropertyDescriptor";
private DataTable cachedProperties;
/// <summary>

View file

@ -90,6 +90,7 @@ namespace Microsoft.PowerShell.Commands
@"\memory\cache faults/sec",
@"\physicaldisk(_total)\% disk time",
@"\physicaldisk(_total)\current disk queue length"};
private bool _defaultCounters = true;
private List<string> _accumulatedCounters = new List<string>();
@ -117,6 +118,7 @@ namespace Microsoft.PowerShell.Commands
// MaxSamples parameter
//
private const Int64 KEEP_ON_SAMPLING = -1;
[Parameter(
ParameterSetName = "GetCounterSet",
ValueFromPipeline = false,

View file

@ -27,6 +27,7 @@ namespace Microsoft.PowerShell.Commands
private const string TemplateTag = "template";
private const string DataTag = "data";
private ResourceManager _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
/// <summary>

View file

@ -18,6 +18,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
{
private readonly string _wqlQuery;
private readonly bool _useEnumerateInstances;
internal QueryInstancesJob(CimJobContext jobContext, CimQuery cimQuery, string wqlCondition)
: base(jobContext, cimQuery)
{

View file

@ -27,6 +27,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
{
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 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
}
private readonly CimSensitiveValueConverter _cimSensitiveValueConverter = new CimSensitiveValueConverter();
internal CimSensitiveValueConverter CimSensitiveValueConverter { get { return _cimSensitiveValueConverter; } }
internal abstract IObservable<T> GetCimOperation();
@ -161,9 +163,12 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
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)
{
this.ExceptionSafeWrapper(
@ -527,7 +532,9 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
}
private readonly Lazy<CimCustomOptionsDictionary> _jobSpecificCustomOptions;
internal abstract CimCustomOptionsDictionary CalculateJobSpecificCustomOptions();
private CimCustomOptionsDictionary GetJobSpecificCustomOptions()
{
return _jobSpecificCustomOptions.Value;

View file

@ -37,7 +37,9 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
private readonly IDictionary<string, string> _privateData;
private const string QueryLanguageKey = "QueryDialect";
private bool? _useEnumerateInstancesInsteadOfWql;
public bool UseEnumerateInstancesInsteadOfWql
{
get
@ -112,6 +114,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
private Uri _resourceUri;
private bool _resourceUriHasBeenCalculated;
public Uri ResourceUri
{
get
@ -140,6 +143,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
}
private CimOperationFlags? _schemaConformanceLevel;
public CimOperationFlags SchemaConformanceLevel
{
get

View file

@ -369,6 +369,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
#region Handling of dynamic parameters
private RuntimeDefinedParameterDictionary _dynamicParameters;
private const string CimNamespaceParameter = "CimNamespace";
private string GetDynamicNamespace()

View file

@ -154,6 +154,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
private abstract class CimInstancePropertyBasedFilter : CimInstanceFilterBase
{
private readonly List<PropertyValueFilter> _propertyValueFilters = new List<PropertyValueFilter>();
protected IEnumerable<PropertyValueFilter> PropertyValueFilters { get { return _propertyValueFilters; } }
protected void AddPropertyValueFilter(PropertyValueFilter propertyValueFilter)
@ -357,6 +358,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
}
protected abstract BehaviorOnNoMatch GetDefaultBehaviorWhenNoMatchesFound(object cimTypedExpectedPropertyValue);
private BehaviorOnNoMatch _behaviorOnNoMatch;
public string PropertyName { get; }

View file

@ -197,6 +197,7 @@ namespace Microsoft.PowerShell.Commands.Internal
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)

View file

@ -1123,6 +1123,7 @@ $result
#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

View file

@ -2776,6 +2776,7 @@ namespace Microsoft.PowerShell.Commands
public int nLength;
public SafeLocalMemHandle lpSecurityDescriptor;
public bool bInheritHandle;
public SECURITY_ATTRIBUTES()
{
this.nLength = 12;
@ -2801,6 +2802,7 @@ namespace Microsoft.PowerShell.Commands
[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 @@ namespace Microsoft.PowerShell.Commands
public SafeFileHandle hStdInput;
public SafeFileHandle hStdOutput;
public SafeFileHandle hStdError;
public STARTUPINFO()
{
this.lpReserved = IntPtr.Zero;

View file

@ -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);

View file

@ -634,7 +634,9 @@ namespace Microsoft.PowerShell.Commands
private static readonly Dictionary<int, Assembly> s_sourceAssemblyCache = new Dictionary<int, Assembly>();
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;

View file

@ -99,10 +99,13 @@ namespace Microsoft.PowerShell.Commands
#region Internal
private List<OrderByPropertyEntry> _referenceEntries;
private readonly List<OrderByPropertyEntry> _referenceEntryBacklog
= new List<OrderByPropertyEntry>();
private readonly List<OrderByPropertyEntry> _differenceEntryBacklog
= new List<OrderByPropertyEntry>();
private OrderByProperty _orderByProperty = null;
private OrderByPropertyComparer _comparer = null;

View file

@ -58,6 +58,7 @@ namespace Microsoft.PowerShell.Commands
private const string PathParameterSet = "PathParamSet";
private const string LiteralPathParameterSet = "LiteralParamSet";
private const string InputObjParamSet = "InputObjParamSet";
private MarkdownConversionType _conversionType = MarkdownConversionType.HTML;
private PSMarkdownOptionInfo _mdOption = null;

View file

@ -43,6 +43,7 @@ namespace Microsoft.PowerShell.Commands
private const string DataNotQualifiedForGridView = "DataNotQualifiedForGridView";
private const string RemotingNotSupported = "RemotingNotSupported";
private TypeInfoDataBase _typeInfoDataBase;
private PSPropertyExpressionFactory _expressionFactory;
private OutWindowProxy _windowProxy;

View file

@ -20,6 +20,7 @@ namespace Microsoft.PowerShell.Commands
internal const string OriginalObjectPropertyName = "OutGridViewOriginalObject";
private const string ToStringValuePropertyName = "ToStringValue";
private const string IndexPropertyName = "IndexValue";
private int _index;
/// <summary> Columns definition of the underlying Management List</summary>

View file

@ -280,6 +280,7 @@ namespace Microsoft.PowerShell.Commands
}
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());

View file

@ -29,6 +29,7 @@ namespace Microsoft.PowerShell.Commands
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

View file

@ -794,6 +794,7 @@ namespace Microsoft.PowerShell.Commands
}
private List<string> _commandsSkippedBecauseOfShadowing = new List<string>();
private void ReportSkippedCommands()
{
if (_commandsSkippedBecauseOfShadowing.Count != 0)
@ -825,6 +826,7 @@ namespace Microsoft.PowerShell.Commands
}
private Dictionary<string, object> _existingCommands;
private Dictionary<string, object> 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 @@ function Get-PSImplicitRemotingSession
}} -ErrorAction SilentlyContinue
}} catch {{ }}
";
private string GenerateReimportingOfModules()
{
StringBuilder result = new StringBuilder();
@ -2543,6 +2549,7 @@ function Get-PSImplicitRemotingSession
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)

View file

@ -225,6 +225,7 @@ namespace Microsoft.PowerShell.Commands
}
private Dictionary<string, CommandTypes> _existingCommands;
private Dictionary<string, CommandTypes> ExistingCommands
{
get

View file

@ -22,6 +22,7 @@ namespace Microsoft.PowerShell.Commands.Utility
{
/// <summary>A bigger default to not get re-allocations in common use cases.</summary>
private const int DefaultOutputStringCapacity = 256;
private readonly StringBuilder _outputBuilder = new StringBuilder(DefaultOutputStringCapacity);
private CultureInfo _cultureInfo = CultureInfo.InvariantCulture;
private string _separator;

View file

@ -272,6 +272,7 @@ namespace Microsoft.PowerShell.Commands
internal static class PSMarkdownOptionInfoCache
{
private static ConcurrentDictionary<Guid, PSMarkdownOptionInfo> markdownOptionInfoCache;
private const string MarkdownOptionInfoVariableName = "PSMarkdownOptionInfo";
static PSMarkdownOptionInfoCache()

View file

@ -329,6 +329,7 @@ namespace Microsoft.PowerShell.Commands
}
internal readonly PSObject WrittenObject;
internal int NotePropertyCount { get; }
}

View file

@ -29,6 +29,7 @@ namespace Microsoft.PowerShell.Commands
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);

View file

@ -26,7 +26,9 @@ namespace Microsoft.PowerShell.Commands
public object InputObject { get; set; }
private int _depth = 2;
private const int maxDepthAllowed = 100;
private readonly CancellationTokenSource _cancellationSource = new CancellationTokenSource();
/// <summary>

View file

@ -79,6 +79,7 @@ namespace Microsoft.PowerShell.Commands
#endregion Known_HTTP_Header_Names
private static HashSet<string> s_contentHeaderSet = null;
internal static HashSet<string> ContentHeaders
{
get

View file

@ -56,39 +56,52 @@ namespace Microsoft.PowerShell
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 @@ namespace Microsoft.PowerShell
{
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 @@ namespace Microsoft.PowerShell
internal interface IObjectArray
{
void GetCount(out uint cObjects);
void GetAt(
uint iIndex,
ref Guid riid,
@ -208,8 +230,10 @@ namespace Microsoft.PowerShell
// IObjectCollection
void AddObject(
[MarshalAs(UnmanagedType.Interface)] object pvObject);
void AddFromArray(
[MarshalAs(UnmanagedType.Interface)] IObjectArray poaSource);
void RemoveObject(uint uiIndex);
void Clear();
}

View file

@ -136,6 +136,7 @@ namespace Microsoft.PowerShell
internal short FontHeight;
internal int FontFamily;
internal int FontWeight;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
internal string FontFace;
}
@ -3005,6 +3006,7 @@ namespace Microsoft.PowerShell
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;

View file

@ -1423,6 +1423,7 @@ namespace Microsoft.PowerShell
// 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
@ -2166,6 +2167,7 @@ namespace Microsoft.PowerShell
}
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.

View file

@ -192,7 +192,9 @@ namespace Microsoft.PowerShell
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

View file

@ -1019,6 +1019,7 @@ namespace Microsoft.PowerShell
private ArrayList _topLevelNodes = new ArrayList();
private int _nodeCount;
private const int maxNodeCount = 128;
}
} // namespace

View file

@ -12,16 +12,22 @@ namespace System.Diagnostics.Eventing
{
[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;

View file

@ -14,6 +14,7 @@ namespace System.Diagnostics.Eventing
{
[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 @@ namespace System.Diagnostics.Eventing
[ThreadStatic]
private static WriteEventErrorCode t_returnCode; // thread slot to keep last error
[ThreadStatic]
private static Guid t_activityId;
@ -48,8 +50,10 @@ namespace System.Diagnostics.Eventing
{
[FieldOffset(0)]
internal ulong DataPointer;
[FieldOffset(8)]
internal uint Size;
[FieldOffset(12)]
internal int Reserved;
}

View file

@ -20,10 +20,13 @@ namespace System.Diagnostics.Eventing
//
//
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;

View file

@ -14,6 +14,7 @@ namespace System.Diagnostics.Eventing
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:
@ -239,18 +240,25 @@ namespace System.Diagnostics.Eventing
{
[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;
}
@ -261,50 +269,73 @@ namespace System.Diagnostics.Eventing
{
[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;
}
@ -493,12 +524,16 @@ namespace System.Diagnostics.Eventing
{
[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;
}
@ -825,8 +860,10 @@ namespace System.Diagnostics.Eventing
{
[MarshalAs(UnmanagedType.LPWStr), FieldOffset(0)]
public string StringVal;
[FieldOffset(8)]
public UInt32 Count;
[FieldOffset(12)]
public UInt32 Type;
};

View file

@ -61,6 +61,7 @@ namespace Microsoft.PowerShell.MarkdownRender
// 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)

View file

@ -273,10 +273,12 @@ namespace Microsoft.PowerShell.MarkdownRender
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;
/// <summary>

View file

@ -565,6 +565,7 @@ namespace Microsoft.PowerShell.Commands
/// this property.
/// </remarks>
private static Regex s_certPathRegex = null;
private static Regex CertPathRegex
{
get
@ -3093,6 +3094,7 @@ namespace Microsoft.PowerShell.Commands
}
private static readonly char[] s_separators = new char[] { '/', '\\' };
private static string[] GetPathElements(string path)
{
string[] allElts = path.Split(s_separators);
@ -3177,6 +3179,7 @@ namespace Microsoft.PowerShell.Commands
{
private List<DnsNameRepresentation> _dnsList = new List<DnsNameRepresentation>();
private System.Globalization.IdnMapping idnMapping = new System.Globalization.IdnMapping();
private const string dnsNamePrefix = "DNS Name=";
private const string distinguishedNamePrefix = "CN=";

View file

@ -5446,6 +5446,7 @@ namespace Microsoft.WSMan.Management
#region def
private static readonly string[] WinrmRootName = new string[] { "winrm/Config" };
private static readonly string[] WinRmRootConfigs = new string[] {
"Client",
"Service",

View file

@ -398,6 +398,7 @@ namespace Microsoft.WSMan.Management
# region private
WSManHelper helper;
private string GetFilter()
{
string name;

View file

@ -113,6 +113,7 @@ namespace System.Management.Automation
// - Value: strong name of the TPA that contains the type represented by Key.
private readonly Dictionary<string, string> _coreClrTypeCatalog;
private readonly Lazy<HashSet<string>> _availableDotNetAssemblyNames;
private readonly HashSet<string> _denyListedAssemblies = new HashSet<string>(StringComparer.OrdinalIgnoreCase){
"System.Windows.Forms"
};

View file

@ -656,6 +656,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
/// </summary>
[ThreadStatic]
private static bool t_cacheResourcesFromMultipleModuleVersions;
private static bool CacheResourcesFromMultipleModuleVersions
{
get
@ -3712,6 +3713,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
}
private static ScriptBlock s_cimKeywordImplementationFunction;
private const string CimKeywordImplementationFunctionText = @"
param (
[Parameter(Mandatory)]

View file

@ -948,7 +948,9 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
private int _rowCount = 0;
private int _consoleHeight = -1;
private int _consoleWidth = -1;
private const int WhitespaceAndPagerLineCount = 2;
private bool _repeatHeader = false;
/// <summary>

View file

@ -547,6 +547,7 @@ namespace System.Management.Automation
public sealed class TableControlBuilder
{
internal readonly TableControl _table;
internal TableControlBuilder(TableControl table)
{
_table = table;

View file

@ -259,6 +259,7 @@ namespace System.Management.Automation
public sealed class WideControlBuilder
{
private readonly WideControl _control;
internal WideControlBuilder(WideControl control)
{
_control = control;

View file

@ -473,6 +473,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
}
private delegate IEnumerable<ExtendedTypeDefinition> TypeGenerator();
private static Dictionary<string, Tuple<bool, TypeGenerator>> s_builtinGenerators;
private static Tuple<bool, TypeGenerator> GetBuiltin(bool isForHelp, TypeGenerator generator)

View file

@ -40,8 +40,10 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
}
private ScreenInfo _si;
private const char ESC = '\u001b';
private const string ResetConsoleVt100Code = "\u001b[m";
private List<string> _header;
internal static int ComputeWideViewBestItemsPerRowFit(int stringLen, int screenColumns)

View file

@ -32,6 +32,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
internal class NameEntryDefinition : HashtableEntryDefinition
{
internal const string NameEntryKey = "name";
internal NameEntryDefinition()
: base(NameEntryKey, new string[] { FormatParameterDefinitionKeys.LabelEntryKey }, new Type[] { typeof(string) }, false)
{

View file

@ -2101,6 +2101,7 @@ Microsoft.PowerShell.Core\Export-ModuleMember -Function '{1}' -Alias '*'
}
private static object s_enumCompilationLock = new object();
private static void CompileEnum(EnumMetadataEnum enumMetadata)
{
try

View file

@ -352,12 +352,16 @@ namespace System.Management.Automation
{
[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 @@ namespace System.Management.Automation
{
[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;
}

View file

@ -56,6 +56,7 @@ namespace System.Management.Automation
public Collection<CompletionResult> CompletionMatches { get; set; }
internal static readonly IList<CompletionResult> EmptyCompletionResult = Array.Empty<CompletionResult>();
private static readonly CommandCompletion s_emptyCommandCompletion = new CommandCompletion(
new Collection<CompletionResult>(EmptyCompletionResult), -1, -1, -1);

View file

@ -208,6 +208,7 @@ namespace System.Management.Automation
private static readonly HashSet<string> s_keywordsToExcludeFromAddingAmpersand
= new HashSet<string>(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 @@ namespace System.Management.Automation
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 @@ namespace System.Management.Automation
}
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 @@ namespace System.Management.Automation
}
private static TypeCompletionMapping[][] s_typeCache;
private static TypeCompletionMapping[][] InitializeTypeCache()
{
#region Process_TypeAccelerators

View file

@ -647,6 +647,7 @@ namespace System.Management.Automation
// 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; }

View file

@ -667,6 +667,7 @@ namespace System.Management.Automation
}
private static readonly ConcurrentDictionary<Type, Func<Cmdlet>> s_constructInstanceCache;
private static Cmdlet ConstructInstance(Type type)
{
// Call the default constructor if type derives from Cmdlet.

View file

@ -156,6 +156,7 @@ namespace System.Management.Automation
/// The command runtime used for this instance of a command processor.
/// </summary>
protected MshCommandRuntime commandRuntime;
internal MshCommandRuntime CommandRuntime
{
get { return commandRuntime; }
@ -230,6 +231,7 @@ namespace System.Management.Automation
/// The execution context used by the system.
/// </summary>
protected ExecutionContext _context;
internal ExecutionContext Context
{
get { return _context; }

View file

@ -2080,6 +2080,7 @@ namespace System.Management.Automation
{
internal MethodBase method;
private string _cachedMethodDefinition;
internal string methodDefinition
{
get
@ -2101,7 +2102,9 @@ namespace System.Management.Automation
internal bool isGeneric;
private bool _useReflection;
private delegate object MethodInvoker(object target, object[] arguments);
private MethodInvoker _methodInvoker;
/// <summary>
@ -2555,8 +2558,10 @@ namespace System.Management.Automation
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() { }
@ -2626,6 +2631,7 @@ namespace System.Management.Automation
}
private bool? _isHidden;
internal override bool IsHidden
{
get
@ -2980,6 +2986,7 @@ namespace System.Management.Automation
internal Type propertyType;
private bool? _isHidden;
internal override bool IsHidden
{
get
@ -2994,6 +3001,7 @@ namespace System.Management.Automation
}
private AttributeCollection _attributes;
internal AttributeCollection Attributes
{
get
@ -4749,6 +4757,7 @@ namespace System.Management.Automation
internal class DotNetAdapterWithComTypeName : DotNetAdapter
{
private ComTypeInfo _comTypeInfo;
internal DotNetAdapterWithComTypeName(ComTypeInfo comTypeInfo)
{
_comTypeInfo = comTypeInfo;

View file

@ -817,6 +817,7 @@ namespace System.Management.Automation
}
private PSNoteProperty _noteProperty;
internal PSNoteProperty GetNotePropertyForProviderCmdlets(string name)
{
if (_noteProperty == null)

View file

@ -673,6 +673,7 @@ namespace System.Management.Automation
private Dictionary<string, List<PSTypeName>> _providerOutputType;
private PSNoteProperty _noteProperty;
internal PSNoteProperty GetNotePropertyForProviderCmdlets(string name)
{
if (_noteProperty == null)

View file

@ -1470,6 +1470,7 @@ namespace System.Management.Automation
public object TargetObject { get => _target; }
private object _target /* = null */;
internal void SetTargetObject(object target)
{
_target = target;

View file

@ -641,6 +641,7 @@ namespace System.Management.Automation
#endregion OnIdleProcessing
private static Dictionary<string, Type> s_generatedEventHandlers = new Dictionary<string, Type>();
private void ProcessNewSubscriber(PSEventSubscriber subscriber, object source, string eventName, string sourceIdentifier, PSObject data, bool supportEvent, bool forwardEvent)
{
Delegate handlerDelegate = null;
@ -2349,6 +2350,7 @@ namespace System.Management.Automation
/// The event generated when a new event is received.
/// </summary>
public event PSEventReceivedEventHandler PSEventReceived;
private List<PSEventArgs> _eventCollection = new List<PSEventArgs>();
/// <summary>

View file

@ -4771,9 +4771,11 @@ end {
";
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;
internal static SessionStateFunctionEntry[] BuiltInFunctions = new SessionStateFunctionEntry[]
{
// Functions that don't require full language mode
@ -4871,6 +4873,7 @@ end {
{ "Microsoft.PowerShell.Diagnostics", "Microsoft.PowerShell.Commands.Diagnostics"},
{ "Microsoft.PowerShell.Host", "Microsoft.PowerShell.ConsoleHost"},
};
internal static Dictionary<string, string> NestedModuleEngineModuleMapping = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "Microsoft.PowerShell.Commands.Utility", "Microsoft.PowerShell.Utility"},

View file

@ -1963,6 +1963,7 @@ namespace Microsoft.PowerShell.Commands
private readonly CallSite<Func<CallSite, object, bool>> _toBoolSite =
CallSite<Func<CallSite, object, bool>>.Create(PSConvertBinder.Get(typeof(bool)));
private Func<object, object, object> _operationDelegate;
private static Func<object, object, object> GetCallSiteDelegate(ExpressionType expressionType, bool ignoreCase)

View file

@ -413,6 +413,7 @@ namespace System.Management.Automation
}
private delegate IEnumerable GetEnumerableDelegate(object obj);
private static Dictionary<Type, GetEnumerableDelegate> s_getEnumerableCache = new Dictionary<Type, GetEnumerableDelegate>(32);
private static GetEnumerableDelegate GetOrCalculateEnumerable(Type type)
@ -1922,6 +1923,7 @@ namespace System.Management.Automation
// This static is thread safe based on the lock in GetEnumHashEntry
// It can be shared by Runspaces in different MiniShells
private static readonly Dictionary<Type, EnumHashEntry> s_enumTable = new Dictionary<Type, EnumHashEntry>();
private const int maxEnumTableSize = 100;
private static EnumHashEntry GetEnumHashEntry(Type enumType)
@ -3656,6 +3658,7 @@ namespace System.Management.Automation
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)
@ -5732,6 +5735,7 @@ namespace System.Management.Automation
}
internal class Null { };
private static IConversionData FigureConversionFromNull(Type toType)
{
IConversionData data = GetConversionData(typeof(Null), toType);

View file

@ -1709,6 +1709,7 @@ namespace Microsoft.PowerShell.Commands
#region Cancellation support
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
private CancellationToken CancellationToken
{
get

View file

@ -841,12 +841,14 @@ namespace System.Management.Automation
"Description",
"HelpInfoURI",
};
private static readonly string[] s_manifestEntriesToKeepAsStringArray = new[] {
"FunctionsToExport",
"VariablesToExport",
"AliasesToExport",
"CmdletsToExport",
};
internal static Hashtable RewriteManifest(
Hashtable originalManifest,
IEnumerable<string> nestedModules,

View file

@ -158,6 +158,7 @@ namespace System.Management.Automation
}
private readonly bool _forCompletion;
internal List<string> DiscoveredExports { get; set; }
internal List<RequiredModuleInfo> DiscoveredModules { get; set; }
internal Dictionary<string, FunctionDefinitionAst> DiscoveredFunctions { get; set; }

View file

@ -926,6 +926,7 @@ namespace System.Management.Automation
/// the cmdlet. Semantically this is equivalent to : cmd | % { $pipelineVariable = $_; (...) }
/// </summary>
internal string PipelineVariable { get; set; }
private PSVariable _pipelineVarReference = null;
internal void SetupOutVariable()

View file

@ -173,6 +173,7 @@ namespace System.Management.Automation
{
internal object instance;
internal string name;
internal bool ShouldSerialize { get; set; }
internal virtual void ReplicateInstance(object particularInstance)

View file

@ -424,6 +424,7 @@ namespace System.Management.Automation
#region Adapter Mappings
private static readonly ConcurrentDictionary<Type, AdapterSet> s_adapterMapping = new ConcurrentDictionary<Type, AdapterSet>();
private static readonly List<Func<object, AdapterSet>> s_adapterSetMappers = new List<Func<object, AdapterSet>>
{
MappedInternalAdapterSet
@ -647,6 +648,7 @@ namespace System.Management.Automation
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()),

View file

@ -11,6 +11,7 @@ namespace System.Management.Automation
internal sealed class NativeCommand : InternalCommand
{
private NativeCommandProcessor _myCommandProcessor;
internal NativeCommandProcessor MyCommandProcessor
{
get { return _myCommandProcessor; }

View file

@ -817,6 +817,7 @@ namespace System.Management.Automation
{
public Process OriginalProcessInstance;
private int _parentId;
public int ParentId
{
get
@ -1407,8 +1408,10 @@ namespace System.Management.Automation
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 @@ namespace System.Management.Automation
[NonSerialized]
private PSObject _serializedRemoteException;
[NonSerialized]
private PSObject _serializedRemoteInvocationInfo;

View file

@ -39,6 +39,7 @@ namespace System.Management.Automation
internal const string PSOSName = "OS";
internal const string SerializationVersionName = "SerializationVersion";
internal const string WSManStackVersionName = "WSManStackVersion";
private static readonly PSVersionHashTable s_psVersionTable;
/// <summary>
@ -350,6 +351,7 @@ namespace System.Management.Automation
public sealed class PSVersionHashTable : Hashtable, IEnumerable
{
private static readonly PSVersionTableComparer s_keysComparer = new PSVersionTableComparer();
internal PSVersionHashTable(IEqualityComparer equalityComparer) : base(equalityComparer)
{
}
@ -429,6 +431,7 @@ namespace System.Management.Automation
private const string PreLabelPropertyName = "PSSemVerPreReleaseLabel";
private const string BuildLabelPropertyName = "PSSemVerBuildLabel";
private const string TypeNameForVersionWithLabel = "System.Version#IncludeLabel";
private string versionString;
/// <summary>

View file

@ -904,6 +904,7 @@ namespace System.Management.Automation
/// The invocation information for the code that is being bound.
/// </summary>
private InvocationInfo _invocationInfo;
internal InvocationInfo InvocationInfo
{
get
@ -916,6 +917,7 @@ namespace System.Management.Automation
/// The context of the currently running engine.
/// </summary>
private ExecutionContext _context;
internal ExecutionContext Context
{
get
@ -928,6 +930,7 @@ namespace System.Management.Automation
/// An instance of InternalCommand that the binder is binding to.
/// </summary>
private InternalCommand _command;
internal InternalCommand Command
{
get

View file

@ -216,6 +216,7 @@ namespace System.Management.Automation
private static readonly ConcurrentDictionary<Tuple<Type, string>, Func<object, object>> s_getterMethods
= new ConcurrentDictionary<Tuple<Type, string>, Func<object, object>>();
private static readonly ConcurrentDictionary<Tuple<Type, string>, Action<object, object>> s_setterMethods =
new ConcurrentDictionary<Tuple<Type, string>, Action<object, object>>();

View file

@ -66,6 +66,7 @@ namespace System.Management.Automation
protected ScriptBlock _scriptBlock;
private ScriptParameterBinderController _scriptParameterBinderController;
internal ScriptParameterBinderController ScriptParameterBinderController
{
get

View file

@ -1711,6 +1711,7 @@ namespace System.Management.Automation
private Dictionary<string, PSDriveInfo> _automountedDrives;
private Dictionary<string, PSVariable> _variables;
private Dictionary<string, PSVariable> GetPrivateVariables()
{
if (_variables == null)

View file

@ -688,6 +688,7 @@ namespace System.Management.Automation
private readonly CallSite<Func<CallSite, object, object>> _copyMutableValueSite =
CallSite<Func<CallSite, object, object>>.Create(PSVariableAssignmentBinder.Get());
internal object CopyMutableValues(object o)
{
// The variable assignment binder copies mutable values and returns other values as is.

View file

@ -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);
/// <summary>
/// Shell environment variable.
/// </summary>
internal const string PSSessionConfigurationName = "PSSessionConfigurationName";
internal static readonly VariablePath PSSessionConfigurationNameVarPath = new VariablePath("global:" + PSSessionConfigurationName);
/// <summary>
@ -212,6 +269,7 @@ namespace System.Management.Automation
/// application name for the connection uri.
/// </summary>
internal const string PSSessionApplicationName = "PSSessionApplicationName";
internal static readonly VariablePath PSSessionApplicationNameVarPath = new VariablePath("global:" + PSSessionApplicationName);
#region AllScope variables created in every session

View file

@ -12,6 +12,7 @@ namespace System.Management.Automation.Runspaces
public sealed partial class TypeTable
{
private const int ValueFactoryCacheCount = 6;
private static readonly Func<string, PSMemberInfoInternalCollection<PSMemberInfo>>[] s_valueFactoryCache;
private static Func<string, PSMemberInfoInternalCollection<PSMemberInfo>> GetValueFactoryBasedOnInitCapacity(int capacity)

View file

@ -485,6 +485,7 @@ namespace System.Management.Automation
#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 @@ namespace System.Management.Automation
}
private const string WhereObjectCommandAlias = "?";
private static bool TryGetCommandInfoList(PowerShell ps, HashSet<string> commandNames, out Collection<CommandInfo> cmdInfoList)
{
if (commandNames.Count == 0)
@ -1877,6 +1879,7 @@ namespace System.Management.Automation
{
internal readonly HashSet<string> ValidVariables = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
internal readonly HashSet<string> Commands = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
internal ScriptBlockAst ScriptBeingConverted { get; set; }
public override AstVisitAction VisitVariableExpression(VariableExpressionAst variableExpressionAst)

View file

@ -1072,6 +1072,7 @@ namespace System.Management.Automation
}
private bool? _isLocalSession;
private bool IsLocalSession
{
get
@ -1723,8 +1724,10 @@ namespace System.Management.Automation
// Runspace debugger integration.
private Dictionary<Guid, PSMonitorRunspaceInfo> _runningRunspaces;
private const int _jobCallStackOffset = 2;
private const int _runspaceCallStackOffset = 1;
private bool _preserveUnhandledDebugStopEvent;
private ManualResetEventSlim _preserveDebugStopEvent;

View file

@ -1672,6 +1672,7 @@ namespace System.Management.Automation.Runspaces
}
private RunspaceBase _runspace;
internal SessionStateProxy(RunspaceBase runspace)
{
Dbg.Assert(runspace != null, "Caller should validate the parameter");

View file

@ -158,6 +158,7 @@ namespace System.Management.Automation
[DataMember()]
private string _message;
private InvocationInfo _invocationInfo;
private ReadOnlyCollection<int> _pipelineIterationInfo;
private bool _serializeExtendedInfo;

View file

@ -1320,6 +1320,7 @@ namespace System.Management.Automation.Runspaces
/// This is set true when stop is called.
/// </summary>
private bool _stopping;
internal bool IsStopping
{
get

View file

@ -41,6 +41,7 @@ namespace System.Management.Automation.Host
/// The powershell spec states that 128 is the maximum nesting depth.
/// </summary>
internal const int MaximumNestedPromptLevel = 128;
internal static bool IsStdOutputRedirected;
/// <summary>

View file

@ -415,12 +415,16 @@ namespace System.Management.Automation.Host
/// make it to the actual host.
/// </summary>
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
{
private PSHostUserInterface _ui;
private bool _disposed = false;
public TranscribeOnlyCookie(PSHostUserInterface ui)
{
_ui = ui;
@ -974,6 +978,7 @@ namespace System.Management.Automation.Host
internal static TranscriptionOption systemTranscript = null;
private static object s_systemTranscriptLock = new object();
private static Lazy<Transcription> s_transcriptionSettingCache = new Lazy<Transcription>(
() => Utils.GetPolicySetting<Transcription>(Utils.SystemWideThenCurrentUserConfig),
isThreadSafe: true);

View file

@ -506,6 +506,7 @@ namespace System.Management.Automation.Runspaces
private RunspacePoolInternal _internalPool;
private object _syncObject = new object();
private event EventHandler<RunspacePoolStateChangedEventArgs> InternalStateChanged = null;
private event EventHandler<PSEventArgs> InternalForwardEvent = null;
private event EventHandler<RunspaceCreatedEventArgs> InternalRunspaceCreated = null;

View file

@ -253,6 +253,7 @@ namespace System.Management.Automation.Interpreter
internal sealed class GotoInstruction : IndexedBranchInstruction
{
private const int Variants = 4;
private static readonly GotoInstruction[] s_cache = new GotoInstruction[Variants * CacheSize];
private readonly bool _hasResult;

View file

@ -35,6 +35,7 @@ namespace System.Management.Automation.Interpreter
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")]
private int[] _continuations;
private int _continuationIndex;
private int _pendingContinuation;
private object _pendingValue;

View file

@ -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

View file

@ -375,6 +375,7 @@ namespace System.Management.Automation.Interpreter
private KeyValuePair<TKey, TValue>[] _keysAndValues;
private Dictionary<TKey, TValue> _dict;
private int _count;
private const int _arraySize = 10;
public HybridReferenceDictionary()

View file

@ -278,6 +278,7 @@ namespace System.Management.Automation
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;
@ -1639,12 +1640,14 @@ namespace System.Management.Automation
internal class RangeEnumerator : IEnumerator
{
private int _lowerBound;
internal int LowerBound
{
get { return _lowerBound; }
}
private int _upperBound;
internal int UpperBound
{
get { return _upperBound; }

View file

@ -169,6 +169,7 @@ namespace System.Management.Automation.Language
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 @@ namespace System.Management.Automation.Language
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 @@ namespace System.Management.Automation.Language
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 @@ namespace System.Management.Automation.Language
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 @@ namespace System.Management.Automation.Language
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 @@ namespace System.Management.Automation.Language
private static readonly CatchBlock[] s_stmtCatchHandlers;
internal static readonly Type DottedLocalsTupleType = MutableTuple.MakeTupleType(SpecialVariables.AutomaticVariableTypes);
internal static readonly Dictionary<string, int> DottedLocalsNameIndexMap =
new Dictionary<string, int>(SpecialVariables.AutomaticVariableTypes.Length, StringComparer.OrdinalIgnoreCase);
internal static readonly Dictionary<string, int> DottedScriptCmdletLocalsNameIndexMap =
new Dictionary<string, int>(
SpecialVariables.AutomaticVariableTypes.Length + SpecialVariables.PreferenceVariableTypes.Length,

View file

@ -20,11 +20,13 @@ namespace System.Management.Automation.Language
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<object>());
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 @@ namespace System.Management.Automation.Language
}
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");

Some files were not shown because too many files have changed in this diff Show more