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 @@ -27,7 +27,7 @@ internal void ThrowTerminatingError(ErrorRecord errorRecord)
_command.ThrowTerminatingError(errorRecord);
}

private PSCmdlet _command;
private readonly PSCmdlet _command;
}

/// <summary>
Expand Down Expand Up @@ -133,7 +133,7 @@ public void Dispose()

private string _commandName = null;
private Type _commandType;
private List<CommandParameterInternal> _commandParameterList = new List<CommandParameterInternal>();
private readonly List<CommandParameterInternal> _commandParameterList = new List<CommandParameterInternal>();

private ExecutionContext _context = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ private void PopGroup()
/// <summary>
/// The formatting shape this formatter emits.
/// </summary>
private FormatShape _shape;
private readonly FormatShape _shape;

#region expression factory

Expand All @@ -537,7 +537,7 @@ internal ScriptBlock CreateScriptBlock(string scriptText)
private TypeInfoDataBase _typeInfoDataBase = null;

private FormattingCommandLineParameters _parameters = null;
private FormatViewManager _viewManager = new FormatViewManager();
private readonly FormatViewManager _viewManager = new FormatViewManager();

private int _enumerationLimit = InitialSessionState.DefaultFormatEnumerationLimit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void ProcessGlobbingCharactersError(bool originalParameterWasHashTable,

#endregion

private bool _noGlobbing;
private readonly bool _noGlobbing;
}

internal class AlignmentEntryDefinition : HashtableEntryDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ private FormatOutputContext FormatContext
/// <summary>
/// Context manager instance to guide the message traversal.
/// </summary>
private FormatMessagesContextManager _ctxManager = new FormatMessagesContextManager();
private readonly FormatMessagesContextManager _ctxManager = new FormatMessagesContextManager();

private FormattedObjectsCache _cache = null;

Expand Down Expand Up @@ -940,7 +940,7 @@ internal TableOutputContextBase(OutCommandInner cmd,
/// <summary>
/// Helper class to properly write a table using text output.
/// </summary>
private TableWriter _tableWriter = new TableWriter();
private readonly TableWriter _tableWriter = new TableWriter();
}

private sealed class TableOutputContext : TableOutputContextBase
Expand All @@ -951,7 +951,7 @@ private sealed class TableOutputContext : TableOutputContextBase

private const int WhitespaceAndPagerLineCount = 2;

private bool _repeatHeader = false;
private readonly bool _repeatHeader = false;

/// <summary>
/// Construct a context to push on the stack.
Expand Down Expand Up @@ -1174,7 +1174,7 @@ internal override void ProcessPayload(FormatEntryData fed)
/// <summary>
/// Writer to do the actual formatting.
/// </summary>
private ListWriter _listWriter = new ListWriter();
private readonly ListWriter _listWriter = new ListWriter();
}

private sealed class WideOutputContext : TableOutputContextBase
Expand Down Expand Up @@ -1357,7 +1357,7 @@ internal void Reset()
_arr[k] = null;
}

private string[] _arr;
private readonly string[] _arr;
private int _lastEmptySpot;
}
}
Expand Down Expand Up @@ -1395,7 +1395,7 @@ internal override void ProcessPayload(FormatEntryData fed)
_writer.WriteObject(cve.formatValueList);
}

private ComplexWriter _writer = new ComplexWriter();
private readonly ComplexWriter _writer = new ComplexWriter();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ private static int GetLastVisibleColumn(Span<int> columnWidths)
return columnWidths.Length - 1;
}

private int _tableWidth;
private int _minimumColumnWidth;
private int _separatorWidth;
private readonly int _tableWidth;
private readonly int _minimumColumnWidth;
private readonly int _separatorWidth;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private void WriteToScreen()
/// <summary>
/// Helper object to manage the frame-based indentation and margins.
/// </summary>
private IndentationManager _indentationManager = new IndentationManager();
private readonly IndentationManager _indentationManager = new IndentationManager();

/// <summary>
/// Buffer to accumulate partially constructed text.
Expand Down Expand Up @@ -243,7 +243,7 @@ public void Dispose()
}
}

private IndentationManager _mgr;
private readonly IndentationManager _mgr;
}

internal void Clear()
Expand Down Expand Up @@ -311,7 +311,7 @@ private int ComputeLeftIndentation()
return val;
}

private Stack<FrameInfo> _frameInfoStack = new Stack<FrameInfo>();
private readonly Stack<FrameInfo> _frameInfoStack = new Stack<FrameInfo>();
}

/// <summary>
Expand All @@ -331,7 +331,7 @@ internal sealed class StringManipulationHelper
private static readonly char s_softHyphen = '\u00AD';
private static readonly char s_hardHyphen = '\u2011';
private static readonly char s_nonBreakingSpace = '\u00A0';
private static Collection<string> s_cultureCollection = new Collection<string>();
private static readonly Collection<string> s_cultureCollection = new Collection<string>();

static StringManipulationHelper()
{
Expand Down Expand Up @@ -510,10 +510,10 @@ internal int ActiveLen
}
}

private StringCollection _retVal;
private readonly StringCollection _retVal;
private bool _addedFirstLine;
private int _firstLineLen;
private int _followingLinesLen;
private readonly int _firstLineLen;
private readonly int _followingLinesLen;
}

private static StringCollection GenerateLinesWithWordWrap(DisplayCells displayCells, string val, int firstLineLen, int followingLinesLen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace System.Management.Automation.Runspaces
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "FormatTable")]
public class FormatTableLoadException : RuntimeException
{
private Collection<string> _errors;
private readonly Collection<string> _errors;

#region Constructors

Expand Down Expand Up @@ -160,7 +160,7 @@ public sealed class FormatTable
{
#region Private Data

private TypeInfoDataBaseManager _formatDBMgr;
private readonly TypeInfoDataBaseManager _formatDBMgr;

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal class XmlLoaderLogger : IDisposable
#region tracer
// PSS/end-user tracer
[TraceSource("FormatFileLoading", "Loading format files")]
private static PSTraceSource s_formatFileLoadingtracer = PSTraceSource.GetTracer("FormatFileLoading", "Loading format files", false);
private static readonly PSTraceSource s_formatFileLoadingtracer = PSTraceSource.GetTracer("FormatFileLoading", "Loading format files", false);

#endregion tracer
/// <summary>
Expand Down Expand Up @@ -149,12 +149,12 @@ internal bool HasErrors
/// <summary>
/// If true, log entries to memory.
/// </summary>
private bool _saveInMemory = true;
private readonly bool _saveInMemory = true;

/// <summary>
/// List of entries logged if saveInMemory is true.
/// </summary>
private List<XmlLoaderLoggerEntry> _entries = new List<XmlLoaderLoggerEntry>();
private readonly List<XmlLoaderLoggerEntry> _entries = new List<XmlLoaderLoggerEntry>();

/// <summary>
/// True if we ever logged an error.
Expand All @@ -170,7 +170,7 @@ internal abstract class XmlLoaderBase : IDisposable
{
#region tracer
[TraceSource("XmlLoaderBase", "XmlLoaderBase")]
private static PSTraceSource s_tracer = PSTraceSource.GetTracer("XmlLoaderBase", "XmlLoaderBase");
private static readonly PSTraceSource s_tracer = PSTraceSource.GetTracer("XmlLoaderBase", "XmlLoaderBase");
#endregion tracer

/// <summary>
Expand Down Expand Up @@ -690,7 +690,7 @@ protected void SetLoadingInfoIsProductCode(bool isProductCode)
_loadingInfo.isProductCode = isProductCode;
}

private DatabaseLoadingInfo _loadingInfo = new DatabaseLoadingInfo();
private readonly DatabaseLoadingInfo _loadingInfo = new DatabaseLoadingInfo();

protected DatabaseLoadingInfo LoadingInfo
{
Expand All @@ -711,13 +711,13 @@ protected DatabaseLoadingInfo LoadingInfo

internal bool VerifyStringResources { get; } = true;

private int _maxNumberOfErrors = 30;
private readonly int _maxNumberOfErrors = 30;

private int _currentErrorCount = 0;

private bool _logStackActivity = false;
private readonly bool _logStackActivity = false;

private Stack<XmlLoaderStackFrame> _executionStack = new Stack<XmlLoaderStackFrame>();
private readonly Stack<XmlLoaderStackFrame> _executionStack = new Stack<XmlLoaderStackFrame>();

private XmlLoaderLogger _logger = new XmlLoaderLogger();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ private Assembly ResolveAssemblyNameInLoadedAssemblies(string assemblyName, bool
return result;
}

private Hashtable _assemblyReferences = new Hashtable(StringComparer.OrdinalIgnoreCase);
private readonly Hashtable _assemblyReferences = new Hashtable(StringComparer.OrdinalIgnoreCase);
}

private AssemblyNameResolver _assemblyNameResolver = new AssemblyNameResolver();
private Hashtable _resourceReferenceToAssemblyCache = new Hashtable();
private readonly AssemblyNameResolver _assemblyNameResolver = new AssemblyNameResolver();
private readonly Hashtable _resourceReferenceToAssemblyCache = new Hashtable();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal sealed class TypeInfoDataBaseManager
internal object updateDatabaseLock = new object();
// this is used to throw errors when updating a shared TypeTable.
internal bool isShared;
private List<string> _formatFileList;
private readonly List<string> _formatFileList;

internal bool DisableFormatTableUpdates { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ private bool MatchCondition(PSObject currentObject, PSPropertyExpression ex)
return retVal;
}

private PSPropertyExpressionFactory _expressionFactory;
private TypeInfoDataBase _db;
private Collection<string> _typeNameHierarchy;
private bool _useInheritance;
private readonly PSPropertyExpressionFactory _expressionFactory;
private readonly TypeInfoDataBase _db;
private readonly Collection<string> _typeNameHierarchy;
private readonly bool _useInheritance;

private int _bestMatchIndex = BestMatchIndexUndefined;
private TypeMatchItem _bestMatchItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal sealed partial class TypeInfoDataBaseLoader : XmlLoaderBase

#region tracer
[TraceSource("TypeInfoDataBaseLoader", "TypeInfoDataBaseLoader")]
private static PSTraceSource s_tracer = PSTraceSource.GetTracer("TypeInfoDataBaseLoader", "TypeInfoDataBaseLoader");
private static readonly PSTraceSource s_tracer = PSTraceSource.GetTracer("TypeInfoDataBaseLoader", "TypeInfoDataBaseLoader");
#endregion tracer

/// <summary>
Expand Down Expand Up @@ -2035,7 +2035,7 @@ internal ExpressionToken GenerateExpressionToken()
return _token;
}

private TypeInfoDataBaseLoader _loader;
private readonly TypeInfoDataBaseLoader _loader;
private ExpressionToken _token;
private bool _fatalError = false;
}
Expand Down Expand Up @@ -2175,7 +2175,7 @@ internal bool ProcessExpressionDirectives(XmlNode containerNode, List<XmlNode> u
private TextToken _textToken;
private ExpressionToken _expression;

private TypeInfoDataBaseLoader _loader;
private readonly TypeInfoDataBaseLoader _loader;
}

#endregion
Expand Down Expand Up @@ -2228,7 +2228,7 @@ internal ControlBase Control
}

private ControlBase _control;
private TypeInfoDataBaseLoader _loader;
private readonly TypeInfoDataBaseLoader _loader;
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ internal OutputContext ActiveOutputContext
/// <summary>
/// Internal stack to manage context.
/// </summary>
private Stack<OutputContext> _stack = new Stack<OutputContext>();
private readonly Stack<OutputContext> _stack = new Stack<OutputContext>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,13 @@ private bool EvaluateDisplayCondition(PSObject so, ExpressionToken conditionToke
return retVal;
}

private TypeInfoDataBase _db;
private DatabaseLoadingInfo _loadingInfo;
private PSPropertyExpressionFactory _expressionFactory;
private List<ControlDefinition> _controlDefinitionList;
private FormatErrorManager _errorManager;
private TerminatingErrorContext _errorContext;
private int _enumerationLimit;
private readonly TypeInfoDataBase _db;
private readonly DatabaseLoadingInfo _loadingInfo;
private readonly PSPropertyExpressionFactory _expressionFactory;
private readonly List<ControlDefinition> _controlDefinitionList;
private readonly FormatErrorManager _errorManager;
private readonly TerminatingErrorContext _errorContext;
private readonly int _enumerationLimit;
}

internal class TraversalInfo
Expand All @@ -412,8 +412,8 @@ internal TraversalInfo NextLevel
}
}

private int _level;
private int _maxDepth;
private readonly int _level;
private readonly int _maxDepth;
}

/// <summary>
Expand Down Expand Up @@ -771,13 +771,13 @@ private List<FormatValue> AddIndentationLevel(List<FormatValue> formatValueList)
/// <summary>
/// Indentation added to each level in the recursion.
/// </summary>
private int _indentationStep = 2;
private readonly int _indentationStep = 2;

private FormatErrorManager _errorManager;
private readonly FormatErrorManager _errorManager;

private PSPropertyExpressionFactory _expressionFactory;
private readonly PSPropertyExpressionFactory _expressionFactory;

private int _enumerationLimit;
private readonly int _enumerationLimit;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal sealed class FormatViewManager
{
#region tracer
[TraceSource("FormatViewBinding", "Format view binding")]
private static PSTraceSource s_formatViewBindingTracer = PSTraceSource.GetTracer("FormatViewBinding", "Format view binding", false);
private static readonly PSTraceSource s_formatViewBindingTracer = PSTraceSource.GetTracer("FormatViewBinding", "Format view binding", false);
#endregion tracer

private static string PSObjectTypeName(PSObject so)
Expand Down Expand Up @@ -677,12 +677,12 @@ private static ErrorRecord GenerateErrorRecord(FormattingError error)
return errorRecord;
}

private FormatErrorPolicy _formatErrorPolicy;
private readonly FormatErrorPolicy _formatErrorPolicy;

/// <summary>
/// Current list of failed PSPropertyExpression evaluations.
/// </summary>
private List<FormattingError> _formattingErrorList = new List<FormattingError>();
private readonly List<FormattingError> _formattingErrorList = new List<FormattingError>();
}
}

Loading