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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ protected virtual void DisposeInternal()
/// Whether at begin process time, false means in processrecord.
/// </summary>
private bool atBeginProcess = true;

internal bool AtBeginProcess
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -1514,6 +1515,7 @@ internal CimInstance TargetCimInstance
/// Flag controls whether session object should be closed or not.
/// </summary>
private bool isTemporaryCimSession;

internal bool IsTemporaryCimSession
{
get
Expand Down Expand Up @@ -2260,6 +2262,7 @@ protected override bool PreNewActionEvent(CmdletActionEventArgs args)
#region private members

private CimNewCimInstance newCimInstance = null;

internal CimNewCimInstance NewCimInstanceOperation
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ internal static class DebugHelper
/// Flag used to control generating log message into file.
/// </summary>
private static bool generateLog = true;

internal static bool GenerateLog
{
get { return generateLog; }
Expand All @@ -157,6 +158,7 @@ internal static bool GenerateLog
/// Flag used to control generating message into powershell.
/// </summary>
private static bool generateVerboseMessage = true;

internal static bool GenerateVerboseMessage
{
get { return generateVerboseMessage; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public IList<T> AvailableValues
#region SelectedIndex

private const string SelectedIndexPropertyName = "SelectedIndex";

private int selectedIndex;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Management.UI.Internal
public class PropertyValueGetter : IPropertyValueGetter
{
private const string PropertyDescriptorColumnId = "PropertyDescriptor";

private DataTable cachedProperties;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> _accumulatedCounters = new List<string>();
Expand Down Expand Up @@ -117,6 +118,7 @@ public int SampleInterval
// MaxSamples parameter
//
private const Int64 KEEP_ON_SAMPLING = -1;

[Parameter(
ParameterSetName = "GetCounterSet",
ValueFromPipeline = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal abstract class CimChildJobBase<T> :
{
private static long s_globalJobNumberCounter;
private readonly long _myJobNumber = Interlocked.Increment(ref s_globalJobNumberCounter);

private const string CIMJobType = "CimJob";

internal CimJobContext JobContext
Expand Down Expand Up @@ -57,6 +58,7 @@ internal CimChildJobBase(CimJobContext jobContext)
}

private readonly CimSensitiveValueConverter _cimSensitiveValueConverter = new CimSensitiveValueConverter();

internal CimSensitiveValueConverter CimSensitiveValueConverter { get { return _cimSensitiveValueConverter; } }

internal abstract IObservable<T> GetCimOperation();
Expand Down Expand Up @@ -161,9 +163,12 @@ 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)
{
this.ExceptionSafeWrapper(
Expand Down Expand Up @@ -527,7 +532,9 @@ internal CimOperationOptions CreateOperationOptions()
}

private readonly Lazy<CimCustomOptionsDictionary> _jobSpecificCustomOptions;

internal abstract CimCustomOptionsDictionary CalculateJobSpecificCustomOptions();

private CimCustomOptionsDictionary GetJobSpecificCustomOptions()
{
return _jobSpecificCustomOptions.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ internal CimCmdletDefinitionContext(
private readonly IDictionary<string, string> _privateData;

private const string QueryLanguageKey = "QueryDialect";

private bool? _useEnumerateInstancesInsteadOfWql;

public bool UseEnumerateInstancesInsteadOfWql
{
get
Expand Down Expand Up @@ -112,6 +114,7 @@ public bool ClientSideShouldProcess

private Uri _resourceUri;
private bool _resourceUriHasBeenCalculated;

public Uri ResourceUri
{
get
Expand Down Expand Up @@ -140,6 +143,7 @@ public bool SkipTestConnection
}

private CimOperationFlags? _schemaConformanceLevel;

public CimOperationFlags SchemaConformanceLevel
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public virtual IEnumerable<NotFoundError> GetNotFoundErrors_IfThisIsTheOnlyFilte
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)
Expand Down Expand Up @@ -357,6 +358,7 @@ public BehaviorOnNoMatch BehaviorOnNoMatch
}

protected abstract BehaviorOnNoMatch GetDefaultBehaviorWhenNoMatchesFound(object cimTypedExpectedPropertyValue);

private BehaviorOnNoMatch _behaviorOnNoMatch;

public string PropertyName { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2776,6 +2776,7 @@ internal class SECURITY_ATTRIBUTES
public int nLength;
public SafeLocalMemHandle lpSecurityDescriptor;
public bool bInheritHandle;

public SECURITY_ATTRIBUTES()
{
this.nLength = 12;
Expand All @@ -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);
Expand Down Expand Up @@ -2828,6 +2830,7 @@ internal class STARTUPINFO
public SafeFileHandle hStdInput;
public SafeFileHandle hStdOutput;
public SafeFileHandle hStdError;

public STARTUPINFO()
{
this.lpReserved = IntPtr.Zero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,9 @@ protected override void EndProcessing()
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ public SwitchParameter PassThru

#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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary> Columns definition of the underlying Management List</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ private ErrorRecord GetErrorNoResultsFromRemoteEnd(string commandName)
}

private List<string> _commandsSkippedBecauseOfShadowing = new List<string>();

private void ReportSkippedCommands()
{
if (_commandsSkippedBecauseOfShadowing.Count != 0)
Expand Down Expand Up @@ -825,6 +826,7 @@ private bool IsCommandNameMatchingParameters(string commandName)
}

private Dictionary<string, object> _existingCommands;

private Dictionary<string, object> ExistingCommands
{
get
Expand Down Expand Up @@ -2119,6 +2121,7 @@ function Write-PSImplicitRemotingMessage
try { & $script:WriteHost -Object $message -ErrorAction SilentlyContinue } catch { }
}
";

private void GenerateHelperFunctionsWriteMessage(TextWriter writer)
{
if (writer == null)
Expand Down Expand Up @@ -2173,6 +2176,7 @@ function Set-PSImplicitRemotingSession

if ($PSSessionOverride) {{ Set-PSImplicitRemotingSession $PSSessionOverride }}
";

private void GenerateHelperFunctionsSetImplicitRunspace(TextWriter writer)
{
if (writer == null)
Expand Down Expand Up @@ -2204,6 +2208,7 @@ function Get-PSImplicitRemotingSessionOption
}}
}}
";

private void GenerateHelperFunctionsGetSessionOption(TextWriter writer)
{
if (writer == null)
Expand Down Expand Up @@ -2434,6 +2439,7 @@ private void GenerateHelperFunctionsGetImplicitRunspace(TextWriter writer)
}} -ErrorAction SilentlyContinue
}} catch {{ }}
";

private string GenerateReimportingOfModules()
{
StringBuilder result = new StringBuilder();
Expand Down Expand Up @@ -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}' ";

Expand Down Expand Up @@ -2748,6 +2755,7 @@ function Get-PSImplicitRemotingClientSideParameters
return $clientSideParameters
}
";

private void GenerateHelperFunctionsClientSideParameters(TextWriter writer)
{
if (writer == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ protected override void ProcessRecord()
}

private Dictionary<string, CommandTypes> _existingCommands;

private Dictionary<string, CommandTypes> ExistingCommands
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public sealed class JoinStringCommand : PSCmdlet
{
/// <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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ protected override void EndProcessing()
internal static class PSMarkdownOptionInfoCache
{
private static ConcurrentDictionary<Guid, PSMarkdownOptionInfo> markdownOptionInfoCache;

private const string MarkdownOptionInfoVariableName = "PSMarkdownOptionInfo";

static PSMarkdownOptionInfoCache()
Expand Down
Loading