diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Localization/LocalizationParserHooks.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Localization/LocalizationParserHooks.cs index f30ddce55a8..002619560f1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Localization/LocalizationParserHooks.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Localization/LocalizationParserHooks.cs @@ -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; @@ -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, diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/CompilationUnit.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/CompilationUnit.cs index 83737af341f..079f30ed80e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/CompilationUnit.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/CompilationUnit.cs @@ -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; @@ -8,9 +8,16 @@ namespace MS.Internal /// /// The CompilationUnit class /// - 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; ///constructor public CompilationUnit(string assemblyName, string language, string defaultNamespace, FileUnit[] fileList) @@ -21,8 +28,6 @@ public CompilationUnit(string assemblyName, string language, string defaultNames _defaultNamespace = defaultNamespace; } -#endregion Constructors - #region Properties internal bool Pass2 @@ -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 @@ -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 @@ -199,7 +193,7 @@ internal SourceFileInfo SourceFileInfo #region Private Data - private SourceFileInfo _sourceFileInfo; + private readonly SourceFileInfo _sourceFileInfo; #endregion Private Data diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/FileUnit.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/FileUnit.cs index f035142f3ac..7a92b696026 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/FileUnit.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/FileUnit.cs @@ -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; @@ -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); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs index f21a36da2e9..ed52deb528c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs @@ -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 @@ -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; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs index bfb0d523857..70a7cb39db0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs @@ -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. //--------------------------------------------------------------------------- @@ -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; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Shared/SourceFileInfo.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Shared/SourceFileInfo.cs index 349b79651e4..8da957c1fd4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Shared/SourceFileInfo.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Shared/SourceFileInfo.cs @@ -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. //--------------------------------------------------------------------------- @@ -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"; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerLocalReference.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerLocalReference.cs index eb5e0db269f..dfe08a84cdc 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerLocalReference.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerLocalReference.cs @@ -25,11 +25,12 @@ namespace MS.Internal.Tasks // 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 = ';'; @@ -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 diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerState.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerState.cs index 06c74b63d2e..15864b8f4b7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerState.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerState.cs @@ -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 diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs index 45d4c9de5e1..4d8f02b308b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs @@ -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. //---------------------------------------------------------------------------------------- @@ -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; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/IncrementalCompileAnalyzer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/IncrementalCompileAnalyzer.cs index 64e6e2b7c4a..533f1783036 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/IncrementalCompileAnalyzer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/IncrementalCompileAnalyzer.cs @@ -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. //---------------------------------------------------------------------------------------- @@ -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); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/TaskFileService.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/TaskFileService.cs index 9a9f077c038..f0db1dfe38a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/TaskFileService.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/TaskFileService.cs @@ -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 diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs index 70512ce153f..37027929947 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs @@ -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; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass2.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass2.cs index 2ab3234ef87..8937fd10240 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass2.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass2.cs @@ -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; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/UidManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/UidManager.cs index f48f6de815b..a0ff59e77a3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/UidManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/UidManager.cs @@ -908,11 +908,12 @@ private string GeneratePrefix() return Guid.NewGuid().ToString(); } - private List _uids; - private Hashtable _uidTable; - private string _fileName; - private Hashtable _sequenceMaxIds; - private List _namespacePrefixes; + private readonly string _fileName; + private readonly List _uids; + private readonly Hashtable _uidTable; + private readonly Hashtable _sequenceMaxIds; + private readonly List _namespacePrefixes; + private int _rootElementLineNumber = -1; private int _rootElementLinePosition = -1; private string _namespacePrefixForMissingUid = null; @@ -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 + /// + /// Buffer for one line's content. + /// + 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