aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2022-02-09 12:51:06 +0100
committerKarsten Heimrich <karsten.heimrich@qt.io>2022-02-10 06:52:37 +0000
commitf17daf02e5573077a3da9d2f71a3d5500413e0b1 (patch)
tree36bd57065789011f2cd36684c25493d76d4c9101
parent134748d4634c5005fa9e4e97994c921660388b01 (diff)
Inline variable declaration
Change-Id: I19a55a53173da4e6e5aeea5f40790b1dea6346ec Reviewed-by: Miguel Costa <miguel.costa@qt.io>
-rw-r--r--QtVsTest/Macro.cs6
-rw-r--r--QtVsTools.Core/CommandLineParser.cs15
-rw-r--r--QtVsTools.Core/Common/EnumExt.cs3
-rw-r--r--QtVsTools.Core/Messages.cs3
-rw-r--r--QtVsTools.Core/MsBuildProject.cs21
-rw-r--r--QtVsTools.Core/QMakeQuery.cs6
-rw-r--r--QtVsTools.Core/QtModules.cs3
-rw-r--r--QtVsTools.Core/QtMsBuild.cs34
-rw-r--r--QtVsTools.Core/VisualStudio/VsServiceProvider.cs6
-rw-r--r--QtVsTools.Core/WaitDialog.cs12
-rw-r--r--QtVsTools.Package/Common/PriorityQueue.cs13
-rw-r--r--QtVsTools.Package/Common/Prototyped.cs3
-rw-r--r--QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs6
-rw-r--r--QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs3
-rw-r--r--QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs37
-rw-r--r--QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs9
-rw-r--r--QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs3
-rw-r--r--QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs18
-rw-r--r--QtVsTools.Package/QML/Debugging/QmlDebugger.cs11
-rw-r--r--QtVsTools.Package/QML/Debugging/QmlFileSystem.cs6
-rw-r--r--QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs3
-rw-r--r--QtVsTools.Package/QML/Parser/QmlParserInterop.cs3
-rw-r--r--QtVsTools.Package/QtMsBuild/QtProjectBuild.cs3
-rw-r--r--QtVsTools.Package/QtMsBuild/QtProjectTracker.cs6
-rw-r--r--QtVsTools.Package/QtVsToolsPackage.cs3
-rw-r--r--QtVsTools.Package/VisualStudio/VsShell.cs11
-rw-r--r--QtVsTools.RegExpr/parser/Parser.cs6
-rw-r--r--QtVsTools.RegExpr/production/Production.cs6
-rw-r--r--QtVsTools.RegExpr/production/ProductionRuleAction.cs6
-rw-r--r--Tests/Test_QtMsBuild.Tasks/Test_Join.cs15
-rw-r--r--Tests/Test_QtVsTools.PriorityQueue/Test_PriorityQueue.cs13
31 files changed, 96 insertions, 197 deletions
diff --git a/QtVsTest/Macro.cs b/QtVsTest/Macro.cs
index be6bd41c..497359b5 100644
--- a/QtVsTest/Macro.cs
+++ b/QtVsTest/Macro.cs
@@ -926,8 +926,7 @@ namespace QtVsTest.Macros
foreach (var globalVar in GlobalVars.Values) {
string varName = globalVar.Name;
Type varType = globalVar.FieldInfo.FieldType;
- object value;
- if (Globals.TryGetValue(varName, out value)) {
+ if (Globals.TryGetValue(varName, out object value)) {
Type valueType = value.GetType();
if (!varType.IsAssignableFrom(valueType)) {
throw new InvalidCastException(string.Format(
@@ -967,8 +966,7 @@ namespace QtVsTest.Macros
static Macro GetMacro(string name)
{
- Macro macro;
- if (!Macros.TryGetValue(name, out macro))
+ if (!Macros.TryGetValue(name, out Macro macro))
return null;
return macro;
}
diff --git a/QtVsTools.Core/CommandLineParser.cs b/QtVsTools.Core/CommandLineParser.cs
index f66d0ef7..1b969367 100644
--- a/QtVsTools.Core/CommandLineParser.cs
+++ b/QtVsTools.Core/CommandLineParser.cs
@@ -117,8 +117,7 @@ namespace QtVsTools.Core.CommandLine
IEnumerable<string> Aliases(string optionName)
{
- int optionIndex;
- if (!nameHash.TryGetValue(optionName, out optionIndex)) {
+ if (!nameHash.TryGetValue(optionName, out int optionIndex)) {
return new List<string>();
}
return commandLineOptionList[optionIndex].Names;
@@ -203,8 +202,7 @@ namespace QtVsTools.Core.CommandLine
IEnumerator<string> argumentEnumerator, ref bool atEnd)
{
const char assignChar = '=';
- int optionOffset;
- if (nameHash.TryGetValue(optionName, out optionOffset)) {
+ if (nameHash.TryGetValue(optionName, out int optionOffset)) {
int assignPos = argument.IndexOf(assignChar);
bool withValue = !string.IsNullOrEmpty(
commandLineOptionList[optionOffset].ValueName);
@@ -355,10 +353,9 @@ namespace QtVsTools.Core.CommandLine
if (!RegisterFoundOption(optionName)) {
error = true;
} else {
- int optionOffset;
Trace.Assert(nameHash.TryGetValue(
optionName,
- out optionOffset));
+ out int optionOffset));
bool withValue = !string.IsNullOrEmpty(
commandLineOptionList[optionOffset].ValueName);
if (withValue) {
@@ -396,10 +393,9 @@ namespace QtVsTools.Core.CommandLine
if (argument.Length > 2) {
string possibleShortOptionStyleName = argument.Substring(1, 1);
- int shortOptionIdx;
if (nameHash.TryGetValue(
possibleShortOptionStyleName,
- out shortOptionIdx)) {
+ out int shortOptionIdx)) {
var arg = commandLineOptionList[shortOptionIdx];
if ((arg.Flags & Option.Flag.ShortOptionStyle) != 0) {
RegisterFoundOption(possibleShortOptionStyleName);
@@ -465,8 +461,7 @@ namespace QtVsTools.Core.CommandLine
public IEnumerable<string> Values(string optionName)
{
CheckParsed("Values");
- int optionOffset;
- if (nameHash.TryGetValue(optionName, out optionOffset)) {
+ if (nameHash.TryGetValue(optionName, out int optionOffset)) {
var values = optionValuesHash[optionOffset];
return values;
}
diff --git a/QtVsTools.Core/Common/EnumExt.cs b/QtVsTools.Core/Common/EnumExt.cs
index 79d84d01..d7e705d6 100644
--- a/QtVsTools.Core/Common/EnumExt.cs
+++ b/QtVsTools.Core/Common/EnumExt.cs
@@ -128,8 +128,7 @@ namespace QtVsTools.Common
/// </summary>
public static TEnum Cast<T, TEnum>(this T valueT, TEnum defaultValue) where TEnum : struct
{
- TEnum value;
- return TryCast(valueT, out value) ? value : defaultValue;
+ return TryCast(valueT, out TEnum value) ? value : defaultValue;
}
/// <summary>
diff --git a/QtVsTools.Core/Messages.cs b/QtVsTools.Core/Messages.cs
index 0f2680a7..aa39acfd 100644
--- a/QtVsTools.Core/Messages.cs
+++ b/QtVsTools.Core/Messages.cs
@@ -238,8 +238,7 @@ namespace QtVsTools.Core
if (!await MessageReady.ToTask(3000))
continue;
while (!msgQueue.IsEmpty) {
- Msg msg;
- if (!msgQueue.TryDequeue(out msg)) {
+ if (!msgQueue.TryDequeue(out Msg msg)) {
await Task.Yield();
continue;
}
diff --git a/QtVsTools.Core/MsBuildProject.cs b/QtVsTools.Core/MsBuildProject.cs
index 2efdad5a..01105838 100644
--- a/QtVsTools.Core/MsBuildProject.cs
+++ b/QtVsTools.Core/MsBuildProject.cs
@@ -375,10 +375,8 @@ namespace QtVsTools.Core
foreach (var pg in uncategorizedPropertyGroups) {
foreach (var p in pg.Elements().ToList()) {
var condition = p.Attribute("Condition") ?? pg.Attribute("Condition");
- XElement configPropertyGroup = null;
- if (condition != null)
- propertyGroups.TryGetValue((string)condition, out configPropertyGroup);
- if (configPropertyGroup != null) {
+ if (condition != null && propertyGroups
+ .TryGetValue((string)condition, out XElement configPropertyGroup)) {
p.Remove();
p.SetAttributeValue("Condition", null);
configPropertyGroup.Add(p);
@@ -524,12 +522,10 @@ namespace QtVsTools.Core
foreach (var configQtSettings in qtSettings) {
var configCondition = (string)configQtSettings.Attribute("Condition");
- XElement oldConfigQtInstall;
- if (oldQtInstall.TryGetValue(configCondition, out oldConfigQtInstall))
+ if (oldQtInstall.TryGetValue(configCondition, out XElement oldConfigQtInstall))
configQtSettings.Add(oldConfigQtInstall);
- XElement oldConfigQtSettings;
- if (oldQtSettings.TryGetValue(configCondition, out oldConfigQtSettings)) {
+ if (oldQtSettings.TryGetValue(configCondition, out XElement oldConfigQtSettings)) {
foreach (var qtSetting in oldConfigQtSettings.Elements())
configQtSettings.Add(qtSetting);
}
@@ -1050,8 +1046,7 @@ namespace QtVsTools.Core
return (string)cbt.Attribute("Include");
}
}
- string ouputFile;
- if (!properties.TryGetValue(QtMoc.Property.InputFile, out ouputFile))
+ if (!properties.TryGetValue(QtMoc.Property.InputFile, out string ouputFile))
return (string)cbt.Attribute("Include");
return ouputFile;
}
@@ -1076,8 +1071,7 @@ namespace QtVsTools.Core
Path.IsPathRooted(x) ? x : Path.Combine(projDir, x)));
var outputItems = new List<XElement>();
foreach (var outputFile in outputFiles) {
- List<XElement> mocOutput = null;
- if (projItemsByPath.TryGetValue(outputFile, out mocOutput)) {
+ if (projItemsByPath.TryGetValue(outputFile, out List<XElement> mocOutput)) {
outputItems.AddRange(mocOutput);
hasGeneratedFiles |= hasGeneratedFiles ? true : mocOutput
.Where(x => !x.Elements(ns + "ExcludedFromBuild")
@@ -1514,8 +1508,7 @@ namespace QtVsTools.Core
public string ExpandString(string stringToExpand)
{
- string expandedString;
- if (TryExpansionCache(stringToExpand, out expandedString))
+ if (TryExpansionCache(stringToExpand, out string expandedString))
return expandedString;
if (evaluateTarget == null) {
diff --git a/QtVsTools.Core/QMakeQuery.cs b/QtVsTools.Core/QMakeQuery.cs
index 9e79bbea..5d942839 100644
--- a/QtVsTools.Core/QMakeQuery.cs
+++ b/QtVsTools.Core/QMakeQuery.cs
@@ -81,11 +81,9 @@ namespace QtVsTools.Core
{
ThreadHelper.ThrowIfNotOnUIThread();
- string value = string.Empty;
- if (Properties.TryGetValue(name, out value))
+ if (Properties.TryGetValue(name, out string value))
return value;
- else
- return null;
+ return null;
}
}
diff --git a/QtVsTools.Core/QtModules.cs b/QtVsTools.Core/QtModules.cs
index 76b5c08d..4b4bd8c4 100644
--- a/QtVsTools.Core/QtModules.cs
+++ b/QtVsTools.Core/QtModules.cs
@@ -44,8 +44,7 @@ namespace QtVsTools.Core
public QtModule Module(int id)
{
- QtModule module;
- modules.TryGetValue(id, out module);
+ modules.TryGetValue(id, out QtModule module);
return module;
}
diff --git a/QtVsTools.Core/QtMsBuild.cs b/QtVsTools.Core/QtMsBuild.cs
index 25d2d898..705070f6 100644
--- a/QtVsTools.Core/QtMsBuild.cs
+++ b/QtVsTools.Core/QtMsBuild.cs
@@ -205,8 +205,7 @@ namespace QtVsTools.Core.QtMsBuild
void AddChange(ItemPropertyChange newChange)
{
- ItemPropertyChange oldChange;
- if (itemPropertyChanges.TryGetValue(newChange.Key, out oldChange)) {
+ if (itemPropertyChanges.TryGetValue(newChange.Key, out ItemPropertyChange oldChange)) {
if (oldChange.GroupKey == newChange.GroupKey) {
oldChange.CopyFrom(newChange);
return;
@@ -883,14 +882,13 @@ namespace QtVsTools.Core.QtMsBuild
{
properties = new Dictionary<Property, string>();
- string qtDir, inputPath, outputPath;
if (!ParseCommandLine(
commandLine,
macros,
ToolExecName,
- out qtDir,
- out inputPath,
- out outputPath)) {
+ out string qtDir,
+ out string inputPath,
+ out string outputPath)) {
return false;
}
@@ -1132,14 +1130,13 @@ namespace QtVsTools.Core.QtMsBuild
{
properties = new Dictionary<Property, string>();
- string qtDir, inputPath, outputPath;
if (!ParseCommandLine(
commandLine,
macros,
ToolExecName,
- out qtDir,
- out inputPath,
- out outputPath)) {
+ out string qtDir,
+ out string inputPath,
+ out string outputPath)) {
return false;
}
@@ -1159,8 +1156,7 @@ namespace QtVsTools.Core.QtMsBuild
properties[Property.Root] = parser.Value(options[Property.Root]);
if (parser.IsSet(options[Property.Compression])) {
- int level;
- if (!int.TryParse(parser.Value(options[Property.Compression]), out level))
+ if (!int.TryParse(parser.Value(options[Property.Compression]), out int level))
return false;
if (level < 1 || 9 < level)
return false;
@@ -1332,14 +1328,13 @@ namespace QtVsTools.Core.QtMsBuild
{
properties = new Dictionary<Property, string>();
- string qtDir, inputPath, outputPath;
if (!ParseCommandLine(
commandLine,
macros,
ToolExecName,
- out qtDir,
- out inputPath,
- out outputPath)) {
+ out string qtDir,
+ out string inputPath,
+ out string outputPath)) {
return false;
}
@@ -1475,14 +1470,13 @@ namespace QtVsTools.Core.QtMsBuild
{
properties = new Dictionary<Property, string>();
- string qtDir, inputPath, outputPath;
if (!ParseCommandLine(
commandLine,
macros,
ToolExecName,
- out qtDir,
- out inputPath,
- out outputPath)) {
+ out string qtDir,
+ out string inputPath,
+ out string outputPath)) {
return false;
}
diff --git a/QtVsTools.Core/VisualStudio/VsServiceProvider.cs b/QtVsTools.Core/VisualStudio/VsServiceProvider.cs
index dba16e89..349ed847 100644
--- a/QtVsTools.Core/VisualStudio/VsServiceProvider.cs
+++ b/QtVsTools.Core/VisualStudio/VsServiceProvider.cs
@@ -60,8 +60,7 @@ namespace QtVsTools.VisualStudio
if (Instance == null)
return null;
- object serviceObj;
- if (services.TryGetValue(new ServiceType(typeof(T), typeof(I)), out serviceObj))
+ if (services.TryGetValue(new ServiceType(typeof(T), typeof(I)), out object serviceObj))
return serviceObj as I;
var serviceInterface = Instance.GetService<T, I>();
@@ -82,8 +81,7 @@ namespace QtVsTools.VisualStudio
if (Instance == null)
return null;
- object serviceObj;
- if (services.TryGetValue(new ServiceType(typeof(T), typeof(I)), out serviceObj))
+ if (services.TryGetValue(new ServiceType(typeof(T), typeof(I)), out object serviceObj))
return serviceObj as I;
var serviceInterface = await Instance.GetServiceAsync<T, I>();
diff --git a/QtVsTools.Core/WaitDialog.cs b/QtVsTools.Core/WaitDialog.cs
index 819bdc76..cedc078c 100644
--- a/QtVsTools.Core/WaitDialog.cs
+++ b/QtVsTools.Core/WaitDialog.cs
@@ -56,8 +56,7 @@ namespace QtVsTools.Core
ThreadHelper.ThrowIfNotOnUIThread();
- bool canceled = false;
- int res = VsWaitDialog.HasCanceled(out canceled);
+ int res = VsWaitDialog.HasCanceled(out bool canceled);
if (res != VSConstants.S_OK)
return false;
@@ -82,8 +81,7 @@ namespace QtVsTools.Core
ThreadHelper.ThrowIfNotOnUIThread();
- IVsThreadedWaitDialog2 vsWaitDialog = null;
- factory.CreateInstance(out vsWaitDialog);
+ factory.CreateInstance(out IVsThreadedWaitDialog2 vsWaitDialog);
if (vsWaitDialog == null)
return null;
@@ -159,9 +157,8 @@ namespace QtVsTools.Core
ThreadHelper.ThrowIfNotOnUIThread();
- bool canceled = false;
int res = VsWaitDialog.UpdateProgress(message, progressText,
- statusBarText, currentStep, totalSteps, disableCancel, out canceled);
+ statusBarText, currentStep, totalSteps, disableCancel, out bool canceled);
if (res != VSConstants.S_OK)
return;
@@ -178,8 +175,7 @@ namespace QtVsTools.Core
ThreadHelper.ThrowIfNotOnUIThread();
Running = false;
- int canceled = 0;
- VsWaitDialog.EndWaitDialog(out canceled);
+ VsWaitDialog.EndWaitDialog(out int canceled);
Canceled = (canceled != 0);
}
diff --git a/QtVsTools.Package/Common/PriorityQueue.cs b/QtVsTools.Package/Common/PriorityQueue.cs
index 14bf551f..eb2c44af 100644
--- a/QtVsTools.Package/Common/PriorityQueue.cs
+++ b/QtVsTools.Package/Common/PriorityQueue.cs
@@ -102,11 +102,10 @@ namespace QtVsTools
if (item == null)
throw new InvalidOperationException("Item cannot be null.");
lock (CriticalSection) {
- T oldItem;
- if (ItemsByPriority.TryGetValue(priority, out oldItem) && !item.Equals(oldItem))
+ if (ItemsByPriority.TryGetValue(priority, out T oldItem) && !item.Equals(oldItem))
throw new InvalidOperationException("An item with the same priority exists.");
- TPriority oldPriority;
- if (ItemPriority.TryGetValue(GetItemKey(item), out oldPriority)) {
+
+ if (ItemPriority.TryGetValue(GetItemKey(item), out TPriority oldPriority)) {
ItemsByPriority.Remove(oldPriority);
--Count;
}
@@ -128,8 +127,7 @@ namespace QtVsTools
public T Peek()
{
lock (CriticalSection) {
- T result;
- if (!TryPeek(out result))
+ if (!TryPeek(out T result))
throw new InvalidOperationException("Queue is empty.");
return result;
}
@@ -167,8 +165,7 @@ namespace QtVsTools
public T Dequeue()
{
lock (CriticalSection) {
- T result;
- if (!TryDequeue(out result))
+ if (!TryDequeue(out T result))
throw new InvalidOperationException("Queue is empty.");
return result;
}
diff --git a/QtVsTools.Package/Common/Prototyped.cs b/QtVsTools.Package/Common/Prototyped.cs
index ac9c949c..66599f43 100644
--- a/QtVsTools.Package/Common/Prototyped.cs
+++ b/QtVsTools.Package/Common/Prototyped.cs
@@ -194,8 +194,7 @@ namespace QtVsTools
lock (classCriticalSection) {
- SubClass subClass = null;
- if (!classes.TryGetValue(type, out subClass)) {
+ if (!classes.TryGetValue(type, out SubClass subClass)) {
var newTypes = GetTypeHierarchy(type)
.Where(x => !classes.ContainsKey(x.Key));
diff --git a/QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs b/QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs
index f1564ccd..b1c3deda 100644
--- a/QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs
+++ b/QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs
@@ -522,8 +522,7 @@ namespace QtVsTools.Qml.Classification
public TValue Get(object client, TKey key)
{
lock (criticalSection) {
- ValueRef valueRef;
- if (!data.TryGetValue(key, out valueRef)) {
+ if (!data.TryGetValue(key, out ValueRef valueRef)) {
valueRef = new ValueRef
{
Value = GetDefaultValue(key),
@@ -541,8 +540,7 @@ namespace QtVsTools.Qml.Classification
{
IDisposable disposable = null;
lock (criticalSection) {
- ValueRef valueRef;
- if (data.TryGetValue(key, out valueRef)) {
+ if (data.TryGetValue(key, out ValueRef valueRef)) {
valueRef.ClientObjects.Remove(client);
if (valueRef.ClientObjects.Count == 0) {
data.Remove(key);
diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs
index 5aefbf29..bd806d14 100644
--- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs
+++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs
@@ -85,8 +85,7 @@ namespace QtVsTools.Qml.Debug.AD7
if (docPosition == null)
return false;
- string fileName;
- if (docPosition.GetFileName(out fileName) != VSConstants.S_OK)
+ if (docPosition.GetFileName(out string fileName) != VSConstants.S_OK)
return false;
if (!ValidExtensions.Where(x => string.Equals(x, Path.GetExtension(fileName))).Any())
diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs
index e4d5ed72..c6a90267 100644
--- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs
+++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs
@@ -106,8 +106,7 @@ namespace QtVsTools.Qml.Debug.AD7
if (string.IsNullOrEmpty(pszOptions))
return VSConstants.E_FAIL;
- uint procId;
- if (!uint.TryParse(pszOptions, out procId))
+ if (!uint.TryParse(pszOptions, out uint procId))
return VSConstants.E_FAIL;
var env = bstrEnv.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
@@ -120,13 +119,12 @@ namespace QtVsTools.Qml.Debug.AD7
FileSystem.RegisterRccFile(rccFile);
}
- IDebugProcess2 nativeProc;
var nativeProcId = new AD_PROCESS_ID
{
ProcessIdType = (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM,
dwProcessId = procId
};
- if (pPort.GetProcess(nativeProcId, out nativeProc) != VSConstants.S_OK)
+ if (pPort.GetProcess(nativeProcId, out IDebugProcess2 nativeProc) != VSConstants.S_OK)
return VSConstants.E_FAIL;
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
@@ -146,20 +144,11 @@ namespace QtVsTools.Qml.Debug.AD7
if (program == null)
return VSConstants.E_FAIL;
- IDebugPort2 port;
- if (process.GetPort(out port) != VSConstants.S_OK)
+ if (process.GetPort(out IDebugPort2 port) != VSConstants.S_OK)
return VSConstants.E_FAIL;
- string portName;
- port.GetPortName(out portName);
-
- Guid guidPort;
- port.GetPortId(out guidPort);
-
IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;
-
- IDebugPortNotify2 portNotify;
- if (defaultPort.GetPortNotify(out portNotify) != VSConstants.S_OK)
+ if (defaultPort.GetPortNotify(out IDebugPortNotify2 portNotify) != VSConstants.S_OK)
return VSConstants.E_FAIL;
if (portNotify.AddProgramNode(program) != VSConstants.S_OK)
@@ -183,8 +172,7 @@ namespace QtVsTools.Qml.Debug.AD7
DebugEvent.Send(new EngineCreateEvent(this));
- Guid pguidProgramId;
- if (rgpPrograms[0].GetProgramId(out pguidProgramId) != VSConstants.S_OK)
+ if (rgpPrograms[0].GetProgramId(out Guid pguidProgramId) != VSConstants.S_OK)
return VSConstants.E_FAIL;
program.ProgramId = pguidProgramId;
@@ -201,15 +189,10 @@ namespace QtVsTools.Qml.Debug.AD7
int IDebugEngineLaunch2.CanTerminateProcess(IDebugProcess2 pProcess)
{
- Guid procId;
- if (pProcess.GetProcessId(out procId) != VSConstants.S_OK)
+ if (pProcess.GetProcessId(out Guid procId) != VSConstants.S_OK)
return VSConstants.E_FAIL;
- Program program;
- if (!programs.TryGetValue(procId, out program))
- return VSConstants.S_FALSE;
-
- return VSConstants.S_OK;
+ return programs.TryGetValue(procId, out _) ? VSConstants.S_OK : VSConstants.S_FALSE;
}
public bool ProgramIsRunning(Program program)
@@ -219,12 +202,10 @@ namespace QtVsTools.Qml.Debug.AD7
int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 pProcess)
{
- Guid procId;
- if (pProcess.GetProcessId(out procId) != VSConstants.S_OK)
+ if (pProcess.GetProcessId(out Guid procId) != VSConstants.S_OK)
return VSConstants.E_FAIL;
- Program program;
- if (!programs.TryGetValue(procId, out program))
+ if (!programs.TryGetValue(procId, out Program program))
return VSConstants.S_FALSE;
programs.Remove(procId);
diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs
index 9859c196..8b467a13 100644
--- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs
+++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs
@@ -119,11 +119,9 @@ namespace QtVsTools.Qml.Debug.AD7
static string GetChildKey(string childName)
{
- int childIndex;
- if (int.TryParse(childName, out childIndex))
+ if (int.TryParse(childName, out int childIndex))
return string.Format("{0:D9}", childIndex);
- else
- return childName;
+ return childName;
}
int IDebugProperty2.SetValueAsString(string pszValue, uint dwRadix, uint dwTimeout)
@@ -241,8 +239,7 @@ namespace QtVsTools.Qml.Debug.AD7
public DEBUG_PROPERTY_INFO GetInfo(enum_DEBUGPROP_INFO_FLAGS dwFields)
{
- DEBUG_PROPERTY_INFO info;
- Info.Map(MappingToDEBUG_PROPERTY_INFO, dwFields, out info);
+ Info.Map(MappingToDEBUG_PROPERTY_INFO, dwFields, out DEBUG_PROPERTY_INFO info);
return info;
}
diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs
index a51f09d1..1d5f3b61 100644
--- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs
+++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs
@@ -152,9 +152,8 @@ namespace QtVsTools.Qml.Debug.AD7
uint dwTimeout,
out IEnumDebugPropertyInfo2 ppEnum)
{
- uint pcelt;
return ((IDebugStackFrame2)this)
- .EnumProperties(dwFields, dwRadix, guidFilter, dwTimeout, out pcelt, out ppEnum);
+ .EnumProperties(dwFields, dwRadix, guidFilter, dwTimeout, out _, out ppEnum);
}
#region //////////////////// Info /////////////////////////////////////////////////////////
diff --git a/QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs b/QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs
index 8351ec2f..fda28ba0 100644
--- a/QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs
+++ b/QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs
@@ -95,8 +95,7 @@ namespace QtVsTools.Qml.Debug
if (pProcess == null && pProgram.GetProcess(out pProcess) != VSConstants.S_OK)
return VSConstants.S_OK;
- Guid procGuid;
- if (pProcess.GetProcessId(out procGuid) != VSConstants.S_OK)
+ if (pProcess.GetProcessId(out Guid procGuid) != VSConstants.S_OK)
return VSConstants.S_OK;
// Run only once per process
@@ -124,14 +123,10 @@ namespace QtVsTools.Qml.Debug
else
return VSConstants.S_OK;
- string execPath;
- uint procId;
- if (!GetProcessInfo(pProcess, native, out execPath, out procId))
+ if (!GetProcessInfo(pProcess, native, out string execPath, out uint procId))
return VSConstants.S_OK;
- string execCmd;
- IEnumerable<string> rccItems;
- if (!GetProjectInfo(execPath, native, out execCmd, out rccItems))
+ if (!GetProjectInfo(execPath, native, out string execCmd, out IEnumerable<string> rccItems))
return VSConstants.S_OK;
ThreadHelper.ThrowIfNotOnUIThread();
@@ -142,9 +137,7 @@ namespace QtVsTools.Qml.Debug
Guid GetEngineId(IDebugProgram2 pProgram)
{
- string engineName;
- Guid engineGuid;
- if (pProgram.GetEngineInfo(out engineName, out engineGuid) != VSConstants.S_OK)
+ if (pProgram.GetEngineInfo(out _, out Guid engineGuid) != VSConstants.S_OK)
return Guid.Empty;
return engineGuid;
}
@@ -175,8 +168,7 @@ namespace QtVsTools.Qml.Debug
execPath = "";
procId = 0;
- string fileName;
- if (pProcess.GetName(enum_GETNAME_TYPE.GN_FILENAME, out fileName) != VSConstants.S_OK)
+ if (pProcess.GetName(enum_GETNAME_TYPE.GN_FILENAME, out string fileName) != VSConstants.S_OK)
return false;
var pProcessId = new AD_PROCESS_ID[1];
diff --git a/QtVsTools.Package/QML/Debugging/QmlDebugger.cs b/QtVsTools.Package/QML/Debugging/QmlDebugger.cs
index 0270e57c..d843726a 100644
--- a/QtVsTools.Package/QML/Debugging/QmlDebugger.cs
+++ b/QtVsTools.Package/QML/Debugging/QmlDebugger.cs
@@ -284,8 +284,7 @@ namespace QtVsTools.Qml.Debug
} else {
foreach (int breakpointId in evtBreak.Body.Breakpoints) {
- IBreakpoint breakpoint;
- if (!breakpoints.TryGetValue(breakpointId, out breakpoint))
+ if (!breakpoints.TryGetValue(breakpointId, out IBreakpoint breakpoint))
continue;
breakpoint.NotifyBreak();
}
@@ -428,13 +427,7 @@ namespace QtVsTools.Qml.Debug
public static bool CheckCommandLine(string execPath, string args)
{
- ushort portFrom;
- ushort portTo;
- string hostName;
- string fileName;
- bool block;
- return ParseCommandLine(
- execPath, args, out portFrom, out portTo, out hostName, out fileName, out block);
+ return ParseCommandLine(execPath, args, out _, out _, out _, out _, out _);
}
/// <summary>
diff --git a/QtVsTools.Package/QML/Debugging/QmlFileSystem.cs b/QtVsTools.Package/QML/Debugging/QmlFileSystem.cs
index fe794ad2..61d34dd0 100644
--- a/QtVsTools.Package/QML/Debugging/QmlFileSystem.cs
+++ b/QtVsTools.Package/QML/Debugging/QmlFileSystem.cs
@@ -156,8 +156,7 @@ namespace QtVsTools.Qml.Debug
qrcPath = string.Format("qrc:///{0}", qrcPath);
- QmlFile file;
- if (!files.TryGetValue(qrcPath, out file))
+ if (!files.TryGetValue(qrcPath, out QmlFile file))
return default(QmlFile);
return file;
@@ -190,8 +189,7 @@ namespace QtVsTools.Qml.Debug
return default(QmlFile);
}
- QmlFile file;
- if (files.TryGetValue(fullPath, out file))
+ if (files.TryGetValue(fullPath, out QmlFile file))
return file;
return new QmlFile
diff --git a/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs b/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs
index aadf03a7..844ac385 100644
--- a/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs
+++ b/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs
@@ -100,8 +100,7 @@ namespace QtVsTools.Qml.Debug.V4
{
while (!Disposing) {
eventReceived.WaitOne();
- Event evt;
- while (!Disposing && eventQueue.TryDequeue(out evt))
+ while (!Disposing && eventQueue.TryDequeue(out Event evt))
sink.NotifyEvent(evt);
}
}
diff --git a/QtVsTools.Package/QML/Parser/QmlParserInterop.cs b/QtVsTools.Package/QML/Parser/QmlParserInterop.cs
index 42b617d2..9052f401 100644
--- a/QtVsTools.Package/QML/Parser/QmlParserInterop.cs
+++ b/QtVsTools.Package/QML/Parser/QmlParserInterop.cs
@@ -314,8 +314,7 @@ namespace QtVsTools.Qml
if (ptrRef == IntPtr.Zero)
return;
- AstNode nodeRef;
- if (nodesBytPtr.TryGetValue(ptrRef, out nodeRef)) {
+ if (nodesBytPtr.TryGetValue(ptrRef, out AstNode nodeRef)) {
nodeProperty.SetValue(node, nodeRef);
} else {
List<KeyValuePair<AstNode, PropertyInfo>> pendingRefList;
diff --git a/QtVsTools.Package/QtMsBuild/QtProjectBuild.cs b/QtVsTools.Package/QtMsBuild/QtProjectBuild.cs
index 3d25da50..f2b3d1da 100644
--- a/QtVsTools.Package/QtMsBuild/QtProjectBuild.cs
+++ b/QtVsTools.Package/QtMsBuild/QtProjectBuild.cs
@@ -160,8 +160,7 @@ namespace QtVsTools.QtMsBuild
}
await Task.Delay(100);
}
- QtProjectBuild buildRequest;
- if (BuildQueue.TryDequeue(out buildRequest)) {
+ if (BuildQueue.TryDequeue(out QtProjectBuild buildRequest)) {
if (dispatchStatus == null) {
dispatchStatus = StatusCenter.PreRegister(
new TaskHandlerOptions
diff --git a/QtVsTools.Package/QtMsBuild/QtProjectTracker.cs b/QtVsTools.Package/QtMsBuild/QtProjectTracker.cs
index 3d7588cf..4a771c24 100644
--- a/QtVsTools.Package/QtMsBuild/QtProjectTracker.cs
+++ b/QtVsTools.Package/QtMsBuild/QtProjectTracker.cs
@@ -139,8 +139,7 @@ namespace QtVsTools.QtMsBuild
ThreadHelper.ThrowIfNotOnUIThread();
lock (StaticCriticalSection) {
- QtProjectTracker tracker = null;
- if (Instances.TryGetValue(project.FullName, out tracker))
+ if (Instances.TryGetValue(project.FullName, out QtProjectTracker tracker))
return tracker;
tracker = new QtProjectTracker
{
@@ -167,8 +166,7 @@ namespace QtVsTools.QtMsBuild
while (!QtVsToolsPackage.Instance.Zombied) {
while (InitQueue.IsEmpty)
await Task.Delay(100);
- QtProjectTracker tracker;
- if (InitQueue.TryDequeue(out tracker)) {
+ if (InitQueue.TryDequeue(out QtProjectTracker tracker)) {
if (InitStatus == null) {
await QtVsToolsPackage.Instance.JoinableTaskFactory.SwitchToMainThreadAsync();
tracker.BeginInitStatus();
diff --git a/QtVsTools.Package/QtVsToolsPackage.cs b/QtVsTools.Package/QtVsToolsPackage.cs
index e9f03b13..a1856863 100644
--- a/QtVsTools.Package/QtVsToolsPackage.cs
+++ b/QtVsTools.Package/QtVsToolsPackage.cs
@@ -203,8 +203,7 @@ namespace QtVsTools
var timeUiThreadEnd = initTimer.Elapsed;
var vm = QtVersionManager.The(initDone);
- var error = string.Empty;
- if (vm.HasInvalidVersions(out error))
+ if (vm.HasInvalidVersions(out string error))
Messages.Print(error);
///////////
diff --git a/QtVsTools.Package/VisualStudio/VsShell.cs b/QtVsTools.Package/VisualStudio/VsShell.cs
index a4c9a9bc..bf24f1cd 100644
--- a/QtVsTools.Package/VisualStudio/VsShell.cs
+++ b/QtVsTools.Package/VisualStudio/VsShell.cs
@@ -56,9 +56,8 @@ namespace QtVsTools.VisualStudio
return;
vsShell = VsServiceProvider.GetService<IVsShell>();
- object objProp;
- int res = vsShell.GetProperty((int)__VSSPROPID2.VSSPROPID_InstallRootDir, out objProp);
- if (res == VSConstants.S_OK && objProp is string property)
+ int res = vsShell.GetProperty((int)__VSSPROPID2.VSSPROPID_InstallRootDir, out object o);
+ if (res == VSConstants.S_OK && o is string property)
_InstallRootDir = property;
}
@@ -66,9 +65,8 @@ namespace QtVsTools.VisualStudio
{
ThreadHelper.ThrowIfNotOnUIThread();
- object value;
int res = context.GetProperty(
- (uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ExtObject, out value);
+ (uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ExtObject, out object value);
if (res == VSConstants.S_OK && value is EnvDTE.Project project)
return project;
return null;
@@ -78,9 +76,8 @@ namespace QtVsTools.VisualStudio
{
ThreadHelper.ThrowIfNotOnUIThread();
- object value;
int res = context.GetProperty(
- itemid, (int)__VSHPROPID.VSHPROPID_ExtObject, out value);
+ itemid, (int)__VSHPROPID.VSHPROPID_ExtObject, out object value);
if (res == VSConstants.S_OK && value is EnvDTE.ProjectItem item)
return item;
return null;
diff --git a/QtVsTools.RegExpr/parser/Parser.cs b/QtVsTools.RegExpr/parser/Parser.cs
index e9394529..60c6a0f7 100644
--- a/QtVsTools.RegExpr/parser/Parser.cs
+++ b/QtVsTools.RegExpr/parser/Parser.cs
@@ -116,11 +116,9 @@ namespace QtVsTools.SyntaxAnalysis
foreach (var node in nodes.Where(n => n.Token != Pattern.Root)) {
// Get nodes captured by parent token
- Token parentToken;
- if (!node.Token.Parents.TryGetValue(node.CaptureId, out parentToken))
+ if (!node.Token.Parents.TryGetValue(node.CaptureId, out Token parentToken))
throw new ParseErrorException("Unknown capture ID");
- ParseTree.Node[] parentNodes;
- if (!nodesByToken.TryGetValue(parentToken, out parentNodes))
+ if (!nodesByToken.TryGetValue(parentToken, out ParseTree.Node[] parentNodes))
throw new ParseErrorException("Missing parent nodes");
// Find parent node
int idx = Array.BinarySearch(parentNodes, node, ParseTree.Node.Comparer);
diff --git a/QtVsTools.RegExpr/production/Production.cs b/QtVsTools.RegExpr/production/Production.cs
index 055de762..324f0c5a 100644
--- a/QtVsTools.RegExpr/production/Production.cs
+++ b/QtVsTools.RegExpr/production/Production.cs
@@ -223,8 +223,7 @@ namespace QtVsTools.SyntaxAnalysis
public void Add(string tokenId, object prodObj)
{
Productions.Add(new KeyValuePair<string, object>(tokenId, prodObj));
- List<object> prodObjs;
- if (!ProductionsByTokenId.TryGetValue(tokenId, out prodObjs))
+ if (!ProductionsByTokenId.TryGetValue(tokenId, out List<object> prodObjs))
ProductionsByTokenId.Add(tokenId, prodObjs = new List<object>());
prodObjs.Add(prodObj);
}
@@ -234,8 +233,7 @@ namespace QtVsTools.SyntaxAnalysis
if (string.IsNullOrEmpty(tokenId))
return Empty<T>();
- List<object> tokenProds;
- if (!ProductionsByTokenId.TryGetValue(tokenId, out tokenProds))
+ if (!ProductionsByTokenId.TryGetValue(tokenId, out List<object> tokenProds))
return Empty<T>();
return tokenProds
diff --git a/QtVsTools.RegExpr/production/ProductionRuleAction.cs b/QtVsTools.RegExpr/production/ProductionRuleAction.cs
index 9276026a..e5ba6100 100644
--- a/QtVsTools.RegExpr/production/ProductionRuleAction.cs
+++ b/QtVsTools.RegExpr/production/ProductionRuleAction.cs
@@ -135,11 +135,9 @@ namespace QtVsTools.SyntaxAnalysis
public bool Execute(ref T prod, string value, params object[] operands)
{
int idx = 0;
- T1 x;
- T2 y;
- if (!GetOperand(out x, operands, ref idx))
+ if (!GetOperand(out T1 x, operands, ref idx))
return false;
- if (!GetOperand(out y, operands, ref idx))
+ if (!GetOperand(out T2 y, operands, ref idx))
return false;
if (!TestAssert(prod, value, x, y))
diff --git a/Tests/Test_QtMsBuild.Tasks/Test_Join.cs b/Tests/Test_QtMsBuild.Tasks/Test_Join.cs
index 78bebfba..2872f359 100644
--- a/Tests/Test_QtMsBuild.Tasks/Test_Join.cs
+++ b/Tests/Test_QtMsBuild.Tasks/Test_Join.cs
@@ -89,9 +89,8 @@ namespace QtVsTools.Test.QtMsBuild.Tasks
// ---------------
var criteria = new string[] { "Y" };
- ITaskItem[] result;
Assert.IsTrue(
- Join.Execute(LeftItems, RightItems, out result, criteria));
+ Join.Execute(LeftItems, RightItems, out ITaskItem[] result, criteria));
Assert.IsTrue(result != null && result.Length == 3);
Assert.IsTrue(result[0].GetMetadata("X") == "foo");
@@ -123,9 +122,8 @@ namespace QtVsTools.Test.QtMsBuild.Tasks
// -------------------
var criteria = new string[] { "ROW_NUMBER" };
- ITaskItem[] result;
Assert.IsTrue(
- Join.Execute(LeftItems, RightItems, out result, criteria));
+ Join.Execute(LeftItems, RightItems, out ITaskItem[] result, criteria));
Assert.IsTrue(result != null && result.Length == 3);
Assert.IsTrue(result[0].GetMetadata("X") == "foo");
@@ -157,9 +155,8 @@ namespace QtVsTools.Test.QtMsBuild.Tasks
// -------------------
var criteria = new string[] { "ROW_NUMBER", "Y" };
- ITaskItem[] result;
Assert.IsTrue(
- Join.Execute(LeftItems, RightItems, out result, criteria));
+ Join.Execute(LeftItems, RightItems, out ITaskItem[] result, criteria));
Assert.IsTrue(result != null && result.Length == 0);
}
@@ -186,9 +183,8 @@ namespace QtVsTools.Test.QtMsBuild.Tasks
.ToArray();
var criteria = new string[] { "ROW_NUMBER", "Y" };
- ITaskItem[] result;
Assert.IsTrue(
- Join.Execute(newLeftItems, RightItems, out result, criteria));
+ Join.Execute(newLeftItems, RightItems, out ITaskItem[] result, criteria));
Assert.IsTrue(result != null && result.Length == 1);
Assert.IsTrue(result[0].GetMetadata("X") == "zzz");
@@ -211,9 +207,8 @@ namespace QtVsTools.Test.QtMsBuild.Tasks
// --------------------- A | bar | 99 B | bar | 99 | bar
// --------------------- ----------------------
- ITaskItem[] result;
Assert.IsTrue(
- Join.Execute(LeftItems, RightItems, out result));
+ Join.Execute(LeftItems, RightItems, out ITaskItem[] result));
Assert.IsTrue(result != null && result.Length == 4);
Assert.IsTrue(result[0].GetMetadata("X") == "foo");
diff --git a/Tests/Test_QtVsTools.PriorityQueue/Test_PriorityQueue.cs b/Tests/Test_QtVsTools.PriorityQueue/Test_PriorityQueue.cs
index bffec6c3..dc0b1736 100644
--- a/Tests/Test_QtVsTools.PriorityQueue/Test_PriorityQueue.cs
+++ b/Tests/Test_QtVsTools.PriorityQueue/Test_PriorityQueue.cs
@@ -89,12 +89,11 @@ namespace QtVsTools.Test.PriorityQueue
public void TestTryPeek()
{
var q = new PunisherQueue<string>();
- string s;
- Assert.IsTrue(!q.TryPeek(out s));
+ Assert.IsTrue(!q.TryPeek(out _));
q.Enqueue("a");
q.Enqueue("b");
q.Enqueue("c");
- Assert.IsTrue(q.TryPeek(out s) && s == "a");
+ Assert.IsTrue(q.TryPeek(out string s) && s == "a");
Assert.IsTrue(string.Join("", q) == "abc");
}
@@ -121,12 +120,11 @@ namespace QtVsTools.Test.PriorityQueue
public void TestTryDequeue()
{
var q = new PunisherQueue<string>();
- string s;
- Assert.IsTrue(!q.TryDequeue(out s));
+ Assert.IsTrue(!q.TryDequeue(out _));
q.Enqueue("a");
q.Enqueue("b");
q.Enqueue("c");
- Assert.IsTrue(q.TryDequeue(out s) && s == "a");
+ Assert.IsTrue(q.TryDequeue(out string s) && s == "a");
Assert.IsTrue(string.Join("", q) == "bc");
}
@@ -177,8 +175,7 @@ namespace QtVsTools.Test.PriorityQueue
}
});
for (int i = 0; i < 10000; ++i) {
- string s;
- if (!q.TryDequeue(out s))
+ if (!q.TryDequeue(out _))
--i;
--n;
Thread.Yield();