aboutsummaryrefslogtreecommitdiffstats
path: root/QtVsTools.Core
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2022-02-07 15:16:24 +0100
committerKarsten Heimrich <karsten.heimrich@qt.io>2022-02-09 18:54:18 +0000
commit6e9d9011fdcd3f2f7b754387d819231825c411e7 (patch)
tree78c9e17e23c11e19b4a65ba6e4d3948a56ccf870 /QtVsTools.Core
parent31dd0cafc6a99cdd6d36a8f8e8a55eb408110952 (diff)
Mark members readonly
Change-Id: I63f4a890400a37319eec064ec0fbd7bf6d6fb4e4 Reviewed-by: Miguel Costa <miguel.costa@qt.io>
Diffstat (limited to 'QtVsTools.Core')
-rw-r--r--QtVsTools.Core/CommandLineParser.cs15
-rw-r--r--QtVsTools.Core/CompilerToolWrapper.cs2
-rw-r--r--QtVsTools.Core/CxxStreamReader.cs4
-rw-r--r--QtVsTools.Core/LinkerToolWrapper.cs2
-rw-r--r--QtVsTools.Core/Messages.cs2
-rw-r--r--QtVsTools.Core/MocCmdChecker.cs4
-rw-r--r--QtVsTools.Core/MsBuildProject.cs11
-rw-r--r--QtVsTools.Core/ProFileContent.cs4
-rw-r--r--QtVsTools.Core/ProFileOption.cs4
-rw-r--r--QtVsTools.Core/ProSolution.cs4
-rw-r--r--QtVsTools.Core/ProjectExporter.cs2
-rw-r--r--QtVsTools.Core/ProjectImporter.cs2
-rw-r--r--QtVsTools.Core/QtModules.cs2
-rw-r--r--QtVsTools.Core/QtMsBuild.cs19
-rw-r--r--QtVsTools.Core/QtProject.cs20
-rw-r--r--QtVsTools.Core/QtVSIPSettings.cs6
-rw-r--r--QtVsTools.Core/QtVersionManager.cs9
-rw-r--r--QtVsTools.Core/VersionInformation.cs4
-rw-r--r--QtVsTools.Core/VisualStudio/VsServiceProvider.cs2
19 files changed, 58 insertions, 60 deletions
diff --git a/QtVsTools.Core/CommandLineParser.cs b/QtVsTools.Core/CommandLineParser.cs
index 3c4683d3..a11879ab 100644
--- a/QtVsTools.Core/CommandLineParser.cs
+++ b/QtVsTools.Core/CommandLineParser.cs
@@ -40,13 +40,12 @@ namespace QtVsTools.Core.CommandLine
public class Parser
{
-
- List<Option> commandLineOptionList = new List<Option>();
- Dictionary<string, int> nameHash = new Dictionary<string, int>();
- Dictionary<int, List<string>> optionValuesHash = new Dictionary<int, List<string>>();
- List<string> optionNames = new List<string>();
- List<string> positionalArgumentList = new List<string>();
- List<string> unknownOptionNames = new List<string>();
+ readonly List<Option> commandLineOptionList = new List<Option>();
+ readonly Dictionary<string, int> nameHash = new Dictionary<string, int>();
+ readonly Dictionary<int, List<string>> optionValuesHash = new Dictionary<int, List<string>>();
+ readonly List<string> optionNames = new List<string>();
+ readonly List<string> positionalArgumentList = new List<string>();
+ readonly List<string> unknownOptionNames = new List<string>();
bool needsParsing = true;
public enum SingleDashWordOptionMode
@@ -558,7 +557,7 @@ namespace QtVsTools.Core.CommandLine
static class Lexer
{
- static Regex lexer = new Regex(
+ static readonly Regex lexer = new Regex(
/* Newline */ @"(\n)" +
/* Unquoted */ @"|((?:(?:[^\s\""])|(?:(?<=\\)\""))+)" +
/* Quoted */ @"|(?:\""((?:(?:[^\""])|(?:(?<=\\)\""))+)\"")" +
diff --git a/QtVsTools.Core/CompilerToolWrapper.cs b/QtVsTools.Core/CompilerToolWrapper.cs
index a17099a0..88869426 100644
--- a/QtVsTools.Core/CompilerToolWrapper.cs
+++ b/QtVsTools.Core/CompilerToolWrapper.cs
@@ -44,7 +44,7 @@ namespace QtVsTools.Core
/// Using VCCLCompilerTool directly will break the VS integration for Win CE.
class CompilerToolWrapper
{
- private VCCLCompilerTool compilerTool;
+ private readonly VCCLCompilerTool compilerTool;
private readonly Object compilerObj;
private readonly Type compilerType;
diff --git a/QtVsTools.Core/CxxStreamReader.cs b/QtVsTools.Core/CxxStreamReader.cs
index 1e6721c7..f383ad13 100644
--- a/QtVsTools.Core/CxxStreamReader.cs
+++ b/QtVsTools.Core/CxxStreamReader.cs
@@ -42,12 +42,12 @@ namespace QtVsTools.Core
Normal, Comment, String
}
private State state = State.Normal;
- private StreamReader sr;
+ private readonly StreamReader sr;
private string partialLine;
bool disposed;
int _lineNum;
- string[] _lines;
+ readonly string[] _lines;
public CxxStreamReader(string[] lines)
{
diff --git a/QtVsTools.Core/LinkerToolWrapper.cs b/QtVsTools.Core/LinkerToolWrapper.cs
index e1e0a607..3de3ead7 100644
--- a/QtVsTools.Core/LinkerToolWrapper.cs
+++ b/QtVsTools.Core/LinkerToolWrapper.cs
@@ -39,7 +39,7 @@ namespace QtVsTools.Core
/// </summary>
public class LinkerToolWrapper
{
- private VCLinkerTool linker;
+ private readonly VCLinkerTool linker;
public LinkerToolWrapper(VCLinkerTool linkerTool)
{
diff --git a/QtVsTools.Core/Messages.cs b/QtVsTools.Core/Messages.cs
index c00208d6..7ec98a9e 100644
--- a/QtVsTools.Core/Messages.cs
+++ b/QtVsTools.Core/Messages.cs
@@ -194,7 +194,7 @@ namespace QtVsTools.Core
}
static bool shuttingDown = false;
- static ConcurrentQueue<Msg> msgQueue = new ConcurrentQueue<Msg>();
+ static readonly ConcurrentQueue<Msg> msgQueue = new ConcurrentQueue<Msg>();
static DTE Dte { get; set; } = null;
private static void OnBeginShutdown()
diff --git a/QtVsTools.Core/MocCmdChecker.cs b/QtVsTools.Core/MocCmdChecker.cs
index 56f69493..8bc8ec4b 100644
--- a/QtVsTools.Core/MocCmdChecker.cs
+++ b/QtVsTools.Core/MocCmdChecker.cs
@@ -34,8 +34,8 @@ namespace QtVsTools.Core
{
class MocCmdChecker
{
- private Regex backslashRegEx = new Regex(@"\\+\.?\\+");
- private Regex endRegEx = new Regex(@"\\\.?$");
+ private readonly Regex backslashRegEx = new Regex(@"\\+\.?\\+");
+ private readonly Regex endRegEx = new Regex(@"\\\.?$");
private string NormalizePath(string path)
{
diff --git a/QtVsTools.Core/MsBuildProject.cs b/QtVsTools.Core/MsBuildProject.cs
index 187382a2..88eeed34 100644
--- a/QtVsTools.Core/MsBuildProject.cs
+++ b/QtVsTools.Core/MsBuildProject.cs
@@ -64,7 +64,8 @@ namespace QtVsTools.Core
User,
Count
}
- MsBuildXmlFile[] files = new MsBuildXmlFile[(int)Files.Count];
+
+ readonly MsBuildXmlFile[] files = new MsBuildXmlFile[(int)Files.Count];
MsBuildProject()
{
@@ -93,7 +94,7 @@ namespace QtVsTools.Core
}
}
- private static XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";
+ private static readonly XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";
public static MsBuildProject Load(string pathToProject)
{
@@ -1462,12 +1463,12 @@ namespace QtVsTools.Core
class MSBuildEvaluator : IVSMacroExpander, IDisposable
{
- MsBuildXmlFile projFile;
+ readonly MsBuildXmlFile projFile;
string tempProjFilePath;
XElement evaluateTarget;
XElement evaluateProperty;
ProjectRootElement projRoot;
- public Dictionary<string, string> expansionCache;
+ public readonly Dictionary<string, string> expansionCache;
public Dictionary<string, string> Properties
{
@@ -1642,7 +1643,7 @@ namespace QtVsTools.Core
return true;
}
- static Regex ConditionParser =
+ static readonly Regex ConditionParser =
new Regex(@"\'\$\(Configuration[^\)]*\)\|\$\(Platform[^\)]*\)\'\=\=\'([^\']+)\'");
class MsBuildConverterProvider : IPropertyStorageProvider
diff --git a/QtVsTools.Core/ProFileContent.cs b/QtVsTools.Core/ProFileContent.cs
index 076798c2..f51fdf6c 100644
--- a/QtVsTools.Core/ProFileContent.cs
+++ b/QtVsTools.Core/ProFileContent.cs
@@ -73,8 +73,8 @@ namespace QtVsTools.Core
}
}
- private VCProject vcproj;
+ private readonly VCProject vcproj;
private bool export;
- private List<ProFileOption> options;
+ private readonly List<ProFileOption> options;
}
}
diff --git a/QtVsTools.Core/ProFileOption.cs b/QtVsTools.Core/ProFileOption.cs
index 276a8750..73d222ea 100644
--- a/QtVsTools.Core/ProFileOption.cs
+++ b/QtVsTools.Core/ProFileOption.cs
@@ -137,7 +137,7 @@ namespace QtVsTools.Core
private bool incComment;
private string comment;
private string newOpt;
- private string name;
- private List<string> list;
+ private readonly string name;
+ private readonly List<string> list;
}
}
diff --git a/QtVsTools.Core/ProSolution.cs b/QtVsTools.Core/ProSolution.cs
index f3df7418..f2f078e6 100644
--- a/QtVsTools.Core/ProSolution.cs
+++ b/QtVsTools.Core/ProSolution.cs
@@ -55,7 +55,7 @@ namespace QtVsTools.Core
}
}
- private List<ProFileContent> proFiles;
- private Solution prosln;
+ private readonly List<ProFileContent> proFiles;
+ private readonly Solution prosln;
}
}
diff --git a/QtVsTools.Core/ProjectExporter.cs b/QtVsTools.Core/ProjectExporter.cs
index 55d8c36e..757f1f3a 100644
--- a/QtVsTools.Core/ProjectExporter.cs
+++ b/QtVsTools.Core/ProjectExporter.cs
@@ -44,7 +44,7 @@ namespace QtVsTools.Core
/// </summary>
public class ProjectExporter
{
- private DTE dteObject;
+ private readonly DTE dteObject;
public ProjectExporter(DTE dte)
{
diff --git a/QtVsTools.Core/ProjectImporter.cs b/QtVsTools.Core/ProjectImporter.cs
index ea72953f..e90ae3c0 100644
--- a/QtVsTools.Core/ProjectImporter.cs
+++ b/QtVsTools.Core/ProjectImporter.cs
@@ -38,7 +38,7 @@ namespace QtVsTools.Core
{
public class ProjectImporter
{
- private DTE dteObject;
+ private readonly DTE dteObject;
const string projectFileExtension = ".vcxproj";
public ProjectImporter(DTE dte)
diff --git a/QtVsTools.Core/QtModules.cs b/QtVsTools.Core/QtModules.cs
index 52e2fbe4..82c013e5 100644
--- a/QtVsTools.Core/QtModules.cs
+++ b/QtVsTools.Core/QtModules.cs
@@ -38,7 +38,7 @@ namespace QtVsTools.Core
{
public class QtModules
{
- private static QtModules instance = new QtModules();
+ private static readonly QtModules instance = new QtModules();
private readonly Dictionary<int, QtModule> modules = new Dictionary<int, QtModule>();
public static QtModules Instance
diff --git a/QtVsTools.Core/QtMsBuild.cs b/QtVsTools.Core/QtMsBuild.cs
index d7235265..94355f8b 100644
--- a/QtVsTools.Core/QtMsBuild.cs
+++ b/QtVsTools.Core/QtMsBuild.cs
@@ -84,8 +84,7 @@ namespace QtVsTools.Core.QtMsBuild
public class QtMsBuildContainer
{
-
- IPropertyStorageProvider provider;
+ readonly IPropertyStorageProvider provider;
public QtMsBuildContainer(IPropertyStorageProvider provider)
{
this.provider = provider;
@@ -198,9 +197,9 @@ namespace QtVsTools.Core.QtMsBuild
return provider.GetProjectConfiguration(GetProject(), configName);
}
- Dictionary<string, ItemPropertyChange> itemPropertyChanges
+ readonly Dictionary<string, ItemPropertyChange> itemPropertyChanges
= new Dictionary<string, ItemPropertyChange>();
- Dictionary<string, List<ItemPropertyChange>> itemPropertyChangesGrouped
+ readonly Dictionary<string, List<ItemPropertyChange>> itemPropertyChangesGrouped
= new Dictionary<string, List<ItemPropertyChange>>();
bool pendingChanges = false;
@@ -658,8 +657,8 @@ namespace QtVsTools.Core.QtMsBuild
public abstract class QtTool
{
- protected CommandLineParser parser;
- protected CommandLineOption outputOption;
+ protected readonly CommandLineParser parser;
+ protected readonly CommandLineOption outputOption;
protected CommandLineOption helpOption;
protected CommandLineOption versionOption;
@@ -779,7 +778,7 @@ namespace QtVsTools.Core.QtMsBuild
AdditionalDependencies,
}
- Dictionary<Property, CommandLineOption> options
+ readonly Dictionary<Property, CommandLineOption> options
= new Dictionary<Property, CommandLineOption>();
public QtMoc() : base()
@@ -1078,7 +1077,7 @@ namespace QtVsTools.Core.QtMsBuild
AdditionalDependencies,
}
- Dictionary<Property, CommandLineOption> options
+ readonly Dictionary<Property, CommandLineOption> options
= new Dictionary<Property, CommandLineOption>();
public QtRcc() : base()
@@ -1272,7 +1271,7 @@ namespace QtVsTools.Core.QtMsBuild
PrintDebug,
}
- Dictionary<Property, CommandLineOption> options
+ readonly Dictionary<Property, CommandLineOption> options
= new Dictionary<Property, CommandLineOption>();
public QtRepc() : base(defaultInputOutput: false)
@@ -1436,7 +1435,7 @@ namespace QtVsTools.Core.QtMsBuild
AdditionalDependencies,
}
- Dictionary<Property, CommandLineOption> options
+ readonly Dictionary<Property, CommandLineOption> options
= new Dictionary<Property, CommandLineOption>();
public QtUic() : base()
diff --git a/QtVsTools.Core/QtProject.cs b/QtVsTools.Core/QtProject.cs
index 4c651fc5..283d2fa1 100644
--- a/QtVsTools.Core/QtProject.cs
+++ b/QtVsTools.Core/QtProject.cs
@@ -53,8 +53,8 @@ namespace QtVsTools.Core
private VCProject vcPro;
private MocCmdChecker mocCmdChecker;
private Array lastConfigurationRowNames;
- private static Dictionary<Project, QtProject> instances = new Dictionary<Project, QtProject>();
- private QtMsBuildContainer qtMsBuild;
+ private static readonly Dictionary<Project, QtProject> instances = new Dictionary<Project, QtProject>();
+ private readonly QtMsBuildContainer qtMsBuild;
public static QtVsTools.VisualStudio.IProjectTracker ProjectTracker { get; set; }
@@ -3688,8 +3688,7 @@ namespace QtVsTools.Core
public class VCMacroExpander : IVSMacroExpander
{
- object config;
-
+ readonly object config;
public VCMacroExpander(object config)
{
this.config = config;
@@ -3704,14 +3703,15 @@ namespace QtVsTools.Core
public class QtCustomBuildTool
{
- QtMsBuildContainer qtMsBuild;
- VCFileConfiguration vcConfig;
- VCFile vcFile;
- VCCustomBuildTool tool;
- VCMacroExpander macros;
+ readonly QtMsBuildContainer qtMsBuild;
+ readonly VCFileConfiguration vcConfig;
+ readonly VCFile vcFile;
+ readonly VCCustomBuildTool tool;
+ readonly VCMacroExpander macros;
enum FileItemType { Other = 0, CustomBuild, QtMoc, QtRcc, QtRepc, QtUic };
- FileItemType itemType = FileItemType.Other;
+ readonly FileItemType itemType = FileItemType.Other;
+
public QtCustomBuildTool(VCFileConfiguration vcConfig, QtMsBuildContainer container = null)
{
if (container != null)
diff --git a/QtVsTools.Core/QtVSIPSettings.cs b/QtVsTools.Core/QtVSIPSettings.cs
index 374cfb0f..10bdb5ef 100644
--- a/QtVsTools.Core/QtVSIPSettings.cs
+++ b/QtVsTools.Core/QtVSIPSettings.cs
@@ -46,9 +46,9 @@ namespace QtVsTools.Core
{
public static IQtVsToolsOptions Options { get; set; }
- static Hashtable mocDirCache = new Hashtable();
- static Hashtable uicDirCache = new Hashtable();
- static Hashtable rccDirCache = new Hashtable();
+ static readonly Hashtable mocDirCache = new Hashtable();
+ static readonly Hashtable uicDirCache = new Hashtable();
+ static readonly Hashtable rccDirCache = new Hashtable();
public static bool GetDisableAutoMocStepsUpdate()
{
diff --git a/QtVsTools.Core/QtVersionManager.cs b/QtVsTools.Core/QtVersionManager.cs
index 9353efab..ef7c3da1 100644
--- a/QtVsTools.Core/QtVersionManager.cs
+++ b/QtVsTools.Core/QtVersionManager.cs
@@ -43,8 +43,8 @@ namespace QtVsTools.Core
public class QtVersionManager
{
private static QtVersionManager instance;
- private string regVersionPath;
- private string strVersionKey;
+ private readonly string regVersionPath;
+ private readonly string strVersionKey;
private Hashtable versionCache;
protected QtVersionManager()
@@ -71,9 +71,8 @@ namespace QtVsTools.Core
}
}
- static EventWaitHandle
- packageInit = new EventWaitHandle(false, EventResetMode.ManualReset),
- packageInitDone = null;
+ private static readonly EventWaitHandle packageInit = new EventWaitHandle(false, EventResetMode.ManualReset);
+ private static EventWaitHandle packageInitDone = null;
static public QtVersionManager The(EventWaitHandle initDone = null)
{
diff --git a/QtVsTools.Core/VersionInformation.cs b/QtVsTools.Core/VersionInformation.cs
index 45129efd..1c7ff153 100644
--- a/QtVsTools.Core/VersionInformation.cs
+++ b/QtVsTools.Core/VersionInformation.cs
@@ -43,7 +43,7 @@ namespace QtVsTools.Core
{
//fields
public string name;
- public string qtDir;
+ public readonly string qtDir;
public uint qtMajor; // X in version x.y.z
public uint qtMinor; // Y in version x.y.z
public uint qtPatch; // Z in version x.y.z
@@ -79,7 +79,7 @@ namespace QtVsTools.Core
_cache.Clear();
}
- Dictionary<string, bool> _IsModuleAvailable;
+ readonly Dictionary<string, bool> _IsModuleAvailable;
public bool IsModuleAvailable(string module)
{
return _IsModuleAvailable?[module] ?? false;
diff --git a/QtVsTools.Core/VisualStudio/VsServiceProvider.cs b/QtVsTools.Core/VisualStudio/VsServiceProvider.cs
index e3db5e4d..dba16e89 100644
--- a/QtVsTools.Core/VisualStudio/VsServiceProvider.cs
+++ b/QtVsTools.Core/VisualStudio/VsServiceProvider.cs
@@ -44,7 +44,7 @@ namespace QtVsTools.VisualStudio
{
public static IVsServiceProvider Instance { get; set; }
- static ConcurrentDictionary<ServiceType, object> services
+ static readonly ConcurrentDictionary<ServiceType, object> services
= new ConcurrentDictionary<ServiceType, object>();
public static I GetService<I>()