Skip to content

[StyleCleanUp] Add readonly modifiers in PresentationBuildTasks #10729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
Expand All @@ -14,12 +14,13 @@ namespace MS.Internal
{
internal sealed class LocalizationParserHooks : ParserHooks
{
private MarkupCompiler _compiler;
private ArrayList _commentList;
private LocalizationComment _currentComment;
private LocalizationDirectivesToLocFile _directivesToFile;
private bool _isSecondPass;

private readonly LocalizationDirectivesToLocFile _directivesToFile;
private readonly MarkupCompiler _compiler;
private readonly ArrayList _commentList;
private readonly bool _isSecondPass;

private LocalizationComment _currentComment;

internal LocalizationParserHooks(
MarkupCompiler compiler ,
LocalizationDirectivesToLocFile directivesToFile,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
Expand All @@ -8,9 +8,16 @@ namespace MS.Internal
///<summary>
/// The CompilationUnit class
///</summary>
internal class CompilationUnit
internal class CompilationUnit
{
#region Constructors
private readonly string _defaultNamespace;
private readonly string _assemblyName;
private readonly string _language;
private readonly FileUnit[] _fileList;

private FileUnit _applicationFile = FileUnit.Empty;
private string _sourcePath = string.Empty;
private bool _pass2;

///<summary>constructor</summary>
public CompilationUnit(string assemblyName, string language, string defaultNamespace, FileUnit[] fileList)
Expand All @@ -21,8 +28,6 @@ public CompilationUnit(string assemblyName, string language, string defaultNames
_defaultNamespace = defaultNamespace;
}

#endregion Constructors

#region Properties

internal bool Pass2
Expand Down Expand Up @@ -71,17 +76,6 @@ public FileUnit[] FileList

#endregion Properties

#region Private Data

private bool _pass2 = false;
private string _assemblyName = string.Empty;
private string _language = string.Empty;
private string _sourcePath = string.Empty;
private string _defaultNamespace = string.Empty;
private FileUnit _applicationFile = FileUnit.Empty;
private FileUnit[] _fileList = null;

#endregion Private Data
}

#region ErrorEvent
Expand Down Expand Up @@ -149,10 +143,10 @@ public string FileName

#region Private Data

private int _lineNum;
private int _linePos;
private Exception _e;
private string _fileName;
private readonly int _lineNum;
private readonly int _linePos;
private readonly Exception _e;
private readonly string _fileName;

#endregion Private Data

Expand Down Expand Up @@ -199,7 +193,7 @@ internal SourceFileInfo SourceFileInfo

#region Private Data

private SourceFileInfo _sourceFileInfo;
private readonly SourceFileInfo _sourceFileInfo;

#endregion Private Data

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
Expand Down Expand Up @@ -43,9 +43,9 @@ public override string ToString()
return _path;
}

private string _path;
private string _linkAlias;
private string _logicalName;
private readonly string _path;
private readonly string _linkAlias;
private readonly string _logicalName;

private static FileUnit _empty = new FileUnit(String.Empty, String.Empty, String.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3427,10 +3427,12 @@ internal CodeTypeReference ElementTypeReference
}

private bool _isAllowedNameScope = true;
private Type _elementType = null;
private string [] _typeArgsList = null;
private string _localElementFullName = string.Empty;
protected CodeTypeReference _ctrElemTypeRef = null;

private readonly Type _elementType;
private readonly string[] _typeArgsList;
private readonly string _localElementFullName;

protected CodeTypeReference _ctrElemTypeRef;
}

private class CodeContextRoot : CodeContext
Expand Down Expand Up @@ -3503,8 +3505,9 @@ internal string SubClass
set { _subClass = value; }
}

private CodeTypeDeclaration _codeClass;
private CodeNamespace _codeNS;
private readonly CodeTypeDeclaration _codeClass;
private readonly CodeNamespace _codeNS;

private CodeMemberMethod _initializeComponentFn = null;
private CodeMemberMethod _hookupFn = null;
private CodeMemberMethod _styleConnectorFn = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -923,12 +923,13 @@ private bool ProcessedRootElement

#region Data

private MarkupCompiler _compiler;
private readonly MarkupCompiler _compiler;
private readonly bool _pass2;

private string _name = null;
private string _class = string.Empty;
private string _subClass = string.Empty;
private int _connectionId = 0;
private bool _pass2 = false;
private bool _isRootTag = false;
private bool _processedRootElement = false;
private bool _isSameScope = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -149,13 +149,14 @@ internal void CloseStream()

#region Private Data

private string _filePath;
private string _fileLinkAlias;
private string _fileLogicalName;
private readonly string _filePath;
private readonly string _fileLinkAlias;
private readonly string _fileLogicalName;
private readonly bool _isXamlFile;

private string _sourcePath;
private string _relativeSourceFilePath;
private Stream _stream;
private bool _isXamlFile;

private const string XAML = ".XAML";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ namespace MS.Internal.Tasks
// </summary>
internal class LocalReferenceFile
{
private bool _localizable;
private string _filePath;
private string _linkAlias;
private string _logicalName;
private static LocalReferenceFile _empty = new LocalReferenceFile(String.Empty, false, String.Empty, String.Empty);
private readonly bool _localizable;
private readonly string _filePath;
private readonly string _linkAlias;
private readonly string _logicalName;
private static readonly LocalReferenceFile _empty = new LocalReferenceFile(String.Empty, false, String.Empty, String.Empty);

private const char trueChar = 'T';
private const char falseChar = 'F';
private const char semiColonChar = ';';
Expand Down Expand Up @@ -332,9 +333,10 @@ internal string InternalTypeHelperFile
private LocalReferenceFile _localApplicationFile;
private LocalReferenceFile[] _localMarkupPages;

private string _localCacheFile;
private string _internalTypeHelperFile = String.Empty;
private ITaskFileService _taskFileService = null;

private readonly string _localCacheFile;
private readonly ITaskFileService _taskFileService;

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ internal bool Pass2Required

#region private data

private String [] _cacheInfoList;
private string _stateFilePath;
private ITaskFileService _taskFileService = null;
private readonly string[] _cacheInfoList;
private readonly string _stateFilePath;
private readonly ITaskFileService _taskFileService;

#endregion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -429,8 +429,8 @@ private string GetResolvedFilePath(string filePath, ref string newSourceDir)

#region private data

private MarkupCompiler _mc;
private string _sourceDir;
private readonly MarkupCompiler _mc;
private readonly string _sourceDir;
private TaskLoggingHelper _taskLogger;
private int _nErrors;
private string _unknownErrorID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -605,7 +605,8 @@ private bool ListIsNotEmpty(object [] list)

#region private data

private MarkupCompilePass1 _mcPass1;
private readonly MarkupCompilePass1 _mcPass1;

private RecompileCategory _analyzeResult;
private DateTime _lastCompileTime = new DateTime(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,14 @@ private bool IsFileInHostManager(string destinationFile)

#region private data field

private Task _buildTask;
private readonly Task _buildTask;

private IVsMSBuildTaskFileManager _hostFileManager;
private bool? _isRealBuild;
private static Guid s_hashSHA256Guid = new Guid(0x8829d00f, 0x11b8, 0x4213, 0x87, 0x8b, 0x77, 0x0e, 0x85, 0x97, 0xac, 0x16);
private static Guid s_hashSHA1Guid = new Guid(0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60);
private static Guid s_hashMD5Guid = new Guid(0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99);

private static readonly Guid s_hashSHA256Guid = new Guid(0x8829d00f, 0x11b8, 0x4213, 0x87, 0x8b, 0x77, 0x0e, 0x85, 0x97, 0xac, 0x16);
private static readonly Guid s_hashSHA1Guid = new Guid(0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60);
private static readonly Guid s_hashMD5Guid = new Guid(0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99);

#endregion private data field

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ private bool IsCleanBuild
private string[] _assembliesGeneratedDuringBuild;
private string[] _knownReferencePaths;

private string _sourceDir;
private readonly string _sourceDir;
private string _outputDir;

private ITaskItem[] _extraBuildControlFiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ private string SourceDir

private LocalizationDirectivesToLocFile _localizationDirectives = MS.Internal.LocalizationDirectivesToLocFile.None;

private string _sourceDir;
private readonly string _sourceDir;
private string _outputPath;
private string _language;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,11 +908,12 @@ private string GeneratePrefix()
return Guid.NewGuid().ToString();
}

private List<Uid> _uids;
private Hashtable _uidTable;
private string _fileName;
private Hashtable _sequenceMaxIds;
private List<string> _namespacePrefixes;
private readonly string _fileName;
private readonly List<Uid> _uids;
private readonly Hashtable _uidTable;
private readonly Hashtable _sequenceMaxIds;
private readonly List<string> _namespacePrefixes;

private int _rootElementLineNumber = -1;
private int _rootElementLinePosition = -1;
private string _namespacePrefixForMissingUid = null;
Expand Down Expand Up @@ -1236,11 +1237,14 @@ private void ProcessAttributeStart(WriterAction action)

private int _currentLineNumber = 1; // current line number in the source stream
private int _currentLinePosition = 1; // current line position in the source stream
private LineBuffer _lineBuffer; // buffer for one line's content
/// <summary>
/// Buffer for one line's content.
/// </summary>
private readonly LineBuffer _lineBuffer;

private UidCollector _collector;
private StreamReader _sourceReader;
private StreamWriter _targetWriter;
private readonly UidCollector _collector;
private readonly StreamReader _sourceReader;
private readonly StreamWriter _targetWriter;

//
// buffer for the content of a line
Expand Down