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 @@ -879,7 +879,7 @@ protected override void ProcessRecord()
/// </summary>
internal class ExportCsvHelper : IDisposable
{
private char _delimiter;
private readonly char _delimiter;
private readonly BaseCsvWritingCommand.QuoteKind _quoteKind;
private readonly HashSet<string> _quoteFields;
private readonly StringBuilder _outputString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ internal class CustomSerialization
/// <summary>
/// Depth of serialization.
/// </summary>
private int _depth;
private readonly int _depth;

/// <summary>
/// XmlWriter to be used for writing.
/// </summary>
private XmlWriter _writer;
private readonly XmlWriter _writer;

/// <summary>
/// Whether type information should be included in the xml.
/// </summary>
private bool _notypeinformation;
private readonly bool _notypeinformation;

/// <summary>
/// CustomerSerializer used for formatting the output for _writer.
Expand Down Expand Up @@ -191,7 +191,7 @@ internal class
/// <summary>
/// Xml writer to be used.
/// </summary>
private XmlWriter _writer;
private readonly XmlWriter _writer;

/// <summary>
/// Check first call for every pipeline object to write Object tag else property tag.
Expand All @@ -201,7 +201,7 @@ internal class
/// <summary>
/// Should the type information to be shown.
/// </summary>
private bool _notypeinformation;
private readonly bool _notypeinformation;

/// <summary>
/// Check object call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public sealed class DebugRunspaceCommand : PSCmdlet

// Debugging to persist until Ctrl+C or Debugger 'Exit' stops cmdlet.
private bool _debugging;
private ManualResetEventSlim _newRunningScriptEvent = new ManualResetEventSlim(true);
private readonly ManualResetEventSlim _newRunningScriptEvent = new ManualResetEventSlim(true);
private RunspaceAvailability _previousRunspaceAvailability = RunspaceAvailability.None;

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ protected override void EndProcessing()
/// <summary>
/// Holds all the matching aliases for writing to the file.
/// </summary>
private Collection<AliasInfo> _matchingAliases = new Collection<AliasInfo>();
private readonly Collection<AliasInfo> _matchingAliases = new Collection<AliasInfo>();

private static string GetAliasLine(AliasInfo alias, string formatString)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.PowerShell.Commands
{
internal class ExpressionColumnInfo : ColumnInfo
{
private PSPropertyExpression _expression;
private readonly PSPropertyExpression _expression;

internal ExpressionColumnInfo(string staleObjectPropertyName, string displayName, PSPropertyExpression expression)
: base(staleObjectPropertyName, displayName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.PowerShell.Commands
{
internal class HeaderInfo
{
private List<ColumnInfo> _columns = new List<ColumnInfo>();
private readonly List<ColumnInfo> _columns = new List<ColumnInfo>();

internal void AddColumn(ColumnInfo col)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Microsoft.PowerShell.Commands
{
internal class OriginalColumnInfo : ColumnInfo
{
private string _liveObjectPropertyName;
private OutGridViewCommand _parentCmdlet;
private readonly string _liveObjectPropertyName;
private readonly OutGridViewCommand _parentCmdlet;

internal OriginalColumnInfo(string staleObjectPropertyName, string displayName, string liveObjectPropertyName, OutGridViewCommand parentCmdlet)
: base(staleObjectPropertyName, displayName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ internal static GridHeader ConstructGridHeader(PSObject input, OutGridViewComman

internal class ScalarTypeHeader : GridHeader
{
private Type _originalScalarType;
private readonly Type _originalScalarType;

internal ScalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
{
Expand All @@ -352,7 +352,7 @@ internal override void ProcessInputObject(PSObject input)

internal class NonscalarTypeHeader : GridHeader
{
private AppliesTo _appliesTo = null;
private readonly AppliesTo _appliesTo = null;

internal NonscalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ internal class OutWindowProxy : IDisposable

private bool _isWindowStarted;

private string _title;
private readonly string _title;

private OutputModeOption _outputMode;
private readonly OutputModeOption _outputMode;

private AutoResetEvent _closedEvent;

private OutGridViewCommand _parentCmdlet;
private readonly OutGridViewCommand _parentCmdlet;

private GraphicalHostReflectionWrapper _graphicalHostReflectionWrapper;
private readonly GraphicalHostReflectionWrapper _graphicalHostReflectionWrapper;

/// <summary>
/// Initializes a new instance of the OutWindowProxy class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.PowerShell.Commands
{
internal class ScalarTypeColumnInfo : ColumnInfo
{
private Type _type;
private readonly Type _type;

internal ScalarTypeColumnInfo(Type type)
: base(type.Name, type.Name)
Expand Down Expand Up @@ -45,7 +45,7 @@ internal override object GetValue(PSObject liveObject)

internal class ToStringColumnInfo : ColumnInfo
{
private OutGridViewCommand _parentCmdlet;
private readonly OutGridViewCommand _parentCmdlet;

internal ToStringColumnInfo(string staleObjectPropertyName, string displayName, OutGridViewCommand parentCmdlet)
: base(staleObjectPropertyName, displayName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public string LiteralPath

private bool _isLiteralPath = false;

private List<ExtendedTypeDefinition> _typeDefinitions = new List<ExtendedTypeDefinition>();
private readonly List<ExtendedTypeDefinition> _typeDefinitions = new List<ExtendedTypeDefinition>();

private bool _force;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void pd_PrintPage(object sender, PrintPageEventArgs ev)
/// <summary>
/// Name of the printer to print to. Null means default printer.
/// </summary>
private string _printerName = null;
private readonly string _printerName = null;

/// <summary>
/// Name of the font to use, if null the default is used.
Expand Down Expand Up @@ -315,13 +315,13 @@ private void pd_PrintPage(object sender, PrintPageEventArgs ev)
/// <summary>
/// Text lines ready to print (after output cache playback).
/// </summary>
private Queue<string> _lines = new Queue<string>();
private readonly Queue<string> _lines = new Queue<string>();

/// <summary>
/// Cached font object.
/// </summary>
private Font _printFont = null;

private WriteLineHelper _writeLineHelper;
private readonly WriteLineHelper _writeLineHelper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@ protected override void EndProcessing()
/// <summary>
/// Buffer used when buffering until the end.
/// </summary>
private StringBuilder _buffer = new StringBuilder();
private readonly StringBuilder _buffer = new StringBuilder();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public SwitchParameter Force

private MshMemberMatchOptions _matchOptions = MshMemberMatchOptions.None;

private HybridDictionary _typesAlreadyDisplayed = new HybridDictionary();
private readonly HybridDictionary _typesAlreadyDisplayed = new HybridDictionary();

/// <summary>
/// This method implements the ProcessRecord method for get-member command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ private void ThrowMinGreaterThanOrEqualMax(object minValue, object maxValue)

#region Random generator state

private static ReaderWriterLockSlim s_runspaceGeneratorMapLock = new ReaderWriterLockSlim();
private static readonly ReaderWriterLockSlim s_runspaceGeneratorMapLock = new ReaderWriterLockSlim();

// 1-to-1 mapping of runspaces and random number generators
private static Dictionary<Guid, PolymorphicRandomNumberGenerator> s_runspaceGeneratorMap = new Dictionary<Guid, PolymorphicRandomNumberGenerator>();
private static readonly Dictionary<Guid, PolymorphicRandomNumberGenerator> s_runspaceGeneratorMap = new Dictionary<Guid, PolymorphicRandomNumberGenerator>();

private static void CurrentRunspace_StateChanged(object sender, RunspaceStateEventArgs e)
{
Expand Down Expand Up @@ -597,8 +597,8 @@ internal PolymorphicRandomNumberGenerator(int seed)
_pseudoGenerator = new Random(seed);
}

private Random _pseudoGenerator = null;
private RandomNumberGenerator _cryptographicGenerator = null;
private readonly Random _pseudoGenerator = null;
private readonly RandomNumberGenerator _cryptographicGenerator = null;

/// <summary>
/// Generates a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ private ErrorRecord GetErrorNoResultsFromRemoteEnd(string commandName)
return errorRecord;
}

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

private void ReportSkippedCommands()
{
Expand Down Expand Up @@ -1919,9 +1919,9 @@ internal class ImplicitRemotingCodeGenerator

#region Constructor and shared private data

private PSSession _remoteRunspaceInfo;
private readonly PSSession _remoteRunspaceInfo;
private Guid _moduleGuid;
private InvocationInfo _invocationInfo;
private readonly InvocationInfo _invocationInfo;

internal ImplicitRemotingCodeGenerator(
PSSession remoteRunspaceInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ protected override void EndProcessing()
/// </summary>
internal static class PSMarkdownOptionInfoCache
{
private static ConcurrentDictionary<Guid, PSMarkdownOptionInfo> markdownOptionInfoCache;
private static readonly ConcurrentDictionary<Guid, PSMarkdownOptionInfo> markdownOptionInfoCache;

private const string MarkdownOptionInfoVariableName = "PSMarkdownOptionInfo";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ private TextMeasureInfo CreateTextMeasureInfo(Statistics stat)
/// The observed statistics keyed by property name.
/// If Property is not set, then the key used will be the value of thisObject.
/// </summary>
private MeasureObjectDictionary<Statistics> _statistics = new MeasureObjectDictionary<Statistics>();
private readonly MeasureObjectDictionary<Statistics> _statistics = new MeasureObjectDictionary<Statistics>();

/// <summary>
/// Whether or not a numeric conversion error occurred.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal CultureInfo Culture

internal static readonly ObjectCommandPropertyValue NonExistingProperty = new ObjectCommandPropertyValue();
internal static readonly ObjectCommandPropertyValue ExistingNullProperty = new ObjectCommandPropertyValue(null);
private bool _caseSensitive;
private readonly bool _caseSensitive;
internal CultureInfo cultureInfo = null;

/// <summary>
Expand Down Expand Up @@ -225,11 +225,11 @@ public int Compare(object first, object second)
return _cultureInfo.CompareInfo.Compare(firstString, secondString, _caseSensitive ? CompareOptions.None : CompareOptions.IgnoreCase) * (_ascendingOrder ? 1 : -1);
}

private CultureInfo _cultureInfo = null;
private readonly CultureInfo _cultureInfo = null;

private bool _ascendingOrder = true;
private readonly bool _ascendingOrder = true;

private bool _caseSensitive = false;
private readonly bool _caseSensitive = false;
}
#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ internal OrderByPropertyEntry CreateOrderByPropertyEntry(
#endregion Utils

// list of processed parameters obtained from the Expression array
private List<MshParameter> _mshParameterList = null;
private readonly List<MshParameter> _mshParameterList = null;

// list of unprocessed parameters obtained from the Expression array.
private List<MshParameter> _unexpandedParameterList = null;
Expand Down Expand Up @@ -698,7 +698,7 @@ internal static OrderByPropertyComparer CreateComparer(List<OrderByPropertyEntry
return new OrderByPropertyComparer(ascending, cultureInfo, caseSensitive);
}

private ObjectCommandComparer[] _propertyComparers = null;
private readonly ObjectCommandComparer[] _propertyComparers = null;
}

internal class IndexedOrderByPropertyComparer : IComparer<OrderByPropertyEntry>
Expand Down Expand Up @@ -727,6 +727,6 @@ public int Compare(OrderByPropertyEntry lhs, OrderByPropertyEntry rhs)
return result;
}

private OrderByPropertyComparer _orderByPropertyComparer = null;
private readonly OrderByPropertyComparer _orderByPropertyComparer = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal bool IsMatch(PSPropertyExpression expression)
return false;
}

private WildcardPattern[] _wildcardPatterns;
private readonly WildcardPattern[] _wildcardPatterns;
}

internal class SelectObjectExpressionParameterDefinition : CommandParameterDefinition
Expand Down Expand Up @@ -304,8 +304,11 @@ public PSObject StreamingDequeue()
}

private int _streamedObjectCount;
private int _first, _last, _skip, _skipLast;
private bool _firstOrLastSpecified;
private readonly int _first;
private readonly int _last;
private int _skip;
private readonly int _skipLast;
private readonly bool _firstOrLastSpecified;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public Encoding Encoding
#region Private variables and methods

// Instantiate a new instance of MailMessage
private MailMessage _mMailMessage = new MailMessage();
private readonly MailMessage _mMailMessage = new MailMessage();

private SmtpClient _mSmtpClient = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ internal class ShowCommandProxy
{
private const string ShowCommandHelperName = "Microsoft.PowerShell.Commands.ShowCommandInternal.ShowCommandHelper";

private ShowCommandCommand _cmdlet;
private readonly ShowCommandCommand _cmdlet;

private GraphicalHostReflectionWrapper _graphicalHostReflectionWrapper;
private readonly GraphicalHostReflectionWrapper _graphicalHostReflectionWrapper;

internal ShowCommandProxy(ShowCommandCommand cmdlet)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void Dispose()

// object used for synchronizes pipeline thread and stop thread
// access to waitHandle
private object _syncObject = new object();
private readonly object _syncObject = new object();

// this is set to true by stopProcessing
private bool _stopping = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public sealed class MeasureCommandCommand : PSCmdlet

#region private members

private System.Diagnostics.Stopwatch _stopWatch = new System.Diagnostics.Stopwatch();
private readonly System.Diagnostics.Stopwatch _stopWatch = new System.Diagnostics.Stopwatch();

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class UpdateTypeDataCommand : UpdateData
private const string DynamicTypeSet = "DynamicTypeSet";
private const string TypeDataSet = "TypeDataSet";

private static object s_notSpecified = new object();
private static readonly object s_notSpecified = new object();

private static bool HasBeenSpecified(object obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public int Timeout

#endregion parameters

private AutoResetEvent _eventArrived = new AutoResetEvent(false);
private readonly AutoResetEvent _eventArrived = new AutoResetEvent(false);
private PSEventArgs _receivedEvent = null;
private object _receivedEventLock = new object();
private readonly object _receivedEventLock = new object();
private WildcardPattern _matchPattern;

/// <summary>
Expand Down
Loading