diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2023-04-17 13:22:12 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2023-04-20 09:46:54 +0000 |
commit | e965bb6a43260552542f808aa9cae67566737a48 (patch) | |
tree | e423033f8b03c7597fab586367ee1e7dd43336d9 | |
parent | 07761bfb4dff0832147af4c155a865feb74aeeeb (diff) |
Remove redundant code
Change-Id: I94cc72280815ed31809747b93032dd8768fd75ca
Reviewed-by: Miguel Costa <miguel.costa@qt.io>
131 files changed, 417 insertions, 466 deletions
diff --git a/QtMSBuild/Properties/AssemblyInfo.cs b/QtMSBuild/Properties/AssemblyInfo.cs index 557ff9ef..f0ca09b8 100644 --- a/QtMSBuild/Properties/AssemblyInfo.cs +++ b/QtMSBuild/Properties/AssemblyInfo.cs @@ -8,7 +8,6 @@ ****************************************************************************/ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/QtMSBuild/Tasks/DumpItems.cs b/QtMSBuild/Tasks/DumpItems.cs index e4672521..108446b6 100644 --- a/QtMSBuild/Tasks/DumpItems.cs +++ b/QtMSBuild/Tasks/DumpItems.cs @@ -50,7 +50,7 @@ namespace QtVsTools.QtMsBuild.Tasks "AccessedTime", "CreatedTime", "DefiningProjectDirectory", "DefiningProjectExtension", "DefiningProjectFullPath", "DefiningProjectName", "Directory", "Extension", "Filename", "FullPath", "Identity", "ModifiedTime", - "RecursiveDir", "RelativeDir", "RootDir", + "RecursiveDir", "RelativeDir", "RootDir" }; if (Metadata == null) Metadata = ""; diff --git a/QtMSBuild/Tasks/Expand.cs b/QtMSBuild/Tasks/Expand.cs index 45d95e5b..0453aef8 100644 --- a/QtMSBuild/Tasks/Expand.cs +++ b/QtMSBuild/Tasks/Expand.cs @@ -45,7 +45,7 @@ namespace QtVsTools.QtMsBuild.Tasks "AccessedTime", "CreatedTime", "DefiningProjectDirectory", "DefiningProjectExtension", "DefiningProjectFullPath", "DefiningProjectName", "Directory", "Extension", "Filename", "FullPath", "Identity", "ModifiedTime", - "RecursiveDir", "RelativeDir", "RootDir", + "RecursiveDir", "RelativeDir", "RootDir" }; var newItems = new List<ITaskItem>(); foreach (var item in Items) { diff --git a/QtMSBuild/Tasks/Flatten.cs b/QtMSBuild/Tasks/Flatten.cs index 7b365aef..b9710805 100644 --- a/QtMSBuild/Tasks/Flatten.cs +++ b/QtMSBuild/Tasks/Flatten.cs @@ -64,7 +64,7 @@ namespace QtVsTools.QtMsBuild.Tasks "AccessedTime", "CreatedTime", "DefiningProjectDirectory", "DefiningProjectExtension", "DefiningProjectFullPath", "DefiningProjectName", "Directory", "Extension", "Filename", "FullPath", "Identity", "ModifiedTime", - "RecursiveDir", "RelativeDir", "RootDir", + "RecursiveDir", "RelativeDir", "RootDir" }; if (Metadata == null) Metadata = Array.Empty<string>(); @@ -82,7 +82,7 @@ namespace QtVsTools.QtMsBuild.Tasks { { "Item", itemName }, { "Name", name }, - { "Value", value }, + { "Value", value } })); } } diff --git a/QtMSBuild/Tasks/HostExec_LinuxSSL.cs b/QtMSBuild/Tasks/HostExec_LinuxSSL.cs index 5f2af32b..19c8a6c5 100644 --- a/QtMSBuild/Tasks/HostExec_LinuxSSL.cs +++ b/QtMSBuild/Tasks/HostExec_LinuxSSL.cs @@ -109,7 +109,7 @@ namespace QtVsTools.QtMsBuild.Tasks Command += " 2> " + RedirectStdErr; Command = string.Format("cd {0}/{1}; {2}", RemoteProjectDir, WorkingDirectory, Command); - var taskCopyFiles = new Microsoft.Build.Linux.Tasks.Execute() + var taskCopyFiles = new Microsoft.Build.Linux.Tasks.Execute { BuildEngine = BuildEngine, HostObject = HostObject, @@ -118,9 +118,9 @@ namespace QtVsTools.QtMsBuild.Tasks RemoteTarget = RemoteTarget, RemoteProjectDir = RemoteProjectDir, Command = string.Join("; ", createDirs.Select(x => string.Format("mkdir -p {0}", x))), - LocalFilesToCopyRemotelyMapping = localFilesToCopyRemotelyMapping, + LocalFilesToCopyRemotelyMapping = localFilesToCopyRemotelyMapping }; - var taskExec = new Microsoft.Build.Linux.Tasks.Execute() + var taskExec = new Microsoft.Build.Linux.Tasks.Execute { BuildEngine = BuildEngine, HostObject = HostObject, @@ -129,7 +129,7 @@ namespace QtVsTools.QtMsBuild.Tasks RemoteTarget = RemoteTarget, RemoteProjectDir = RemoteProjectDir, Command = Command, - RemoteFilesToCopyLocallyMapping = remoteFilesToCopyLocallyMapping, + RemoteFilesToCopyLocallyMapping = remoteFilesToCopyLocallyMapping }; Log.LogMessage("\r\n==== HostExec: Microsoft.Build.Linux.Tasks.Execute"); diff --git a/QtMSBuild/Tasks/HostExec_LinuxWSL.cs b/QtMSBuild/Tasks/HostExec_LinuxWSL.cs index 2348ead6..79d76206 100644 --- a/QtMSBuild/Tasks/HostExec_LinuxWSL.cs +++ b/QtMSBuild/Tasks/HostExec_LinuxWSL.cs @@ -97,14 +97,14 @@ namespace QtVsTools.QtMsBuild.Tasks Command); } - var taskExec = new Microsoft.Build.Linux.WSL.Tasks.ExecuteCommand() + var taskExec = new Microsoft.Build.Linux.WSL.Tasks.ExecuteCommand { BuildEngine = BuildEngine, HostObject = HostObject, ProjectDir = @"$(ProjectDir)", IntermediateDir = @"$(IntDir)", WSLPath = @"$(WSLPath)", - Command = Command, + Command = Command }; Log.LogMessage("\r\n==== HostExec: Microsoft.Build.Linux.WSL.Tasks.ExecuteCommand"); Log.LogMessage("ProjectDir: {0}", taskExec.ProjectDir); diff --git a/QtMSBuild/Tasks/HostExec_Windows.cs b/QtMSBuild/Tasks/HostExec_Windows.cs index 1c3bdbce..3d755d10 100644 --- a/QtMSBuild/Tasks/HostExec_Windows.cs +++ b/QtMSBuild/Tasks/HostExec_Windows.cs @@ -74,13 +74,13 @@ namespace QtVsTools.QtMsBuild.Tasks else if (!string.IsNullOrEmpty(RedirectStdErr)) Command += " 2> " + RedirectStdErr; - var taskExec = new Microsoft.Build.Tasks.Exec() + var taskExec = new Microsoft.Build.Tasks.Exec { BuildEngine = BuildEngine, HostObject = HostObject, WorkingDirectory = WorkingDirectory, Command = Command, - IgnoreExitCode = IgnoreExitCode, + IgnoreExitCode = IgnoreExitCode }; Log.LogMessage("\r\n==== HostExec: Microsoft.Build.Tasks.Exec"); diff --git a/QtMSBuild/Tasks/HostTranslatePaths_LinuxSSL.cs b/QtMSBuild/Tasks/HostTranslatePaths_LinuxSSL.cs index ceed47d7..4354f78e 100644 --- a/QtMSBuild/Tasks/HostTranslatePaths_LinuxSSL.cs +++ b/QtMSBuild/Tasks/HostTranslatePaths_LinuxSSL.cs @@ -82,7 +82,7 @@ namespace QtVsTools.QtMsBuild.Tasks { { "Item", item.GetMetadata("Item") }, { "Name", itemName }, - { "Value", itemValue }, + { "Value", itemValue } })); } Result = newItems.ToArray(); diff --git a/QtMSBuild/Tasks/HostTranslatePaths_LinuxWSL.cs b/QtMSBuild/Tasks/HostTranslatePaths_LinuxWSL.cs index 2b4725a3..231d63a0 100644 --- a/QtMSBuild/Tasks/HostTranslatePaths_LinuxWSL.cs +++ b/QtMSBuild/Tasks/HostTranslatePaths_LinuxWSL.cs @@ -69,7 +69,7 @@ namespace QtVsTools.QtMsBuild.Tasks { { "Item", item.GetMetadata("Item") }, { "Name", itemName }, - { "Value", itemValue }, + { "Value", itemValue } })); } Result = newItems.ToArray(); diff --git a/QtMSBuild/Tasks/Join.cs b/QtMSBuild/Tasks/Join.cs index 26f7a11c..299c4b52 100644 --- a/QtMSBuild/Tasks/Join.cs +++ b/QtMSBuild/Tasks/Join.cs @@ -68,7 +68,7 @@ namespace QtVsTools.QtMsBuild.Tasks "AccessedTime", "CreatedTime", "DefiningProjectDirectory", "DefiningProjectExtension", "DefiningProjectFullPath", "DefiningProjectName", "Directory", "Extension", "Filename", "FullPath", "Identity", "ModifiedTime", - "RecursiveDir", "RelativeDir", "RootDir", + "RecursiveDir", "RelativeDir", "RootDir" }; for (int leftRowNum = 0; leftRowNum < LeftItems.Length; leftRowNum++) { @@ -78,7 +78,7 @@ namespace QtVsTools.QtMsBuild.Tasks bool match = true; foreach (string field in matchFields) { if (field.Equals("ROW_NUMBER", StringComparison.OrdinalIgnoreCase)) { - match = (leftRowNum == rightRowNum); + match = leftRowNum == rightRowNum; } else { string leftField = leftItem.GetMetadata(field); string rightField = rightItem.GetMetadata(field); diff --git a/QtMSBuild/Tasks/ParseVarDefs.cs b/QtMSBuild/Tasks/ParseVarDefs.cs index 7be34352..9bc0a3ac 100644 --- a/QtMSBuild/Tasks/ParseVarDefs.cs +++ b/QtMSBuild/Tasks/ParseVarDefs.cs @@ -34,17 +34,17 @@ namespace QtVsTools.QtMsBuild.Tasks OutVarDefs = Regex.Matches(QtVars, @"\s*(\w+)\s*(?:;|=\s*(\w*)\s*(?:\/((?:\\.|[^;\/])*)\/((?:\\.|[^;\/])*)\/)?)?") .Cast<Match>() - .Where((Match x) => x.Groups.Count > 4 && !string.IsNullOrEmpty(x.Groups[1].Value)) - .Select((Match x) => x.Groups + .Where(x => x.Groups.Count > 4 && !string.IsNullOrEmpty(x.Groups[1].Value)) + .Select(x => x.Groups .Cast<Group>() - .Select((Group y) => !string.IsNullOrEmpty(y.Value) ? y.Value : null) + .Select(y => !string.IsNullOrEmpty(y.Value) ? y.Value : null) .ToArray()) - .Select((string[] x) => new TaskItem(x[1], + .Select(x => new TaskItem(x[1], new Dictionary<string, string> { { "Name" , x[2] ?? x[1] }, { "Pattern" , x[3] ?? ".*" }, - { "Value" , x[4] ?? "$0" }, + { "Value" , x[4] ?? "$0" } })) .ToArray(); #endregion diff --git a/QtMSBuild/Tasks/QtRunTask.cs b/QtMSBuild/Tasks/QtRunTask.cs index 14983336..1c1662d9 100644 --- a/QtMSBuild/Tasks/QtRunTask.cs +++ b/QtMSBuild/Tasks/QtRunTask.cs @@ -87,7 +87,7 @@ namespace QtVsTools.QtMsBuild.Tasks "AccessedTime", "CreatedTime", "DefiningProjectDirectory", "DefiningProjectExtension", "DefiningProjectFullPath", "DefiningProjectName", "Directory", "Extension", "Filename", "FullPath", "Identity", "ModifiedTime", - "RecursiveDir", "RelativeDir", "RootDir", + "RecursiveDir", "RelativeDir", "RootDir" }; // Output default values diff --git a/QtMSBuild/Tasks/QtRunWork.cs b/QtMSBuild/Tasks/QtRunWork.cs index d159981c..790f416d 100644 --- a/QtMSBuild/Tasks/QtRunWork.cs +++ b/QtMSBuild/Tasks/QtRunWork.cs @@ -52,7 +52,7 @@ namespace QtVsTools.QtMsBuild.Tasks // Work item key = "%(WorkType)(%(Identity))" Func<string, string, string> KeyString = (x, y) => string.Format("{0}{{{1}}}", x, y); - Func<ITaskItem, string> Key = (item) => + Func<ITaskItem, string> Key = item => KeyString(item.GetMetadata("WorkType"), item.ItemSpec); var workItemKeys = new HashSet<string>(QtWork.Select(x => Key(x)), Comparer); @@ -86,8 +86,8 @@ namespace QtVsTools.QtMsBuild.Tasks CreateNoWindow = true, UseShellExecute = false, RedirectStandardError = true, - RedirectStandardOutput = true, - }, + RedirectStandardOutput = true + } }) // In case of items with duplicate keys, use only the first one .GroupBy(x => x.Key, Comparer) @@ -200,7 +200,7 @@ namespace QtVsTools.QtMsBuild.Tasks // Process terminated; check exit code and close terminated.Add(workItem.Key); result[workItem.Key].SetMetadata("ExitCode", proc.ExitCode.ToString()); - ok &= (proc.ExitCode == 0); + ok &= proc.ExitCode == 0; proc.Close(); // Add postponed dependent items to work queue @@ -268,7 +268,7 @@ namespace QtVsTools.QtMsBuild.Tasks } // Process terminated; check exit code and close result[workItem.Key].SetMetadata("ExitCode", proc.ExitCode.ToString()); - ok &= (proc.ExitCode == 0); + ok &= proc.ExitCode == 0; proc.Close(); } else { // Process is still running; feed it back into the running queue @@ -278,7 +278,7 @@ namespace QtVsTools.QtMsBuild.Tasks if (QtDebug) { Log.LogMessage(MessageImportance.High, - string.Format("## QtRunWork result {0}", (ok ? "ok" : "FAILED!"))); + string.Format("## QtRunWork result {0}", ok ? "ok" : "FAILED!")); } Result = result.Values.ToArray(); diff --git a/QtVsTest/Macro.cs b/QtVsTest/Macro.cs index 21052fbc..25d210aa 100644 --- a/QtVsTest/Macro.cs +++ b/QtVsTest/Macro.cs @@ -111,7 +111,7 @@ namespace QtVsTest.Macros typeof(Macro).Assembly.FullName, typeof(EnvDTE.DTE).Assembly.FullName, typeof(AutomationElement).Assembly.FullName, - "System.Core", + "System.Core" }; IEnumerable<string> RefAssemblies { get; set; } @@ -124,7 +124,7 @@ namespace QtVsTest.Macros "Task = System.Threading.Tasks.Task", "System.Windows.Automation", "EnvDTE", - "EnvDTE80", + "EnvDTE80" }; private Dictionary<string, VSServiceRef> ServiceRefs { get; } = new() @@ -132,7 +132,7 @@ namespace QtVsTest.Macros { "Dte", new VSServiceRef { Name = "Dte", Interface = "DTE2", Type = "DTE" } - }, + } }; private Dictionary<string, GlobalVar> GlobalVars { get; } = new() @@ -140,7 +140,7 @@ namespace QtVsTest.Macros { "Result", new GlobalVar { Type = "string", Name = "Result", InitialValueExpr = "string.Empty" } - }, + } }; string CSharpMethodCode { get; set; } @@ -486,7 +486,7 @@ namespace QtVsTest.Macros var uiIterator = uiContext; foreach (var item in path) { var itemType = item.GetType(); - var scope = (uiIterator == UiRoot) ? TreeScope.Children : TreeScope.Subtree; + var scope = uiIterator == UiRoot ? TreeScope.Children : TreeScope.Subtree; if (itemType.IsAssignableFrom(typeof(string))) { // Find element by name var name = (string)item; @@ -496,14 +496,14 @@ namespace QtVsTest.Macros // Find element by name and type var itemParams = (string[])item; uiIterator = uiIterator.FindFirst(scope, - new AndCondition(itemParams.Select((x, i) => - (i == 0) ? new PropertyCondition( - AutomationElement.NameProperty, x) : - (i == 1) ? new PropertyCondition( - AutomationElement.LocalizedControlTypeProperty, x) : - (i == 2) ? new PropertyCondition( - AutomationElement.AutomationIdProperty, x) : - Condition.FalseCondition).ToArray())); + new AndCondition(itemParams.Select((x, i) => i switch + { + 0 => new PropertyCondition(AutomationElement.NameProperty, x), + 1 => new PropertyCondition( + AutomationElement.LocalizedControlTypeProperty, x), + 2 => new PropertyCondition(AutomationElement.AutomationIdProperty, x), + _ => Condition.FalseCondition + }).ToArray())); } if (uiIterator == null) throw new Exception($"Could not find UI element \"{item}\""); @@ -560,9 +560,9 @@ namespace QtVsTest.Macros if (s.Args.Count > 3 || string.IsNullOrEmpty(s.Code)) return ErrorMsg("Invalid #ui statement"); - bool uiVsRoot = (s.Args.Count > 1 && s.Args[1] == "VSROOT"); - bool uiDesktop = (s.Args.Count > 1 && s.Args[1] == "DESKTOP"); - bool uiHwnd = (s.Args.Count > 1 && s.Args[1] == "HWND"); + bool uiVsRoot = s.Args.Count > 1 && s.Args[1] == "VSROOT"; + bool uiDesktop = s.Args.Count > 1 && s.Args[1] == "DESKTOP"; + bool uiHwnd = s.Args.Count > 1 && s.Args[1] == "HWND"; string context; if (uiVsRoot) @@ -624,7 +624,7 @@ namespace QtVsTest.Macros return ErrorMsg("Invalid #ui statement"); string typeName = s.Args[1]; - string varName = (s.Args.Count > 2) ? s.Args[2] : string.Empty; + string varName = s.Args.Count > 2 ? s.Args[2] : string.Empty; if (!UI_TYPES.Contains(typeName)) return ErrorMsg("Invalid #ui statement"); @@ -774,7 +774,7 @@ namespace QtVsTest.Macros if (File.Exists(macroDllPath)) File.Delete(macroDllPath); - var cscParams = new CompilerParameters() + var cscParams = new CompilerParameters { GenerateInMemory = false, OutputAssembly = macroDllPath @@ -892,7 +892,7 @@ namespace QtVsTest.Macros } bool ok = !IsDefaultValue(value); - while (!ok && (tRemaining = (tMax - t.Elapsed)) > TimeSpan.Zero) { + while (!ok && (tRemaining = tMax - t.Elapsed) > TimeSpan.Zero) { await Task.Delay(10); try { value = await Task.Run(expr).WithTimeout(tRemaining); @@ -1008,31 +1008,31 @@ namespace QtVsTest.Macros bool NoError() { Result = MACRO_OK; - return (Ok = true); + return Ok = true; } bool Error() { Result = MACRO_ERROR; - return (Ok = false); + return Ok = false; } bool ErrorMsg(string errorMsg) { Result = MACRO_ERROR_MSG(errorMsg); - return (Ok = false); + return Ok = false; } bool ErrorException(Exception e) { Result = MACRO_ERROR_MSG($"{e.GetType().Name}\r\n\"{e.Message}\"\r\n{e.StackTrace}"); - return (Ok = false); + return Ok = false; } bool Warning(string warnMsg) { Result = MACRO_WARN_MSG(warnMsg); - return (Ok = true); + return Ok = true; } } } diff --git a/QtVsTest/MacroParser.cs b/QtVsTest/MacroParser.cs index 965e6bb3..d5b938d0 100644 --- a/QtVsTest/MacroParser.cs +++ b/QtVsTest/MacroParser.cs @@ -125,8 +125,8 @@ namespace QtVsTest.Macros StatementArg, StatementArgValue, StatementCode, - StatementCodeValue, - }; + StatementCodeValue + } bool Initialize() { @@ -194,7 +194,7 @@ namespace QtVsTest.Macros { new Rule<CodeLine> { - Capture((string value) => new CodeLine(value)) + Capture(value => new CodeLine(value)) } } & (LineBreak | EndOfFile); diff --git a/QtVsTest/MacroServer.cs b/QtVsTest/MacroServer.cs index e83a7f37..376ca8ea 100644 --- a/QtVsTest/MacroServer.cs +++ b/QtVsTest/MacroServer.cs @@ -100,7 +100,7 @@ namespace QtVsTest.Macros if (macro is { Ok: true, AutoRun: true, QuitWhenDone: true }) { await JoinableTaskFactory.SwitchToMainThreadAsync(Loop.Token); - dte.Solution.Close(false); + dte.Solution.Close(); dte.Quit(); await TaskScheduler.Default; Loop.Cancel(); diff --git a/QtVsTest/Properties/AssemblyInfo.cs b/QtVsTest/Properties/AssemblyInfo.cs index ce11e62c..48790c91 100644 --- a/QtVsTest/Properties/AssemblyInfo.cs +++ b/QtVsTest/Properties/AssemblyInfo.cs @@ -8,7 +8,6 @@ ****************************************************************************/ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/QtVsTools.Core/CommandLineParser.cs b/QtVsTools.Core/CommandLineParser.cs index 3d81a89e..ae3f16ae 100644 --- a/QtVsTools.Core/CommandLineParser.cs +++ b/QtVsTools.Core/CommandLineParser.cs @@ -40,10 +40,6 @@ namespace QtVsTools.Core.CommandLine } OptionsAfterPositionalArgumentsMode optionsAfterPositionalArgumentsMode = 0; - public Parser() - { - } - public string ApplicationDescription { get; @@ -97,7 +93,7 @@ namespace QtVsTools.Core.CommandLine public void SetOptionsAfterPositionalArgumentsMode( OptionsAfterPositionalArgumentsMode parsingMode) { - this.optionsAfterPositionalArgumentsMode = parsingMode; + optionsAfterPositionalArgumentsMode = parsingMode; } public bool AddOption(Option option) @@ -504,7 +500,7 @@ namespace QtVsTools.Core.CommandLine Unquoted = 2, Quoted = 3, Whitespace = 4 - }; + } static class Lexer { diff --git a/QtVsTools.Core/Common/Concurrent.cs b/QtVsTools.Core/Common/Concurrent.cs index 5157abd2..6d528948 100644 --- a/QtVsTools.Core/Common/Concurrent.cs +++ b/QtVsTools.Core/Common/Concurrent.cs @@ -173,7 +173,7 @@ namespace QtVsTools Action actionElse = null, Concurrent<TSubClass> _this = null) { - bool success = false; + bool success; lock (_this?.CriticalSection ?? StaticCriticalSection) { success = test(); if (success) @@ -273,7 +273,7 @@ namespace QtVsTools LeaveCriticalSection(); } else if (!IsNull(value) && IsNull(newValue)) { - value = default(T); + value = default; LeaveCriticalSection(); LeaveCriticalSection(); diff --git a/QtVsTools.Core/Common/Disposable.cs b/QtVsTools.Core/Common/Disposable.cs index f7193b38..49885175 100644 --- a/QtVsTools.Core/Common/Disposable.cs +++ b/QtVsTools.Core/Common/Disposable.cs @@ -31,7 +31,7 @@ namespace QtVsTools protected const bool DisposingFrom_ObjectFinalizer = false; protected const bool DisposingFrom_DisposeInterface = true; - private HashSet<IDisposableEventSink> eventSinks = null; + private HashSet<IDisposableEventSink> eventSinks; private HashSet<IDisposableEventSink> EventSinks => ThreadSafe(() => eventSinks ??= new HashSet<IDisposableEventSink>()); diff --git a/QtVsTools.Core/Common/EnumExt.cs b/QtVsTools.Core/Common/EnumExt.cs index 9c2917e0..84f6e86c 100644 --- a/QtVsTools.Core/Common/EnumExt.cs +++ b/QtVsTools.Core/Common/EnumExt.cs @@ -93,7 +93,7 @@ namespace QtVsTools.Common /// </summary> public static bool TryCast<T, TEnum>(this T valueT, out TEnum value) where TEnum : struct { - value = default(TEnum); + value = default; IEnumerable<Enum> enumValues = Enum.GetValues(typeof(TEnum)).OfType<Enum>() .Where(valueEnum => valueEnum.Cast<T>().Equals(valueT)) .ToList(); diff --git a/QtVsTools.Core/Common/Json/Serializable.cs b/QtVsTools.Core/Common/Json/Serializable.cs index 3117c51f..513f4679 100644 --- a/QtVsTools.Core/Common/Json/Serializable.cs +++ b/QtVsTools.Core/Common/Json/Serializable.cs @@ -27,9 +27,6 @@ namespace QtVsTools.Json private Serializer Serializer { get; set; } - protected Serializable() - { } - protected sealed override void InitializePrototype() { System.Diagnostics.Debug.Assert(IsPrototype); @@ -95,7 +92,7 @@ namespace QtVsTools.Json #region //////////////////// Deferred Objects ///////////////////////////////////////////// - List<IDeferredObject> deferredObjects = null; + List<IDeferredObject> deferredObjects; List<IDeferredObject> DeferredObjects { get diff --git a/QtVsTools.Core/Common/Json/SerializableEnum.cs b/QtVsTools.Core/Common/Json/SerializableEnum.cs index ec8b6980..3388c0af 100644 --- a/QtVsTools.Core/Common/Json/SerializableEnum.cs +++ b/QtVsTools.Core/Common/Json/SerializableEnum.cs @@ -39,11 +39,11 @@ namespace QtVsTools.Json where TEnum : struct { if (!typeof(TEnum).IsEnum) - return default(TEnum); + return default; var members = typeof(TEnum).GetMembers(); if (members.Length == 0) - return default(TEnum); + return default; var member = members.Where(x => { @@ -59,13 +59,10 @@ namespace QtVsTools.Json var field = member as FieldInfo; if (field == null) - return default(TEnum); + return default; var objValue = field.GetValue(null); - if (!(objValue is TEnum)) - return default(TEnum); - - return (TEnum)objValue; + return objValue is not TEnum value ? default : value; } } diff --git a/QtVsTools.Core/Common/Json/Serializer.cs b/QtVsTools.Core/Common/Json/Serializer.cs index a0c316fd..df85014a 100644 --- a/QtVsTools.Core/Common/Json/Serializer.cs +++ b/QtVsTools.Core/Common/Json/Serializer.cs @@ -100,7 +100,7 @@ namespace QtVsTools.Json try { serializer.WriteObject(writer, obj); writer.Close(); - return new JsonData() { Stream = stream }; + return new JsonData { Stream = stream }; } catch (Exception exception) { exception.Log(); if (stream is { CanRead: true, Length: > 0 }) @@ -153,7 +153,7 @@ namespace QtVsTools.Json { rawJsonData ??= Array.Empty<byte>(); - var data = new JsonData() + var data = new JsonData { Stream = new MemoryStream(rawJsonData) }; @@ -219,7 +219,7 @@ namespace QtVsTools.Json #region //////////////////// Data Contract Surrogate ////////////////////////////////////// static readonly Exclusive<Serializer> sharedInstance = new(); - private XmlReader reader = null; + private XmlReader reader; private readonly List<IDeferredObject> deferredObjects = new(); public static IJsonData GetCurrentJsonData() diff --git a/QtVsTools.Core/Common/LazyFactory.cs b/QtVsTools.Core/Common/LazyFactory.cs index bbf97684..2e8346b8 100644 --- a/QtVsTools.Core/Common/LazyFactory.cs +++ b/QtVsTools.Core/Common/LazyFactory.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Concurrent; -using System.Diagnostics; using System.Linq.Expressions; using System.Reflection; diff --git a/QtVsTools.Core/Common/PriorityQueue.cs b/QtVsTools.Core/Common/PriorityQueue.cs index 06a5ef11..da79f5a5 100644 --- a/QtVsTools.Core/Common/PriorityQueue.cs +++ b/QtVsTools.Core/Common/PriorityQueue.cs @@ -13,7 +13,7 @@ namespace QtVsTools public class PriorityQueue<T, TPriority> : BasePriorityQueue<T, TPriority> where TPriority : IComparable<TPriority> { - public PriorityQueue() : base() + public PriorityQueue() { } public PriorityQueue(Func<T, object> getItemKey) : base(getItemKey) @@ -32,7 +32,7 @@ namespace QtVsTools Dictionary<object, TPriority> ItemPriority { get; } T Head { get; set; } public int Count { get; private set; } - public bool IsEmpty => (Count == 0); + public bool IsEmpty => Count == 0; IEnumerable<T> Items => ThreadSafe(() => ItemsByPriority.Values.ToList()); IEnumerator<T> IEnumerable<T>.GetEnumerator() => Items.GetEnumerator(); @@ -47,7 +47,7 @@ namespace QtVsTools { ItemsByPriority = new SortedDictionary<TPriority, T>(); ItemPriority = new Dictionary<object, TPriority>(); - Head = default(T); + Head = default; Count = 0; GetItemKey = getItemKey; } @@ -59,7 +59,7 @@ namespace QtVsTools return; ItemsByPriority.Clear(); ItemPriority.Clear(); - Head = default(T); + Head = default; Count = 0; } } @@ -120,7 +120,7 @@ namespace QtVsTools ItemPriority.Remove(key); --Count; if (key == GetItemKey(Head)) - Head = IsEmpty ? default(T) : ItemsByPriority.First().Value; + Head = IsEmpty ? default : ItemsByPriority.First().Value; } } diff --git a/QtVsTools.Core/Common/Prototyped.cs b/QtVsTools.Core/Common/Prototyped.cs index e4682056..4f49fc44 100644 --- a/QtVsTools.Core/Common/Prototyped.cs +++ b/QtVsTools.Core/Common/Prototyped.cs @@ -65,7 +65,7 @@ namespace QtVsTools public TBase Prototype => ThisClass.Prototype; - SubClass thisClass = null; + SubClass thisClass; protected SubClass ThisClass { get @@ -139,11 +139,11 @@ namespace QtVsTools static SubClass Create(Type type, IEnumerable<Type> subTypes) { - return new SubClass() + return new SubClass { Type = type, SubTypes = subTypes, - Prototype = CreatePrototype(type), + Prototype = CreatePrototype(type) }; } diff --git a/QtVsTools.Core/Common/PunisherQueue.cs b/QtVsTools.Core/Common/PunisherQueue.cs index 9792cd69..27ad7c8e 100644 --- a/QtVsTools.Core/Common/PunisherQueue.cs +++ b/QtVsTools.Core/Common/PunisherQueue.cs @@ -9,7 +9,7 @@ namespace QtVsTools { public class PunisherQueue<T> : BasePriorityQueue<T, long> { - public PunisherQueue() : base() + public PunisherQueue() { } public PunisherQueue(Func<T, object> getItemKey) : base(getItemKey) diff --git a/QtVsTools.Core/Common/Timestamp.cs b/QtVsTools.Core/Common/Timestamp.cs index 0edd4d3a..1e500e76 100644 --- a/QtVsTools.Core/Common/Timestamp.cs +++ b/QtVsTools.Core/Common/Timestamp.cs @@ -20,7 +20,7 @@ namespace QtVsTools long t = Stopwatch.GetTimestamp(); if (t <= LastTimestamp) t = LastTimestamp + 1; - return (LastTimestamp = t); + return LastTimestamp = t; } } diff --git a/QtVsTools.Core/CxxStreamReader.cs b/QtVsTools.Core/CxxStreamReader.cs index 01f0da29..e3da32ba 100644 --- a/QtVsTools.Core/CxxStreamReader.cs +++ b/QtVsTools.Core/CxxStreamReader.cs @@ -65,7 +65,7 @@ namespace QtVsTools.Core public string ReadLine(bool removeStrings = false) { - var line = string.Empty; + string line; if (sr != null) { do { line = sr.ReadLine(); diff --git a/QtVsTools.Core/Extensions.cs b/QtVsTools.Core/Extensions.cs index 61dc1860..b7188da8 100644 --- a/QtVsTools.Core/Extensions.cs +++ b/QtVsTools.Core/Extensions.cs @@ -18,7 +18,7 @@ namespace QtVsTools.Core return original; } - int pos = 0, index = 0; + int pos = 0, index; var result = new System.Text.StringBuilder(); while ((index = original.IndexOf(oldValue, pos, comparison)) >= 0) { result.Append(original, pos, index - pos).Append(newValue); diff --git a/QtVsTools.Core/Filters.cs b/QtVsTools.Core/Filters.cs index b6e53217..4b881a77 100644 --- a/QtVsTools.Core/Filters.cs +++ b/QtVsTools.Core/Filters.cs @@ -54,7 +54,7 @@ namespace QtVsTools.Core { UniqueIdentifier = "{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}", Name = "Generated Files", - Filter = "moc;h;cpp", + Filter = "moc;h;cpp" }; } } diff --git a/QtVsTools.Core/HelperFunctions.cs b/QtVsTools.Core/HelperFunctions.cs index 7072de41..53114b65 100644 --- a/QtVsTools.Core/HelperFunctions.cs +++ b/QtVsTools.Core/HelperFunctions.cs @@ -85,7 +85,7 @@ namespace QtVsTools.Core return ".\\"; path = path.Trim(); - path = HelperFunctions.ToNativeSeparator(path); + path = ToNativeSeparator(path); var tmp = string.Empty; while (tmp != path) { @@ -134,7 +134,7 @@ namespace QtVsTools.Core var diArray = dir.Split(Path.DirectorySeparatorChar); var minLen = fiArray.Length < diArray.Length ? fiArray.Length : diArray.Length; - int i = 0, j = 0, commonParts = 0; + int i = 0, j, commonParts = 0; while (i < minLen && fiArray[i].ToLower() == diArray[i].ToLower()) { commonParts++; @@ -315,8 +315,7 @@ namespace QtVsTools.Core try { cxxSr = new CxxStreamReader(content.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); - string strLine; - while (!found && (strLine = cxxSr.ReadLine(suppressStrings)) != null) { + while (!found && cxxSr.ReadLine(suppressStrings) is {} strLine) { foreach (var str in searchStrings) { if (strLine.IndexOf(str, comparisonType) != -1) { found = true; @@ -326,8 +325,7 @@ namespace QtVsTools.Core } cxxSr.Close(); } catch (Exception) { - if (cxxSr != null) - cxxSr.Close(); + cxxSr?.Close(); } return found; } @@ -426,11 +424,11 @@ namespace QtVsTools.Core continue; // can be in any filter - if (IsTranslationFile(vcfile.Name) && (filter == FilesToList.FL_Translation)) + if (IsTranslationFile(vcfile.Name) && filter == FilesToList.FL_Translation) fileList.Add(FromNativeSeparators(vcfile.RelativePath)); // can also be in any filter - if (IsWinRCFile(vcfile.Name) && (filter == FilesToList.FL_WinResource)) + if (IsWinRCFile(vcfile.Name) && filter == FilesToList.FL_WinResource) fileList.Add(FromNativeSeparators(vcfile.RelativePath)); if (IsGenerated(vcfile)) { @@ -741,7 +739,7 @@ namespace QtVsTools.Core /* fail-safe */ foreach (Match propNameMatch in Regex.Matches(expanded, @"\$\(([^\)]+)\)")) { string propName = propNameMatch.Groups[1].Value; - string propValue = ""; + string propValue; switch (propName) { case "Configuration": case "ConfigurationName": @@ -764,7 +762,7 @@ namespace QtVsTools.Core /* because item metadata is not expanded in Evaluate() */ foreach (Match metaNameMatch in Regex.Matches(expanded, @"\%\(([^\)]+)\)")) { string metaName = metaNameMatch.Groups[1].Value; - string metaValue = ""; + string metaValue; switch (metaName) { case "FullPath": if (vcFile == null) @@ -874,7 +872,7 @@ namespace QtVsTools.Core return false; // Select vcvars script according to host and target platforms - var osIs64Bit = System.Environment.Is64BitOperatingSystem; + var osIs64Bit = Environment.Is64BitOperatingSystem; var vcVarsCmd = ""; switch (versionInfo.platform()) { case Platform.x86: @@ -931,7 +929,7 @@ namespace QtVsTools.Core }; process.BeginOutputReadLine(); process.WaitForExit(); - var ok = (process.ExitCode == 0); + var ok = process.ExitCode == 0; process.Close(); if (!ok) return false; diff --git a/QtVsTools.Core/Messages.cs b/QtVsTools.Core/Messages.cs index 228d6560..e12c8c54 100644 --- a/QtVsTools.Core/Messages.cs +++ b/QtVsTools.Core/Messages.cs @@ -28,7 +28,7 @@ namespace QtVsTools.Core /// </summary> public static void Print(string text, bool clear = false, bool activate = false) { - msgQueue.Enqueue(new Msg() + msgQueue.Enqueue(new Msg { Clear = clear, Text = text, @@ -39,7 +39,7 @@ namespace QtVsTools.Core public static void Log(this Exception exception, bool clear = false, bool activate = false) { - msgQueue.Enqueue(new Msg() + msgQueue.Enqueue(new Msg { Clear = clear, Text = ExceptionToString(exception), @@ -53,7 +53,7 @@ namespace QtVsTools.Core /// </summary> public static void ActivateMessagePane() { - msgQueue.Enqueue(new Msg() + msgQueue.Enqueue(new Msg { Activate = true }); @@ -66,7 +66,7 @@ namespace QtVsTools.Core await Pane?.ActivateAsync(); } - private static string ExceptionToString(System.Exception exception) + private static string ExceptionToString(Exception exception) { return $"An exception ({exception.GetType().Name}) occurred.\r\n" + $"Message:\r\n {exception.Message}\r\n" @@ -82,7 +82,7 @@ namespace QtVsTools.Core Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } - public static void DisplayErrorMessage(System.Exception e) + public static void DisplayErrorMessage(Exception e) { MessageBox.Show(ExceptionToString(e), Name, MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -94,7 +94,7 @@ namespace QtVsTools.Core Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } - public static void DisplayWarningMessage(System.Exception e, string solution) + public static void DisplayWarningMessage(Exception e, string solution) { MessageBox.Show(WarningString + ExceptionToString(e) @@ -112,7 +112,7 @@ namespace QtVsTools.Core public static void ClearPane() { - msgQueue.Enqueue(new Msg() + msgQueue.Enqueue(new Msg { Clear = true }); @@ -127,9 +127,9 @@ namespace QtVsTools.Core class Msg { - public bool Clear { get; set; } = false; - public string Text { get; set; } = null; - public bool Activate { get; set; } = false; + public bool Clear { get; set; } + public string Text { get; set; } + public bool Activate { get; set; } } static readonly ConcurrentQueue<Msg> msgQueue = new(); diff --git a/QtVsTools.Core/MsBuildProject.cs b/QtVsTools.Core/MsBuildProject.cs index ab37e998..363f1f6a 100644 --- a/QtVsTools.Core/MsBuildProject.cs +++ b/QtVsTools.Core/MsBuildProject.cs @@ -14,7 +14,6 @@ using System.Xml.Linq; using Microsoft.Build.Construction; using Microsoft.Build.Execution; using Microsoft.Build.Evaluation; -using Microsoft.VisualStudio.Shell; namespace QtVsTools.Core { @@ -30,10 +29,10 @@ namespace QtVsTools.Core class MsBuildXmlFile { public string filePath = ""; - public XDocument xml = null; - public bool isDirty = false; - public XDocument xmlCommitted = null; - public bool isCommittedDirty = false; + public XDocument xml; + public bool isDirty; + public XDocument xmlCommitted; + public bool isCommittedDirty; } enum Files @@ -499,7 +498,7 @@ namespace QtVsTools.Core this[Files.Project].xml .Elements(ns + "Project") .Elements(ns + "PropertyGroup") - .Where(x => ((string)x.Attribute("Label")) == Resources.projLabelQtSettings) + .Where(x => (string)x.Attribute("Label") == Resources.projLabelQtSettings) .ToList() .ForEach(config => { @@ -624,7 +623,7 @@ namespace QtVsTools.Core this[Files.Project].xml .Elements(ns + "Project") .Elements(ns + "PropertyGroup") - .Where(x => ((string)x.Attribute("Label")) == Resources.projLabelQtSettings) + .Where(x => (string)x.Attribute("Label") == Resources.projLabelQtSettings) .ToList() .ForEach(x => x.Add(new XElement(ns + "QtModules", string.Join(";", moduleNames)))); @@ -963,8 +962,8 @@ namespace QtVsTools.Core HashSet<string> includes = new HashSet<string> { QtVSIPSettings.GetMocDirectory(), QtVSIPSettings.GetRccDirectory(), - QtVSIPSettings.GetUicDirectory(), - }; + QtVSIPSettings.GetUicDirectory() + }; foreach (var includePath in includePathList.Split(';')) includes.Add(includePath); return string.Join<string>(";", includes); @@ -1000,7 +999,7 @@ namespace QtVsTools.Core if (cbEval != null) { var outputFiles = cbEval.Outputs .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) - .Select(x => HelperFunctions.CanonicalPath( + .Select(x => CanonicalPath( Path.IsPathRooted(x) ? x : Path.Combine(projDir, x))); var outputItems = new List<XElement>(); foreach (var outputFile in outputFiles) { @@ -1041,11 +1040,11 @@ namespace QtVsTools.Core .Elements() .Where(x => ((string)x.Attribute("Include")) .IndexOfAny(Path.GetInvalidPathChars()) == -1) - .GroupBy(x => HelperFunctions.CanonicalPath( + .GroupBy(x => CanonicalPath( Path.Combine(projDir, (string)x.Attribute("Include"))), CaseIgnorer) .ToDictionary(x => x.Key, x => new List<XElement>(x)); - var filterItemsByPath = (this[Files.Filters].xml != null) + var filterItemsByPath = this[Files.Filters].xml != null ? this[Files.Filters].xml .Elements(ns + "Project") .Elements(ns + "ItemGroup") @@ -1088,7 +1087,7 @@ namespace QtVsTools.Core "AdditionalInputs", "Command", "Message", - "Outputs", + "Outputs" }; foreach (var cbt in cbtGroup) { var enabledProperties = cbt.Elements().Where(x => @@ -1142,7 +1141,7 @@ namespace QtVsTools.Core $@"\{Path.GetFileNameWithoutExtension(item)}.moc", @"\%(Filename).moc", IgnoreCase) .Replace($" -o {Path.GetFileNameWithoutExtension(item)}.moc", - @" -o $(ProjectDir)\%(Filename).moc", IgnoreCase), + @" -o $(ProjectDir)\%(Filename).moc", IgnoreCase) })) { Rollback(); return false; @@ -1162,7 +1161,7 @@ namespace QtVsTools.Core QtMoc.Property.ExecutionDescription, "Moc'ing %(Identity)..."); qtMsBuild.SetItemProperty(qtMoc, QtMoc.Property.InputFile, "%(FullPath)"); - if (!HelperFunctions.IsSourceFile(itemName)) { + if (!IsSourceFile(itemName)) { qtMsBuild.SetItemProperty(qtMoc, QtMoc.Property.DynamicSource, "output"); if (!hasGeneratedFiles) @@ -1191,7 +1190,7 @@ namespace QtVsTools.Core @"\qrc_%(Filename).cpp", IgnoreCase) .Replace( $" -o qrc_{Path.GetFileNameWithoutExtension(item)}.cpp", - @" -o $(ProjectDir)\qrc_%(Filename).cpp", IgnoreCase), + @" -o $(ProjectDir)\qrc_%(Filename).cpp", IgnoreCase) })) { Rollback(); return false; @@ -1248,7 +1247,7 @@ namespace QtVsTools.Core @"\ui_%(Filename).h", IgnoreCase) .Replace( $" -o ui_{Path.GetFileNameWithoutExtension(item)}.h", - @" -o $(ProjectDir)\ui_%(Filename).h", IgnoreCase), + @" -o $(ProjectDir)\ui_%(Filename).h", IgnoreCase) })) { Rollback(); return false; @@ -1503,7 +1502,7 @@ namespace QtVsTools.Core AdditionalInputs = cbEval.Groups[2].Value, Outputs = cbEval.Groups[3].Value, Message = cbEval.Groups[4].Value, - Command = cbEval.Groups[5].Value, + Command = cbEval.Groups[5].Value }); } } diff --git a/QtVsTools.Core/OutputWindowPane.cs b/QtVsTools.Core/OutputWindowPane.cs index dc3408fd..cf5a0845 100644 --- a/QtVsTools.Core/OutputWindowPane.cs +++ b/QtVsTools.Core/OutputWindowPane.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Microsoft.VisualStudio; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Threading; using Task = System.Threading.Tasks.Task; @@ -22,7 +21,7 @@ namespace QtVsTools.Core { General, Build, - Debug, + Debug } public static Task<OutputWindowPane> GetVSOutputWindowPaneAsync(VSOutputWindowPane pane) @@ -36,7 +35,7 @@ namespace QtVsTools.Core return GetAsync(VSConstants.OutputWindowPaneGuid.DebugPane_guid); default: throw new InvalidOperationException("Unsupported Visual Studio output pane"); - }; + } } public static async Task<OutputWindowPane> GetAsync(Guid guid) @@ -98,7 +97,7 @@ namespace QtVsTools.Core } private Guid Guid { get; } - private IVsOutputWindowPane Pane { get; set; } = null; + private IVsOutputWindowPane Pane { get; set; } private OutputWindowPane(Guid guid, IVsOutputWindowPane pane) { @@ -132,7 +131,7 @@ namespace QtVsTools.Core public void Print() { - ThreadHelper.JoinableTaskFactory.Run(async () => { await PrintAsync(""); }); + ThreadHelper.JoinableTaskFactory.Run(async () => { await PrintAsync(); }); } public void Print(string value) diff --git a/QtVsTools.Core/QMake.cs b/QtVsTools.Core/QMake.cs index 3f12bf2c..57be213a 100644 --- a/QtVsTools.Core/QMake.cs +++ b/QtVsTools.Core/QMake.cs @@ -109,13 +109,13 @@ namespace QtVsTools.Core RedirectStandardOutput = true, FileName = QMakeExe, Arguments = QMakeArgs, - WorkingDirectory = WorkingDirectory, + WorkingDirectory = WorkingDirectory }; qmakeStartInfo.EnvironmentVariables["QTDIR"] = qtDir; var qmakeProc = new Process { - StartInfo = qmakeStartInfo, + StartInfo = qmakeStartInfo }; qmakeProc.OutputDataReceived += (sender, ev) => OutMsg(ev.Data); qmakeProc.ErrorDataReceived += (sender, ev) => ErrMsg(ev.Data); @@ -182,7 +182,7 @@ namespace QtVsTools.Core Path.Combine(path, "qmake.bat"), // Path points to folder containing bin\qmake.exe or bin\qmake.bat Path.Combine(path, "bin", "qmake.exe"), - Path.Combine(path, "bin", "qmake.bat"), + Path.Combine(path, "bin", "qmake.bat") }; return possibleQMakePaths.Where(File.Exists).Select(Path.GetFileName) .Any(file => file.Equals("qmake.exe", IgnoreCase) diff --git a/QtVsTools.Core/QMakeConf.cs b/QtVsTools.Core/QMakeConf.cs index d57d460a..feb988b5 100644 --- a/QtVsTools.Core/QMakeConf.cs +++ b/QtVsTools.Core/QMakeConf.cs @@ -63,8 +63,7 @@ namespace QtVsTools.Core var fileInfo = new FileInfo(filename); if (fileInfo.Exists) { var streamReader = new StreamReader(filename); - var line = streamReader.ReadLine(); - while (line != null) { + while (streamReader.ReadLine() is {} line) { line = line.Trim(); var commentStartIndex = line.IndexOf('#'); if (commentStartIndex >= 0) @@ -99,7 +98,6 @@ namespace QtVsTools.Core Environment.CurrentDirectory = saveCurrentDir; } } - line = streamReader.ReadLine(); } streamReader.Close(); diff --git a/QtVsTools.Core/QtModules.cs b/QtVsTools.Core/QtModules.cs index 097bf677..da2489ec 100644 --- a/QtVsTools.Core/QtModules.cs +++ b/QtVsTools.Core/QtModules.cs @@ -17,7 +17,7 @@ namespace QtVsTools.Core { public static QtModules Instance { get; } = new(); - private List<QtModule> qt5list = null, qt6list = null; + private List<QtModule> qt5list, qt6list; private readonly Dictionary<int, QtModule> qt5modules = new(); private readonly Dictionary<int, QtModule> qt6modules = new(); @@ -72,7 +72,7 @@ namespace QtVsTools.Core int id = (int)xModule.Attribute("Id"); QtModule module = new QtModule(id, major); module.Name = (string)xModule.Element("Name"); - module.Selectable = ((string)xModule.Element("Selectable") == "true"); + module.Selectable = (string)xModule.Element("Selectable") == "true"; module.LibraryPrefix = (string)xModule.Element("LibraryPrefix"); module.proVarQT = (string)xModule.Element("proVarQT"); module.IncludePath = xModule.Elements("IncludePath") diff --git a/QtVsTools.Core/QtMsBuild.cs b/QtVsTools.Core/QtMsBuild.cs index 56ef1579..5a79e723 100644 --- a/QtVsTools.Core/QtMsBuild.cs +++ b/QtVsTools.Core/QtMsBuild.cs @@ -152,7 +152,7 @@ namespace QtVsTools.Core.QtMsBuild readonly Dictionary<string, ItemPropertyChange> itemPropertyChanges = new(); readonly Dictionary<string, List<ItemPropertyChange>> itemPropertyChangesGrouped = new(); - bool pendingChanges = false; + bool pendingChanges; void AddChange(ItemPropertyChange newChange) { @@ -218,7 +218,7 @@ namespace QtVsTools.Core.QtMsBuild ItemName = itemName, PropertyName = propertyName, PropertyValue = propertyValue, - PropertyStorage = propertyStorage, + PropertyStorage = propertyStorage }; if (!pendingChanges) { @@ -614,7 +614,7 @@ namespace QtVsTools.Core.QtMsBuild bool useQuotes = false) { var name = option.Names.First(); - var escape = (name.Length == 1) ? "-" : "--"; + var escape = name.Length == 1 ? "-" : "--"; if (!string.IsNullOrEmpty(option.ValueName)) { foreach (var value in values.Split(';')) { @@ -659,12 +659,12 @@ namespace QtVsTools.Core.QtMsBuild AdditionalOptions, DynamicSource, ParallelProcess, - AdditionalDependencies, + AdditionalDependencies } readonly Dictionary<Property, CommandLineOption> options = new(); - public QtMoc() : base() + public QtMoc() { parser.AddOption(options[Property.IncludePath] = new CommandLineOption("I") @@ -693,7 +693,7 @@ namespace QtVsTools.Core.QtMsBuild parser.AddOption(options[Property.Undefine] = new CommandLineOption("U") { - ValueName = ("macro"), + ValueName = "macro", Flags = CommandLineOption.Flag.ShortOptionStyle }); @@ -957,12 +957,12 @@ namespace QtVsTools.Core.QtMsBuild AdditionalOptions, DynamicSource, ParallelProcess, - AdditionalDependencies, + AdditionalDependencies } readonly Dictionary<Property, CommandLineOption> options = new(); - public QtRcc() : base() + public QtRcc() { parser.AddOption(options[Property.TempFile] = new CommandLineOption(new[] { "t", "temp" }, "file")); @@ -1157,7 +1157,7 @@ namespace QtVsTools.Core.QtMsBuild OutputFile, IncludePath, AlwaysClass, - PrintDebug, + PrintDebug } readonly Dictionary<Property, CommandLineOption> options = new(); @@ -1318,12 +1318,12 @@ namespace QtVsTools.Core.QtMsBuild CommandLineTemplate, AdditionalOptions, ParallelProcess, - AdditionalDependencies, + AdditionalDependencies } readonly Dictionary<Property, CommandLineOption> options = new(); - public QtUic() : base() + public QtUic() { parser.AddOption(options[Property.DisplayDependencies] = new CommandLineOption(new[] { "d", "dependencies" })); diff --git a/QtVsTools.Core/QtProject.cs b/QtVsTools.Core/QtProject.cs index c5a639ec..74b28b68 100644 --- a/QtVsTools.Core/QtProject.cs +++ b/QtVsTools.Core/QtProject.cs @@ -31,7 +31,7 @@ namespace QtVsTools.Core private static readonly Dictionary<Project, QtProject> instances = new(); private readonly QtMsBuildContainer qtMsBuild; - public static QtVsTools.VisualStudio.IProjectTracker ProjectTracker { get; set; } + public static VisualStudio.IProjectTracker ProjectTracker { get; set; } public static QtProject Create(VCProject vcProject) { @@ -107,7 +107,7 @@ namespace QtVsTools.Core return IsQtMsBuildEnabled(project.Object as VCProject); } - private bool? isQtMsBuildEnabled = null; + private bool? isQtMsBuildEnabled; public bool IsQtMsBuildEnabled() { ThreadHelper.ThrowIfNotOnUIThread(); @@ -175,7 +175,7 @@ namespace QtVsTools.Core } public static string GetPropertyValue( - EnvDTE.Project dteProject, + Project dteProject, string propName) { ThreadHelper.ThrowIfNotOnUIThread(); @@ -188,8 +188,8 @@ namespace QtVsTools.Core } public static string GetPropertyValue( - EnvDTE.Project dteProject, - EnvDTE.Configuration dteConfig, + Project dteProject, + Configuration dteConfig, string propName) { ThreadHelper.ThrowIfNotOnUIThread(); @@ -309,9 +309,8 @@ namespace QtVsTools.Core #endif CxxStreamReader cxxStream = null; try { - var line = string.Empty; cxxStream = new CxxStreamReader(fullPath); - while ((line = cxxStream.ReadLine()) != null) { + while (cxxStream.ReadLine() is {} line) { if (Regex.IsMatch(line, "#include *(<|\")" + mocFile + "(\"|>)")) return true; } @@ -405,10 +404,10 @@ namespace QtVsTools.Core if (cbtTool == null) continue; foreach (var output in cbtTool.Outputs.Split(';')) { - string outputExpanded = output; + var outputExpanded = output; if (!HelperFunctions.ExpandString(ref outputExpanded, mocConfig)) continue; - string outputFullPath = ""; + string outputFullPath; try { outputFullPath = Path.GetFullPath(Path.Combine( Path.GetDirectoryName(mocFile.FullPath), @@ -704,7 +703,7 @@ namespace QtVsTools.Core } } - public static void MarkAsQtPlugin(Core.QtProject qtPro) + public static void MarkAsQtPlugin(QtProject qtPro) { foreach (VCConfiguration config in qtPro.VCProject.Configurations as IVCCollection) { (config.Rules.Item("QtRule10_Settings") as IVCRulePropertyStorage) @@ -739,12 +738,10 @@ namespace QtVsTools.Core var list = new List<string>(); var reader = new StreamReader(file); - var line = reader.ReadLine(); - while (line != null) { + while (reader.ReadLine() is {} line) { if (line.StartsWith(oldValue, StringComparison.Ordinal)) line = line.Replace(oldValue, newValue); list.Add(line); - line = reader.ReadLine(); } reader.Close(); @@ -907,7 +904,7 @@ namespace QtVsTools.Core envPro.Save(null); dte.Solution.Remove(envPro); AddPlatformToVCProj(projectFileName, oldPlatform, newPlatform); - envPro = dte.Solution.AddFromFile(projectFileName, false); + envPro = dte.Solution.AddFromFile(projectFileName); vcPro = (VCProject)envPro.Object; } @@ -1099,7 +1096,7 @@ namespace QtVsTools.Core .Select(x => new CppConfig { Config = x, - Cpp = x.Rules.Item("CL") as IVCRulePropertyStorage, + Cpp = x.Rules.Item("CL") as IVCRulePropertyStorage }) .Where(x => x.Cpp != null && x.Config.GetEvaluatedPropertyValue("ApplicationType") != "Linux"); @@ -1156,9 +1153,9 @@ namespace QtVsTools.Core public static void UndefineQtQmlDebug(VCProject vcPro) { - var configs = GetCppDebugConfigs(vcPro).Where(x => x.Cpp - .GetEvaluatedPropertyValue("PreprocessorDefinitions").Split(';') - .Contains("QT_QML_DEBUG") == true) + var configs = GetCppDebugConfigs(vcPro) + .Where(x => x.Cpp.GetEvaluatedPropertyValue("PreprocessorDefinitions").Split(';') + .Contains("QT_QML_DEBUG")) .Select(x => new { x.Cpp, @@ -1245,7 +1242,7 @@ namespace QtVsTools.Core get => IsQtQmlDebugDefined(vcPro) && IsQmlJsDebuggerDefined(vcPro); set { - bool enabled = (IsQtQmlDebugDefined(vcPro) && IsQmlJsDebuggerDefined(vcPro)); + bool enabled = IsQtQmlDebugDefined(vcPro) && IsQmlJsDebuggerDefined(vcPro); if (value == enabled) return; @@ -1462,7 +1459,7 @@ namespace QtVsTools.Core readonly VCFile vcFile; readonly VCCustomBuildTool tool; - enum FileItemType { Other = 0, CustomBuild, QtMoc, QtRcc, QtRepc, QtUic }; + enum FileItemType { Other = 0, CustomBuild, QtMoc, QtRcc, QtRepc, QtUic } readonly FileItemType itemType = FileItemType.Other; public QtCustomBuildTool(VCFileConfiguration vcConfig, QtMsBuildContainer container = null) @@ -1493,7 +1490,7 @@ namespace QtVsTools.Core { switch (itemType) { case FileItemType.CustomBuild: - return (tool != null) ? tool.CommandLine : ""; + return tool != null ? tool.CommandLine : ""; case FileItemType.QtMoc: return qtMsBuild.GenerateQtMocCommandLine(vcConfig); case FileItemType.QtRcc: @@ -1513,7 +1510,7 @@ namespace QtVsTools.Core { switch (itemType) { case FileItemType.CustomBuild: - return (tool != null) ? tool.Outputs : ""; + return tool != null ? tool.Outputs : ""; case FileItemType.QtMoc: return qtMsBuild.GetPropertyValue(vcConfig, QtMoc.Property.OutputFile); case FileItemType.QtRcc: diff --git a/QtVsTools.Core/QtVersionManager.cs b/QtVsTools.Core/QtVersionManager.cs index 8533ab71..f3e680a9 100644 --- a/QtVsTools.Core/QtVersionManager.cs +++ b/QtVsTools.Core/QtVersionManager.cs @@ -36,7 +36,7 @@ namespace QtVsTools.Core } private static readonly EventWaitHandle packageInit = new(false, EventResetMode.ManualReset); - private static EventWaitHandle packageInitDone = null; + private static EventWaitHandle packageInitDone; public static QtVersionManager The(EventWaitHandle initDone = null) { diff --git a/QtVsTools.Core/VersionInformation.cs b/QtVsTools.Core/VersionInformation.cs index 79f38732..fe1c4808 100644 --- a/QtVsTools.Core/VersionInformation.cs +++ b/QtVsTools.Core/VersionInformation.cs @@ -5,7 +5,6 @@ using System; using System.Collections; -using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; diff --git a/QtVsTools.Core/VisualStudio/InfoBarMessage.cs b/QtVsTools.Core/VisualStudio/InfoBarMessage.cs index f003ddcb..f9b36866 100644 --- a/QtVsTools.Core/VisualStudio/InfoBarMessage.cs +++ b/QtVsTools.Core/VisualStudio/InfoBarMessage.cs @@ -98,7 +98,7 @@ namespace QtVsTools.VisualStudio hyperlinks = Message.Hyperlinks .Select(x => new InfoBarHyperlink(x.Text, x)); } - var model = new InfoBarModel(textSpans, hyperlinks, Message.Icon, true); + var model = new InfoBarModel(textSpans, hyperlinks, Message.Icon); UIElement = Factory.CreateInfoBar(model); if (UIElement != null) { UIElement.Advise(this, out eventNotificationCookie); diff --git a/QtVsTools.Core/VisualStudio/VsSearch.cs b/QtVsTools.Core/VisualStudio/VsSearch.cs index f28e45ea..45193813 100644 --- a/QtVsTools.Core/VisualStudio/VsSearch.cs +++ b/QtVsTools.Core/VisualStudio/VsSearch.cs @@ -18,8 +18,8 @@ namespace QtVsTools.VisualStudio { public class SearchTask : VsSearchTask { - private readonly Action _clearCallback = null; - private readonly Func<IEnumerable<string>, uint> _searchCallBack = null; + private readonly Action _clearCallback; + private readonly Func<IEnumerable<string>, uint> _searchCallBack; public SearchTask(uint cookie, IVsSearchQuery query, IVsSearchCallback callback, Action clearCallback, Func<IEnumerable<string>, uint> searchCallBack) @@ -89,8 +89,8 @@ namespace QtVsTools.VisualStudio public class ListBoxSearch : VsWindowSearch { - private readonly ListBox _listBox = null; - private Action<string> _setSearchText = null; + private readonly ListBox _listBox; + private Action<string> _setSearchText; public ListBoxSearch(ListBox listBox, Action<string> action) { @@ -102,7 +102,7 @@ namespace QtVsTools.VisualStudio IVsSearchCallback callback) { return new SearchTask(cookie, query, callback, ClearSearch, - searchCallBack: (IEnumerable<string> tokens) => + searchCallBack: tokens => { _setSearchText(string.Join(" ", tokens)); var view = CollectionViewSource.GetDefaultView(_listBox.ItemsSource); diff --git a/QtVsTools.Core/VisualStudio/VsShell.cs b/QtVsTools.Core/VisualStudio/VsShell.cs index 30caa67e..6a76124f 100644 --- a/QtVsTools.Core/VisualStudio/VsShell.cs +++ b/QtVsTools.Core/VisualStudio/VsShell.cs @@ -84,7 +84,7 @@ namespace QtVsTools.VisualStudio return GetProjectItem(context, itemid)?.Document; } - private static IVsInfoBarHost _InfoBarHost = null; + private static IVsInfoBarHost _InfoBarHost; public static IVsInfoBarHost InfoBarHost { get diff --git a/QtVsTools.Core/WaitDialog.cs b/QtVsTools.Core/WaitDialog.cs index 9a523253..3cb95fb8 100644 --- a/QtVsTools.Core/WaitDialog.cs +++ b/QtVsTools.Core/WaitDialog.cs @@ -14,13 +14,13 @@ namespace QtVsTools.Core public class WaitDialog : IDisposable { - static IVsThreadedWaitDialogFactory factory = null; + static IVsThreadedWaitDialogFactory factory; private IVsThreadedWaitDialog2 VsWaitDialog { get; set; } private bool Running { get; set; } - bool? vsDialogCanceled = null; + bool? vsDialogCanceled; public bool Canceled { @@ -60,7 +60,7 @@ namespace QtVsTools.Core return new WaitDialog { VsWaitDialog = vsWaitDialog, - Running = true, + Running = true }; } @@ -136,7 +136,7 @@ namespace QtVsTools.Core Running = false; VsWaitDialog.EndWaitDialog(out int canceled); - Canceled = (canceled != 0); + Canceled = canceled != 0; } void IDisposable.Dispose() diff --git a/QtVsTools.Package/Editors/Editor.QtDesigner.cs b/QtVsTools.Package/Editors/Editor.QtDesigner.cs index cdda11aa..e4ee4a1b 100644 --- a/QtVsTools.Package/Editors/Editor.QtDesigner.cs +++ b/QtVsTools.Package/Editors/Editor.QtDesigner.cs @@ -7,7 +7,6 @@ using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; -using System.Threading.Tasks; using Microsoft.VisualStudio.Shell; using Task = System.Threading.Tasks.Task; diff --git a/QtVsTools.Package/Editors/Editor.QtLinguist.cs b/QtVsTools.Package/Editors/Editor.QtLinguist.cs index 1bdfe68a..10877e0a 100644 --- a/QtVsTools.Package/Editors/Editor.QtLinguist.cs +++ b/QtVsTools.Package/Editors/Editor.QtLinguist.cs @@ -16,7 +16,7 @@ namespace QtVsTools.Editors public const string Title = "Qt Linguist"; private Guid? guid; - public override Guid Guid => (guid ??= new Guid(GuidString)); + public override Guid Guid => guid ??= new Guid(GuidString); public override string ExecutableName => "linguist.exe"; diff --git a/QtVsTools.Package/Editors/Editor.QtResourceEditor.cs b/QtVsTools.Package/Editors/Editor.QtResourceEditor.cs index 3e31e6fa..60681ce0 100644 --- a/QtVsTools.Package/Editors/Editor.QtResourceEditor.cs +++ b/QtVsTools.Package/Editors/Editor.QtResourceEditor.cs @@ -6,7 +6,6 @@ using System; using System.Diagnostics; using System.Runtime.InteropServices; -using Microsoft.VisualStudio.Shell; namespace QtVsTools.Editors { @@ -17,7 +16,7 @@ namespace QtVsTools.Editors public const string Title = "Qt Resource Editor"; private Guid? guid; - public override Guid Guid => (guid ??= new Guid(GuidString)); + public override Guid Guid => guid ??= new Guid(GuidString); public override string ExecutableName => "QrcEditor.exe"; diff --git a/QtVsTools.Package/Editors/Editor.cs b/QtVsTools.Package/Editors/Editor.cs index 2b34152c..67f958f1 100644 --- a/QtVsTools.Package/Editors/Editor.cs +++ b/QtVsTools.Package/Editors/Editor.cs @@ -30,7 +30,7 @@ namespace QtVsTools.Editors public abstract Guid Guid { get; } public abstract string ExecutableName { get; } - public virtual Func<string, bool> WindowFilter => (caption => true); + public virtual Func<string, bool> WindowFilter => caption => true; protected virtual string GetTitle(Process editorProcess) { @@ -220,7 +220,7 @@ namespace QtVsTools.Editors { AutoSize = true, Dock = DockStyle.Fill, - BackColor = Color.FromArgb(201, 221, 201), + BackColor = Color.FromArgb(201, 221, 201) }; titleBar.Controls.Add(EditorTitle = new Label { @@ -228,14 +228,14 @@ namespace QtVsTools.Editors ForeColor = Color.FromArgb(9, 16, 43), Font = new Font("Segoe UI", 8F, FontStyle.Bold, GraphicsUnit.Point), AutoSize = true, - Margin = new Padding(8), + Margin = new Padding(8) }); titleBar.Controls.Add(EditorDetachButton = new LinkLabel { Text = "Detach", Font = new Font("Segoe UI", 8F, FontStyle.Regular, GraphicsUnit.Point), AutoSize = true, - Margin = new Padding(0, 8, 8, 8), + Margin = new Padding(0, 8, 8, 8) }); EditorDetachButton.Click += EditorDetachButton_Click; @@ -249,7 +249,7 @@ namespace QtVsTools.Editors EditorContainer = new TableLayoutPanel { ColumnCount = 1, - RowCount = 2, + RowCount = 2 }; EditorContainer.ColumnStyles.Add(new ColumnStyle()); EditorContainer.RowStyles.Add(new RowStyle()); diff --git a/QtVsTools.Package/Options/QtOptionsPage.cs b/QtVsTools.Package/Options/QtOptionsPage.cs index 61e1c5df..d289d3c2 100644 --- a/QtVsTools.Package/Options/QtOptionsPage.cs +++ b/QtVsTools.Package/Options/QtOptionsPage.cs @@ -43,17 +43,17 @@ namespace QtVsTools.Options public enum Designer { - [String("Designer_Detached")] Detached, + [String("Designer_Detached")] Detached } public enum Linguist { - [String("Linguist_Detached")] Detached, + [String("Linguist_Detached")] Detached } public enum ResEditor { - [String("ResourceEditor_Detached")] Detached, + [String("ResourceEditor_Detached")] Detached } public enum BkgBuild @@ -61,7 +61,7 @@ namespace QtVsTools.Options [String("BkgBuild_ProjectTracking")] ProjectTracking, [String("BkgBuild_RunQtTools")] RunQtTools, [String("BkgBuild_DebugInfo")] DebugInfo, - [String("BkgBuild_LoggerVerbosity")] LoggerVerbosity, + [String("BkgBuild_LoggerVerbosity")] LoggerVerbosity } public enum Notifications @@ -72,7 +72,7 @@ namespace QtVsTools.Options public enum Natvis { - [String("LinkNatvis")] Link, + [String("LinkNatvis")] Link } public enum Timeout : uint { Disabled = 0 } @@ -335,7 +335,7 @@ namespace QtVsTools.Options { object value = property; if (Equals<T, bool>()) - value = ((bool)(object)property) ? 1 : 0; + value = (bool)(object)property ? 1 : 0; else if (Equals<T, Timeout>()) value = Convert.ToInt32(property); else if (typeof(T).IsEnum) diff --git a/QtVsTools.Package/Options/QtVersionsPage.cs b/QtVsTools.Package/Options/QtVersionsPage.cs index ca9ac891..58069be5 100644 --- a/QtVsTools.Package/Options/QtVersionsPage.cs +++ b/QtVsTools.Package/Options/QtVersionsPage.cs @@ -15,8 +15,8 @@ namespace QtVsTools.Options { using Common; using Core; + using static QtVersionsTable; using static Utils; - using static QtVsTools.Options.QtVersionsTable; public class QtVersionsPage : UIElementDialogPage { @@ -48,9 +48,9 @@ namespace QtVsTools.Options compiler = linuxPaths[2]; } var defaultVersion = VersionManager.GetDefaultVersion(); - versions.Add(new Row() + versions.Add(new Row { - IsDefault = (versionName == defaultVersion), + IsDefault = versionName == defaultVersion, VersionName = versionName, InitialVersionName = versionName, Path = versionPath, diff --git a/QtVsTools.Package/Options/QtVersionsTable.cs b/QtVsTools.Package/Options/QtVersionsTable.cs index 2ba2b91a..f6beb1b2 100644 --- a/QtVsTools.Package/Options/QtVersionsTable.cs +++ b/QtVsTools.Package/Options/QtVersionsTable.cs @@ -15,7 +15,7 @@ using Microsoft.Win32; namespace QtVsTools.Options { using Common; - using QtVsTools.Core; + using Core; using static Utils; using static Common.EnumExt; @@ -23,7 +23,7 @@ namespace QtVsTools.Options { [String("Windows")] Windows, [String("Linux SSH")] LinuxSSH, - [String("Linux WSL")] LinuxWSL, + [String("Linux WSL")] LinuxWSL } public partial class QtVersionsTable : UserControl @@ -67,9 +67,9 @@ namespace QtVsTools.Options } public bool IsValid => string.IsNullOrEmpty(ValidationError); public ToolTip ToolTip - => IsValid ? null : new ToolTip() { Content = ValidationError }; + => IsValid ? null : new ToolTip { Content = ValidationError }; public int SelectionStart { get; set; } - public bool UpdateUi { get; private set; } = false; + public bool UpdateUi { get; private set; } } public class Row @@ -85,7 +85,7 @@ namespace QtVsTools.Options ?? (Fields[Column.IsDefault] = new Field()); public bool IsDefault { - get => (FieldDefault.Value == true.ToString()); + get => FieldDefault.Value == true.ToString(); set => FieldDefault.Value = value.ToString(); } @@ -126,14 +126,14 @@ namespace QtVsTools.Options public bool DefaultEnabled => !IsDefault && !LastRow; public bool NameEnabled => !LastRow; - public bool CompilerEnabled => (Host != BuildHost.Windows); + public bool CompilerEnabled => Host != BuildHost.Windows; public Visibility RowContentVisibility => LastRow ? Visibility.Hidden : Visibility.Visible; public Visibility ButtonAddVisibility => LastRow ? Visibility.Visible : Visibility.Hidden; public Visibility ButtonBrowseVisibility - => (!LastRow && Host == BuildHost.Windows) ? Visibility.Visible : Visibility.Hidden; - public Thickness PathMargin => new(((Host == BuildHost.Windows) ? 24 : 2), 4, 4, 4); + => !LastRow && Host == BuildHost.Windows ? Visibility.Visible : Visibility.Hidden; + public Thickness PathMargin => new(Host == BuildHost.Windows ? 24 : 2, 4, 4, 4); public FontWeight FontWeight => IsDefault ? FontWeights.Bold : FontWeights.Normal; @@ -432,7 +432,7 @@ namespace QtVsTools.Options void Add_Click(object sender, RoutedEventArgs e) { - var version = new Row() + var version = new Row { IsDefault = Versions.All(x => x.State == State.Removed), Host = BuildHost.Windows, @@ -478,7 +478,7 @@ namespace QtVsTools.Options void Explorer_Click(object sender, RoutedEventArgs e) { if (sender is Button button && GetBinding(button) is Row version) { - var openFileDialog = new OpenFileDialog() + var openFileDialog = new OpenFileDialog { AddExtension = false, CheckFileExists = true, diff --git a/QtVsTools.Package/Package/QMakeWrapper.cs b/QtVsTools.Package/Package/QMakeWrapper.cs index afbbd708..eb6afbe6 100644 --- a/QtVsTools.Package/Package/QMakeWrapper.cs +++ b/QtVsTools.Package/Package/QMakeWrapper.cs @@ -39,7 +39,7 @@ namespace QtVsTools string output; try { var exeFilePath = QMakeFileReaderPath; - if (!System.IO.File.Exists(exeFilePath)) + if (!File.Exists(exeFilePath)) return false; using (var process = new Process()) { @@ -54,9 +54,9 @@ namespace QtVsTools process.WaitForExit(); } - System.IO.StringReader stringReader = null; + StringReader stringReader = null; try { - stringReader = new System.IO.StringReader(output); + stringReader = new StringReader(output); using (var reader = new XmlTextReader(stringReader)) { stringReader = null; reader.ReadToFollowing("content"); diff --git a/QtVsTools.Package/Package/QtHelp.cs b/QtVsTools.Package/Package/QtHelp.cs index 575f38f0..270a9560 100644 --- a/QtVsTools.Package/Package/QtHelp.cs +++ b/QtVsTools.Package/Package/QtHelp.cs @@ -108,7 +108,7 @@ namespace QtVsTools if (dte?.ActiveDocument?.Object() is not TextDocument objTextDocument) return false; - var keyword = string.Empty; + string keyword; var selection = objTextDocument.Selection; if (selection.IsEmpty) { // no selection inside the document var line = selection.ActivePoint.Line; // current line @@ -173,7 +173,7 @@ namespace QtVsTools var title = GetString(reader, 0); if (string.IsNullOrWhiteSpace(title)) title = keyword + ':' + GetString(reader, 3); - var path = string.Empty; + string path; if (offline) { path = "file:///" + Path.Combine(docPath, GetString(reader, 2), GetString(reader, 3)); @@ -190,7 +190,7 @@ namespace QtVsTools } } - var uri = string.Empty; + string uri; switch (links.Values.Count) { case 0: return TryShowGenericSearchResultsOnline(keyword, info.qtMajor); diff --git a/QtVsTools.Package/Package/QtMainMenu.cs b/QtVsTools.Package/Package/QtMainMenu.cs index cac71382..e083a775 100644 --- a/QtVsTools.Package/Package/QtMainMenu.cs +++ b/QtVsTools.Package/Package/QtMainMenu.cs @@ -167,8 +167,8 @@ namespace QtVsTools else if (HelperFunctions.IsQtProject(project)) status |= vsCommandStatus.vsCommandStatusInvisible; } - command.Enabled = ((status & vsCommandStatus.vsCommandStatusEnabled) != 0); - command.Visible = ((status & vsCommandStatus.vsCommandStatusInvisible) == 0); + command.Enabled = (status & vsCommandStatus.vsCommandStatusEnabled) != 0; + command.Visible = (status & vsCommandStatus.vsCommandStatusInvisible) == 0; } break; case CommandId.ConvertToQtMsBuild: { diff --git a/QtVsTools.Package/Package/QtMsBuildConverter.cs b/QtVsTools.Package/Package/QtMsBuildConverter.cs index 3420acbf..815c8f51 100644 --- a/QtVsTools.Package/Package/QtMsBuildConverter.cs +++ b/QtVsTools.Package/Package/QtMsBuildConverter.cs @@ -113,7 +113,7 @@ namespace QtVsTools static bool ConvertProject(string pathToProject) { var xmlProject = MsBuildProject.Load(pathToProject); - bool ok = (xmlProject != null); + bool ok = xmlProject != null; if (ok) ok = xmlProject.AddQtMsBuildReferences(); if (ok) diff --git a/QtVsTools.Package/Package/QtProjectContextMenu.cs b/QtVsTools.Package/Package/QtProjectContextMenu.cs index 4ffa2470..bf095e33 100644 --- a/QtVsTools.Package/Package/QtProjectContextMenu.cs +++ b/QtVsTools.Package/Package/QtProjectContextMenu.cs @@ -148,8 +148,8 @@ namespace QtVsTools status |= vsCommandStatus.vsCommandStatusEnabled; else status |= vsCommandStatus.vsCommandStatusInvisible; - command.Enabled = ((status & vsCommandStatus.vsCommandStatusEnabled) != 0); - command.Visible = ((status & vsCommandStatus.vsCommandStatusInvisible) == 0); + command.Enabled = (status & vsCommandStatus.vsCommandStatusEnabled) != 0; + command.Visible = (status & vsCommandStatus.vsCommandStatusInvisible) == 0; break; case CommandId.ProjectConvertToQtMsBuild: command.Visible = true; diff --git a/QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs b/QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs index 42dc8e51..3e3d84aa 100644 --- a/QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs +++ b/QtVsTools.Package/QML/Classification/QmlAsyncClassifier.cs @@ -110,9 +110,9 @@ namespace QtVsTools.Qml.Classification return -1; bool sameVersion = - (firstTag.Snapshot.Version.VersionNumber == snapshot.Version.VersionNumber); + firstTag.Snapshot.Version.VersionNumber == snapshot.Version.VersionNumber; - int? idx = null; + int? idx; if (sameVersion) { idx = data.Keys.BinarySearch(location); } else { @@ -212,7 +212,7 @@ namespace QtVsTools.Qml.Classification SharedTagList currentTagList; readonly Dispatcher dispatcher; readonly DispatcherTimer timer; - bool flag = false; + bool flag; protected QmlAsyncClassifier( string classificationType, @@ -352,7 +352,7 @@ namespace QtVsTools.Qml.Classification var snapshot = spans[0].Snapshot; bool sameVersion = - (firstTag.Snapshot.Version.VersionNumber == snapshot.Version.VersionNumber); + firstTag.Snapshot.Version.VersionNumber == snapshot.Version.VersionNumber; foreach (var span in spans) { @@ -428,7 +428,7 @@ namespace QtVsTools.Qml.Classification return null; int lower = index; - int upper = (index + length) - 1; + int upper = index + length - 1; while (lower <= upper) { int adjustedIndex = lower + ((upper - lower) >> 1); @@ -520,7 +520,7 @@ namespace QtVsTools.Qml.Classification disposable?.Dispose(); } - private static TInstance instance = null; + private static TInstance instance; public static TInstance Instance { get diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs index 6a284644..32cf653d 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Breakpoint.cs @@ -114,7 +114,7 @@ namespace QtVsTools.Qml.Debug.AD7 int IDebugPendingBreakpoint2.Enable(int fEnable) { - bool enable = (fEnable != 0); + bool enable = fEnable != 0; if (Atomic(() => Enabled != enable, () => Enabled = enable)) { foreach (var breakpoint in ThreadSafe(() => breakpoints.ToList())) (breakpoint as IDebugBoundBreakpoint2).Enable(fEnable); @@ -138,10 +138,8 @@ namespace QtVsTools.Qml.Debug.AD7 { if (Disposed) { pState[0].state = (enum_PENDING_BP_STATE)enum_BP_STATE.BPS_DELETED; - } else if (Enabled) { pState[0].state = (enum_PENDING_BP_STATE)enum_BP_STATE.BPS_ENABLED; - } else { pState[0].state = (enum_PENDING_BP_STATE)enum_BP_STATE.BPS_DISABLED; } @@ -201,7 +199,7 @@ namespace QtVsTools.Qml.Debug.AD7 parent.Engine, program, parent.FileName, - parent.BeginPosition.dwLine), + parent.BeginPosition.dwLine) }; } @@ -215,7 +213,7 @@ namespace QtVsTools.Qml.Debug.AD7 int IDebugBoundBreakpoint2.Enable(int fEnable) { - bool enable = (fEnable != 0); + bool enable = fEnable != 0; if (Atomic(() => Enabled != enable, () => { Enabled = enable; supressNotify = true; })) { diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7CodeContext.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7CodeContext.cs index ebf558bc..3426a4f8 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7CodeContext.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7CodeContext.cs @@ -42,7 +42,7 @@ namespace QtVsTools.Qml.Debug.AD7 QmlEngine engine, Program program, string filePath, uint fileLine) { - return new CodeContext() + return new CodeContext { Engine = engine, Program = program, diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs index d231b55b..8b71f6ec 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs @@ -261,9 +261,6 @@ namespace QtVsTools.Qml.Debug.AD7 { public const string CLSID_PROGRAMPROVIDER = "f2ff34e2-7fa5-461b-9e59-b5997ee0a637"; public static readonly Guid ClassId = new(CLSID_PROGRAMPROVIDER); - - public ProgramProvider() - { } } public static class NativeEngine diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Enums.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Enums.cs index 7860f5ca..5847718a 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Enums.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Enums.cs @@ -37,7 +37,7 @@ namespace QtVsTools.Qml.Debug.AD7 return new TEnum { index = 0, - list = new List<T>() { singleElement } + list = new List<T> { singleElement } }; } diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Expression.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Expression.cs index d66dbdba..8b73c4c3 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Expression.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Expression.cs @@ -33,7 +33,7 @@ namespace QtVsTools.Qml.Debug.AD7 Engine = frame.Engine, Program = frame.Program, Debugger = frame.Debugger, - CodeContext = frame.Context, + CodeContext = frame.Context }; } diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7InfoHelpers.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7InfoHelpers.cs index 8c826b2e..6150f0a7 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7InfoHelpers.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7InfoHelpers.cs @@ -14,7 +14,7 @@ namespace QtVsTools.Qml.Debug.AD7 { public class Ref<TStruct> { - public TStruct s = default(TStruct); + public TStruct s = default; } public abstract class MapField<TStruct, TFieldMask> @@ -82,8 +82,8 @@ namespace QtVsTools.Qml.Debug.AD7 FieldMaskBitUpdate = fieldMaskBitUpdate, FieldValue = fieldValue, MapToStruct = mapToStruct, - IsNull = (x => x == null), - Convert = (x => x) + IsNull = x => x == null, + Convert = x => x }); } @@ -126,7 +126,7 @@ namespace QtVsTools.Qml.Debug.AD7 public void Map(TDerived infoObj, TFieldMask fieldMask, out TStruct infoStruct) { - infoStruct = default(TStruct); + infoStruct = default; var r = new Ref<TStruct>(); foreach (var mapping in this) { @@ -165,7 +165,7 @@ namespace QtVsTools.Qml.Debug.AD7 if (mapping is Mapping<TStruct, TFieldMask> mappingToStruct) mappingToStruct.Map(this as TDerived, fieldMask, out infoStruct); else - infoStruct = default(TStruct); + infoStruct = default; } } } diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Program.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Program.cs index d2ce59cf..834a1a9d 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Program.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Program.cs @@ -53,7 +53,7 @@ namespace QtVsTools.Qml.Debug.AD7 private static readonly object criticalSectionGlobal = new(); private static bool originalBreakAllProcesses = BreakAllProcesses; - private static int runningPrograms = 0; + private static int runningPrograms; public static Program Create( QmlEngine engine, @@ -149,7 +149,7 @@ namespace QtVsTools.Qml.Debug.AD7 if (res != VSConstants.S_OK) return false; - return (debugMode[0] != DBGMODE.DBGMODE_Run); + return debugMode[0] != DBGMODE.DBGMODE_Run; } void IDebuggerEventSink.NotifyError(string errorMessage) @@ -195,7 +195,7 @@ namespace QtVsTools.Qml.Debug.AD7 TerminateProcess(); } - bool terminated = false; + bool terminated; void TerminateProcess() { if (!terminated) { @@ -278,10 +278,10 @@ namespace QtVsTools.Qml.Debug.AD7 get => ThreadHelper.JoinableTaskFactory.Run(async () => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - return ((bool)QtVsToolsPackage.Instance.Dte + return (bool)QtVsToolsPackage.Instance.Dte .Properties["Debugging", "General"] .Item("BreakAllProcesses") - .Value); + .Value; }); set => ThreadHelper.JoinableTaskFactory.Run(async () => { @@ -405,7 +405,7 @@ namespace QtVsTools.Qml.Debug.AD7 (r, v) => r.s.bstrName = v, i => i.Name }, { enum_THREADPROPERTY_FIELDS.TPF_LOCATION, - (r, v) => r.s.bstrLocation = v, i => i.Location }, + (r, v) => r.s.bstrLocation = v, i => i.Location } }; #endregion //////////////////// THREADPROPERTIES <-- ProgramInfo ////////////////////////// @@ -454,7 +454,7 @@ namespace QtVsTools.Qml.Debug.AD7 (r, v) => r.s.AffinityMask = v, i => i.AffinityMask }, { enum_THREADPROPERTY_FIELDS100.TPF100_PRIORITY_ID, - (r, v) => r.s.priorityId = v, i => i.PriorityId }, + (r, v) => r.s.priorityId = v, i => i.PriorityId } }; #endregion //////////////////// THREADPROPERTIES100 <-- ProgramInfo /////////////////////// @@ -475,7 +475,7 @@ namespace QtVsTools.Qml.Debug.AD7 (r, v) => r.s.m_bstrName = v, i => i.ModuleName }, { enum_MODULE_INFO_FIELDS.MIF_URL, - (r, v) => r.s.m_bstrUrl = v, i => i.ModuleUrl }, + (r, v) => r.s.m_bstrUrl = v, i => i.ModuleUrl } }; #endregion //////////////////// MODULE_INFO <-- ProgramInfo /////////////////////////////// @@ -483,7 +483,7 @@ namespace QtVsTools.Qml.Debug.AD7 public int /*IDebugProgram3*/ GetName(out string pbstrName) { - pbstrName = Program.Name; + pbstrName = Name; return VSConstants.S_OK; } diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs index cacaffc2..ec8f4784 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs @@ -167,7 +167,7 @@ namespace QtVsTools.Qml.Debug.AD7 Value = Value, Property = this, Attribs = Children.Any() || JsValue.Type == JsValue.DataType.Object - ? enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_OBJ_IS_EXPANDABLE : 0, + ? enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_OBJ_IS_EXPANDABLE : 0 }; static readonly PropertyInfo.Mapping MappingToDEBUG_PROPERTY_INFO = @@ -197,7 +197,7 @@ namespace QtVsTools.Qml.Debug.AD7 (r, v) => r.s.dwAttrib |= v, i => i.Attribs }, { enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP, - (r, v) => r.s.pProperty = v, i => i.Property }, + (r, v) => r.s.pProperty = v, i => i.Property } }; #endregion //////////////////// DEBUG_PROPERTY_INFO <-- PropertyInfo ////////////////////// @@ -224,7 +224,7 @@ namespace QtVsTools.Qml.Debug.AD7 int IDebugProperty2.GetParent(out IDebugProperty2 ppParent) { ppParent = Parent; - return (Parent != null) ? VSConstants.S_OK : VSConstants.S_FALSE; + return Parent != null ? VSConstants.S_OK : VSConstants.S_FALSE; } #endregion //////////////////// Info ////////////////////////////////////////////////////// diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs index 9136503b..659b9d35 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7StackFrame.cs @@ -167,7 +167,7 @@ namespace QtVsTools.Qml.Debug.AD7 Frame = this, Module = Program, HasDebugInfo = 1, - StaleCode = 0, + StaleCode = 0 }; static readonly StackFrameInfo.Mapping MappingToFRAMEINFO = @@ -212,7 +212,7 @@ namespace QtVsTools.Qml.Debug.AD7 (r, v) => r.s.m_fHasDebugInfo = v, i => i.HasDebugInfo }, { enum_FRAMEINFO_FLAGS.FIF_STALECODE, - (r, v) => r.s.m_fStaleCode = v, i => i.StaleCode }, + (r, v) => r.s.m_fStaleCode = v, i => i.StaleCode } }; #endregion //////////////////// FRAMEINFO <-- StackFrameInfo ////////////////////////////// diff --git a/QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs b/QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs index 62cc0933..55293be7 100644 --- a/QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs +++ b/QtVsTools.Package/QML/Debugging/QmlDebugLauncher.cs @@ -140,10 +140,10 @@ namespace QtVsTools.Qml.Debug new Rule<WslPath> { Update("DRIVE", (WslPath wslPath, string drive) => wslPath.Drive = drive), - Update("PATH", (WslPath wslPath, string path) => wslPath.Path = path), + Update("PATH", (WslPath wslPath, string path) => wslPath.Path = path) } }; - static readonly RegExpr.Parser wslPathParser = wslPathRegex.Render(); + static readonly Parser wslPathParser = wslPathRegex.Render(); bool GetProcessInfo(IDebugProcess2 pProcess, bool native, out string execPath, out uint procId) { @@ -196,7 +196,7 @@ namespace QtVsTools.Qml.Debug var remoteDebugCommand = props.GetPropertyValue("RemoteDebuggerCommand", vcConfig.Name, "UserFile"); - string debugCommand = (native || string.IsNullOrEmpty(remoteDebugCommand)) + string debugCommand = native || string.IsNullOrEmpty(remoteDebugCommand) ? localDebugCommand : remoteDebugCommand; bool sameFile = string.Equals(execPath, Path.GetFullPath(debugCommand), IgnoreCase); @@ -273,7 +273,7 @@ namespace QtVsTools.Qml.Debug bstrOptions = procId.ToString(), bstrEnv = "QTRCC=" + string.Join(";", rccItems), guidLaunchDebugEngine = QmlEngine.Id, - LaunchFlags = (uint)__VSDBGLAUNCHFLAGS5.DBGLAUNCH_BreakOneProcess, + LaunchFlags = (uint)__VSDBGLAUNCHFLAGS5.DBGLAUNCH_BreakOneProcess }}; var processInfo = new VsDebugTargetProcessInfo[targets.Length]; diff --git a/QtVsTools.Package/QML/Debugging/QmlDebugger.cs b/QtVsTools.Package/QML/Debugging/QmlDebugger.cs index f828a5e8..f702c041 100644 --- a/QtVsTools.Package/QML/Debugging/QmlDebugger.cs +++ b/QtVsTools.Package/QML/Debugging/QmlDebugger.cs @@ -273,7 +273,7 @@ namespace QtVsTools.Qml.Debug } } - Scope currentScope = null; + Scope currentScope; Scope MoveToScope(int frameNumber, int scopeNumber) { diff --git a/QtVsTools.Package/QML/Debugging/QmlFileSystem.cs b/QtVsTools.Package/QML/Debugging/QmlFileSystem.cs index bd310cc3..4e6b9601 100644 --- a/QtVsTools.Package/QML/Debugging/QmlFileSystem.cs +++ b/QtVsTools.Package/QML/Debugging/QmlFileSystem.cs @@ -90,7 +90,7 @@ namespace QtVsTools.Qml.Debug else continue; - string qrcPathPrefix = (file.Prefix != null) ? ((string)file.Prefix) : ""; + var qrcPathPrefix = file.Prefix != null ? (string)file.Prefix : ""; if (!string.IsNullOrEmpty(qrcPathPrefix) && !qrcPathPrefix.EndsWith("/")) qrcPathPrefix += Path.AltDirectorySeparatorChar; diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Backtrace.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Backtrace.cs index b96e3a42..81f26a76 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Backtrace.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Backtrace.cs @@ -21,7 +21,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string REQ_COMMAND = "backtrace"; - public BacktraceRequest() : base() + public BacktraceRequest() { Command = REQ_COMMAND; } @@ -56,7 +56,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = BacktraceRequest.REQ_COMMAND; - public BacktraceResponse() : base() + public BacktraceResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Break.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Break.cs index 582cbc43..ca5562cc 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Break.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Break.cs @@ -26,7 +26,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string EV_TYPE = "break"; - public BreakEvent() : base() + public BreakEvent() { EventType = EV_TYPE; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4ClearBreakpoint.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4ClearBreakpoint.cs index 7e5a8b1e..d499b31b 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4ClearBreakpoint.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4ClearBreakpoint.cs @@ -18,7 +18,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string REQ_COMMAND = "clearbreakpoint"; - public ClearBreakpointRequest() : base() + public ClearBreakpointRequest() { Command = REQ_COMMAND; } @@ -35,7 +35,7 @@ namespace QtVsTools.Qml.Debug.V4 sealed class ClearBreakpointResponse : Response { public const string REQ_COMMAND = ClearBreakpointRequest.REQ_COMMAND; - public ClearBreakpointResponse() : base() + public ClearBreakpointResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Connect.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Connect.cs index 93d2f8c8..9ef4b9ab 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Connect.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Connect.cs @@ -15,7 +15,7 @@ namespace QtVsTools.Qml.Debug.V4 // "namesAsObjects" : <bool> // } public const string MSG_TYPE = "connect"; - public ConnectMessage() : base() + public ConnectMessage() { Type = MSG_TYPE; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Continue.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Continue.cs index 2774d49e..a1aec83b 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Continue.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Continue.cs @@ -21,14 +21,14 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string REQ_COMMAND = "continue"; - public ContinueRequest() : base() + public ContinueRequest() { Command = REQ_COMMAND; } public enum StepAction { - [EnumString(default(string))] Continue = 0, + [EnumString(default)] Continue = 0, [EnumString("in")] StepIn, [EnumString("next")] Next, [EnumString("out")] StepOut @@ -63,7 +63,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = ContinueRequest.REQ_COMMAND; - public ContinueResponse() : base() + public ContinueResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Disconnect.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Disconnect.cs index 22d644b1..17a5269c 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Disconnect.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Disconnect.cs @@ -16,7 +16,7 @@ namespace QtVsTools.Qml.Debug.V4 // "command" : "disconnect" // } public const string REQ_COMMAND = "disconnect"; - public DisconnectRequest() : base() + public DisconnectRequest() { Command = REQ_COMMAND; } @@ -34,7 +34,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = DisconnectRequest.REQ_COMMAND; - public DisconnectResponse() : base() + public DisconnectResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Evaluate.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Evaluate.cs index 3297856f..35aec6bc 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Evaluate.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Evaluate.cs @@ -23,7 +23,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string REQ_COMMAND = "evaluate"; - public EvaluateRequest() : base() + public EvaluateRequest() { Command = REQ_COMMAND; } @@ -57,7 +57,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = EvaluateRequest.REQ_COMMAND; - public EvaluateResponse() : base() + public EvaluateResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Exception.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Exception.cs index b3b4fb8b..68ddc715 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Exception.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Exception.cs @@ -24,7 +24,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string EV_TYPE = "exception"; - public ExceptionEvent() : base() + public ExceptionEvent() { EventType = EV_TYPE; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Frame.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Frame.cs index 71737cf1..f0ab91a2 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Frame.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Frame.cs @@ -96,7 +96,7 @@ namespace QtVsTools.Qml.Debug.V4 // "arguments" : { "number" : <frame number> } // } public const string REQ_COMMAND = "frame"; - public FrameRequest() : base() + public FrameRequest() { Command = REQ_COMMAND; } @@ -146,7 +146,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = FrameRequest.REQ_COMMAND; - public FrameResponse() : base() + public FrameResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4JsObject.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4JsObject.cs index f203342d..13bef699 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4JsObject.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4JsObject.cs @@ -44,9 +44,6 @@ namespace QtVsTools.Qml.Debug.V4 [DataContract] class JsObjectRef : JsRef<JsObjectRef> { - public JsObjectRef() - { } - protected override bool? IsCompatible(JsValue obj) { System.Diagnostics.Debug.Assert(IsPrototype); @@ -81,9 +78,6 @@ namespace QtVsTools.Qml.Debug.V4 // ... // ] // } - public JsObject() - { } - protected override bool? IsCompatible(JsValue obj) { System.Diagnostics.Debug.Assert(IsPrototype); diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4JsValue.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4JsValue.cs index 0fa64b86..5e1db495 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4JsValue.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4JsValue.cs @@ -67,7 +67,7 @@ namespace QtVsTools.Qml.Debug.V4 return false; if (string.IsNullOrEmpty(TypeString)) return null; - return (this.TypeString == that.TypeString); + return this.TypeString == that.TypeString; } public static JsValue Create<T>(T value) diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Lookup.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Lookup.cs index 855c9fe7..38eeb24f 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Lookup.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Lookup.cs @@ -23,7 +23,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string REQ_COMMAND = "lookup"; - public LookupRequest() : base() + public LookupRequest() { Command = REQ_COMMAND; } @@ -51,7 +51,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = LookupRequest.REQ_COMMAND; - public LookupResponse() : base() + public LookupResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Message.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Message.cs index 44aae46c..4e94bd62 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Message.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Message.cs @@ -48,7 +48,7 @@ namespace QtVsTools.Qml.Debug.V4 return false; if (string.IsNullOrEmpty(Type)) return null; - return (this.Type == that.Type); + return this.Type == that.Type; } protected ProtocolDriver Driver { get; private set; } @@ -70,7 +70,7 @@ namespace QtVsTools.Qml.Debug.V4 // } public const string MSG_TYPE = "v8request"; public const string MSG_SUBTYPE = "request"; - protected Request() : base() + protected Request() { Type = MSG_TYPE; SubType = MSG_SUBTYPE; @@ -99,14 +99,14 @@ namespace QtVsTools.Qml.Debug.V4 return null; } - Response response = null; + Response response; public Response Response { get => response; set => Atomic(() => response == null, () => response = value); } - object tag = null; + object tag; public object Tag { get => tag; @@ -156,7 +156,7 @@ namespace QtVsTools.Qml.Debug.V4 where TArgs : class, new() { [DataMember(Name = "arguments", EmitDefaultValue = false)] - TArgs args = null; + TArgs args; public virtual TArgs Arguments { @@ -174,7 +174,7 @@ namespace QtVsTools.Qml.Debug.V4 // ... // } public const string MSG_TYPE = "v8message"; - protected ServerMessage() : base() + protected ServerMessage() { Type = MSG_TYPE; } @@ -212,7 +212,7 @@ namespace QtVsTools.Qml.Debug.V4 // ... // } public const string MSG_SUBTYPE = "response"; - protected Response() : base() + protected Response() { SubType = MSG_SUBTYPE; } @@ -260,7 +260,7 @@ namespace QtVsTools.Qml.Debug.V4 where TBody : class, new() { [DataMember(Name = "body", EmitDefaultValue = false)] - TBody body = null; + TBody body; public TBody Body { @@ -279,7 +279,7 @@ namespace QtVsTools.Qml.Debug.V4 // ... // } public const string MSG_SUBTYPE = "event"; - protected Event() : base() + protected Event() { SubType = MSG_SUBTYPE; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Scope.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Scope.cs index 7d15c6ed..d349ee15 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Scope.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Scope.cs @@ -61,7 +61,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string REQ_COMMAND = "scope"; - public ScopeRequest() : base() + public ScopeRequest() { Command = REQ_COMMAND; } @@ -105,7 +105,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = ScopeRequest.REQ_COMMAND; - public ScopeResponse() : base() + public ScopeResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4SetBreakpoint.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4SetBreakpoint.cs index 5e32ded1..341922ab 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4SetBreakpoint.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4SetBreakpoint.cs @@ -30,7 +30,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string REQ_COMMAND = "setbreakpoint"; - public SetBreakpointRequest() : base() + public SetBreakpointRequest() { Command = REQ_COMMAND; } @@ -95,7 +95,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = SetBreakpointRequest.REQ_COMMAND; - public SetBreakpointResponse() : base() + public SetBreakpointResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4SetExceptionBreak.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4SetExceptionBreak.cs index 9289b938..fcf9369f 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4SetExceptionBreak.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4SetExceptionBreak.cs @@ -12,7 +12,7 @@ namespace QtVsTools.Qml.Debug.V4 public enum ExceptionBreakType { [EnumString("all")] All = 0, - [EnumString("uncaught")] Uncaught, + [EnumString("uncaught")] Uncaught } [DataContract] @@ -27,7 +27,7 @@ namespace QtVsTools.Qml.Debug.V4 // } // } public const string REQ_COMMAND = "setexceptionbreak"; - public SetExceptionBreakRequest() : base() + public SetExceptionBreakRequest() { Command = REQ_COMMAND; } @@ -65,7 +65,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = SetExceptionBreakRequest.REQ_COMMAND; - public SetExceptionBreakResponse() : base() + public SetExceptionBreakResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Version.cs b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Version.cs index 5e2bf7e4..4570cb04 100644 --- a/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Version.cs +++ b/QtVsTools.Package/QML/Debugging/V4/Messages/QmlDebugV4Version.cs @@ -16,7 +16,7 @@ namespace QtVsTools.Qml.Debug.V4 // "command" : "version" // } public const string REQ_COMMAND = "version"; - public VersionRequest() : base() + public VersionRequest() { Command = REQ_COMMAND; } @@ -38,7 +38,7 @@ namespace QtVsTools.Qml.Debug.V4 // "success" : true // } public const string REQ_COMMAND = VersionRequest.REQ_COMMAND; - public VersionResponse() : base() + public VersionResponse() { Command = REQ_COMMAND; } diff --git a/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs b/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs index eb7d8a04..54ea5a0e 100644 --- a/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs +++ b/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Protocol.cs @@ -29,7 +29,7 @@ namespace QtVsTools.Qml.Debug.V4 { IMessageEventSink sink; DebugClient client; - int nextRequestSeq = 0; + int nextRequestSeq; readonly Dictionary<int, PendingRequest> pendingRequests = new(); Task eventHandlingThread; readonly EventWaitHandle eventReceived = new(false, EventResetMode.AutoReset); diff --git a/QtVsTools.Package/QML/Parser/QmlParserInterop.cs b/QtVsTools.Package/QML/Parser/QmlParserInterop.cs index 492525fa..d26a0520 100644 --- a/QtVsTools.Package/QML/Parser/QmlParserInterop.cs +++ b/QtVsTools.Package/QML/Parser/QmlParserInterop.cs @@ -263,7 +263,7 @@ namespace QtVsTools.Qml return new SourceLocation { Offset = nodeData.ReadInt32(), - Length = nodeData.ReadInt32(), + Length = nodeData.ReadInt32() }; } catch (Exception) { return new SourceLocation(); @@ -383,8 +383,8 @@ namespace QtVsTools.Qml UnmarshalPointer(nodeData, node, GetPropertyRef(() => node.MemberType)); UnmarshalPointer(nodeData, node, GetPropertyRef(() => node.Statement)); UnmarshalPointer(nodeData, node, GetPropertyRef(() => node.Binding)); - node.IsDefaultMember = (nodeData.ReadInt32() != 0); - node.IsReadonlyMember = (nodeData.ReadInt32() != 0); + node.IsDefaultMember = nodeData.ReadInt32() != 0; + node.IsReadonlyMember = nodeData.ReadInt32() != 0; UnmarshalPointer(nodeData, node, GetPropertyRef(() => node.Parameters)); node.DefaultToken = UnmarshalLocation(nodeData); node.ReadonlyToken = UnmarshalLocation(nodeData); @@ -485,7 +485,7 @@ namespace QtVsTools.Qml } #region IDisposable - bool disposed = false; + bool disposed; public void Dispose() { diff --git a/QtVsTools.Package/QML/Syntax/QmlAst.cs b/QtVsTools.Package/QML/Syntax/QmlAst.cs index 8f5f4c83..6b926b93 100644 --- a/QtVsTools.Package/QML/Syntax/QmlAst.cs +++ b/QtVsTools.Package/QML/Syntax/QmlAst.cs @@ -191,7 +191,7 @@ namespace QtVsTools.Qml.Syntax public SourceLocation RBracketToken { get; set; } } - public enum UiPublicMemberType { Signal, Property }; + public enum UiPublicMemberType { Signal, Property } public class UiPublicMember : AstNode { diff --git a/QtVsTools.Package/QML/Syntax/QmlSyntax.cs b/QtVsTools.Package/QML/Syntax/QmlSyntax.cs index f1d40a25..f3af5866 100644 --- a/QtVsTools.Package/QML/Syntax/QmlSyntax.cs +++ b/QtVsTools.Package/QML/Syntax/QmlSyntax.cs @@ -177,7 +177,7 @@ namespace QtVsTools.Qml.Syntax return Create(kind, new SourceLocation { Offset = offset, - Length = length, + Length = length }); } diff --git a/QtVsTools.Package/QtMsBuild/QtModulesEditor.cs b/QtVsTools.Package/QtMsBuild/QtModulesEditor.cs index 0a6af542..c5e970fd 100644 --- a/QtVsTools.Package/QtMsBuild/QtModulesEditor.cs +++ b/QtVsTools.Package/QtMsBuild/QtModulesEditor.cs @@ -41,7 +41,7 @@ namespace QtVsTools.QtMsBuild Id = x.Id, Name = x.Name, IsReadOnly = !x.Selectable, - QT = x.proVarQT.Split(' ').ToHashSet(), + QT = x.proVarQT.Split(' ').ToHashSet() }) .ToList(); diff --git a/QtVsTools.Package/QtMsBuild/QtModulesPopup.xaml.cs b/QtVsTools.Package/QtMsBuild/QtModulesPopup.xaml.cs index 5667dc53..6fa667ec 100644 --- a/QtVsTools.Package/QtMsBuild/QtModulesPopup.xaml.cs +++ b/QtVsTools.Package/QtMsBuild/QtModulesPopup.xaml.cs @@ -63,7 +63,7 @@ namespace QtVsTools.QtMsBuild if (e.Key is not Key.Enter and not Key.Space) return; if (PopupListBox.SelectedItem is Module {IsEnabled: true} module) - module.CheckBox.IsChecked = (module.CheckBox.IsChecked != true); + module.CheckBox.IsChecked = module.CheckBox.IsChecked != true; } private void Window_MouseDown(object sender, MouseButtonEventArgs e) diff --git a/QtVsTools.Package/QtMsBuild/QtProjectBuild.cs b/QtVsTools.Package/QtMsBuild/QtProjectBuild.cs index 3bdc26c4..f830295e 100644 --- a/QtVsTools.Package/QtMsBuild/QtProjectBuild.cs +++ b/QtVsTools.Package/QtMsBuild/QtProjectBuild.cs @@ -18,6 +18,7 @@ using Microsoft.VisualStudio.TaskStatusCenter; using Microsoft.VisualStudio.Threading; using Microsoft.VisualStudio.VCProjectEngine; +using Project = EnvDTE.Project; using Thread = System.Threading.Thread; namespace QtVsTools.QtMsBuild @@ -39,10 +40,7 @@ namespace QtVsTools.QtMsBuild static PunisherQueue<QtProjectBuild> BuildQueue => StaticLazy.Get(() => BuildQueue, () => new PunisherQueue<QtProjectBuild>( - getItemKey: (QtProjectBuild build) => - { - return build.ConfiguredProject; - })); + getItemKey: build => build.ConfiguredProject)); static ConcurrentStopwatch RequestTimer => StaticLazy.Get(() => RequestTimer, () => new ConcurrentStopwatch()); @@ -51,7 +49,7 @@ namespace QtVsTools.QtMsBuild StatusCenter, VsServiceProvider .GetService<SVsTaskStatusCenterService, IVsTaskStatusCenterService>); - EnvDTE.Project Project { get; set; } + Project Project { get; set; } VCProject VcProject { get; set; } UnconfiguredProject UnconfiguredProject { get; set; } ConfiguredProject ConfiguredProject { get; set; } @@ -62,7 +60,7 @@ namespace QtVsTools.QtMsBuild static Task BuildDispatcher { get; set; } public static void StartBuild( - EnvDTE.Project project, + Project project, string projectPath, string configName, Dictionary<string, string> properties, @@ -79,7 +77,7 @@ namespace QtVsTools.QtMsBuild } public static async Task StartBuildAsync( - EnvDTE.Project project, + Project project, string projectPath, string configName, Dictionary<string, string> properties, @@ -117,7 +115,7 @@ namespace QtVsTools.QtMsBuild if (configuredProject == null) throw new ArgumentException(string.Format("Unknown configuration '{0}'.", configName)); - BuildQueue.Enqueue(new QtProjectBuild() + BuildQueue.Enqueue(new QtProjectBuild { Project = project, VcProject = tracker.VcProject, @@ -133,7 +131,7 @@ namespace QtVsTools.QtMsBuild } public static async Task SetOutdatedAsync( - EnvDTE.Project project, + Project project, string projectPath, string configName, LoggerVerbosity verbosity = LoggerVerbosity.Quiet) @@ -168,7 +166,7 @@ namespace QtVsTools.QtMsBuild dispatchStatus = StatusCenter.PreRegister( new TaskHandlerOptions { - Title = "Qt VS Tools", + Title = "Qt VS Tools" }, new TaskProgressData { @@ -187,7 +185,7 @@ namespace QtVsTools.QtMsBuild ProgressText = string.Format( "Refreshing IntelliSense data, {0} project(s) remaining...", BuildQueue.Count), - CanBeCanceled = true, + CanBeCanceled = true }); } await buildRequest.BuildAsync(); @@ -234,10 +232,10 @@ namespace QtVsTools.QtMsBuild var loggerVerbosity = LoggerVerbosity; if (QtVsToolsPackage.Instance.Options.BuildDebugInformation) loggerVerbosity = QtVsToolsPackage.Instance.Options.BuildLoggerVerbosity; - var buildParams = new BuildParameters() + var buildParams = new BuildParameters { - Loggers = (loggerVerbosity != LoggerVerbosity.Quiet) - ? new[] { new QtProjectLogger() { Verbosity = loggerVerbosity } } + Loggers = loggerVerbosity != LoggerVerbosity.Quiet + ? new[] { new QtProjectLogger { Verbosity = loggerVerbosity } } : null }; @@ -311,8 +309,7 @@ namespace QtVsTools.QtMsBuild Messages.Print(string.Format( "{0:HH:mm:ss.FFF} QtProjectBuild({1}): [{2}] {3}\r\n{4}", DateTime.Now, Thread.CurrentThread.ManagedThreadId, - ConfiguredProject.ProjectConfiguration.Name, - resMsg, resInfo.ToString())); + ConfiguredProject.ProjectConfiguration.Name, resMsg, resInfo)); } bool ok = false; @@ -356,7 +353,7 @@ namespace QtVsTools.QtMsBuild while (timer.IsRunning) { try { await lockService.WriteLockAsync( - async (ProjectWriteLockReleaser writeAccess) => + async writeAccess => { ok = await BuildProjectAsync(writeAccess); }); @@ -365,7 +362,7 @@ namespace QtVsTools.QtMsBuild if (timer.ElapsedMilliseconds >= 5000) throw; await lockService.ReadLockAsync( - async (ProjectLockReleaser readAccess) => + async readAccess => { await readAccess.ReleaseAsync(); }); diff --git a/QtVsTools.Package/QtMsBuild/QtProjectIntelliSense.cs b/QtVsTools.Package/QtMsBuild/QtProjectIntelliSense.cs index 85c42ba9..e18d643c 100644 --- a/QtVsTools.Package/QtMsBuild/QtProjectIntelliSense.cs +++ b/QtVsTools.Package/QtMsBuild/QtProjectIntelliSense.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Microsoft.Build.Framework; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Threading; @@ -36,7 +35,7 @@ namespace QtVsTools.QtMsBuild + $"Refreshing: [{configId ?? "(all configs)"}] {project.FullName}"); } string projectPath = project.FullName; - _ = Task.Run(() => RefreshAsync(project, projectPath, configId, selectedFiles, false)); + _ = Task.Run(() => RefreshAsync(project, projectPath, configId, selectedFiles)); } public static async Task RefreshAsync( @@ -74,8 +73,7 @@ namespace QtVsTools.QtMsBuild project, projectPath, config, properties, targets, LoggerVerbosity.Quiet); } else { - await QtProjectBuild.SetOutdatedAsync( - project, projectPath, config, LoggerVerbosity.Quiet); + await QtProjectBuild.SetOutdatedAsync(project, projectPath, config); } } } diff --git a/QtVsTools.Package/QtMsBuild/QtProjectTracker.cs b/QtVsTools.Package/QtMsBuild/QtProjectTracker.cs index 7ef7886e..02e4fad7 100644 --- a/QtVsTools.Package/QtMsBuild/QtProjectTracker.cs +++ b/QtVsTools.Package/QtMsBuild/QtProjectTracker.cs @@ -5,9 +5,7 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Threading.Tasks.Dataflow; @@ -181,7 +179,7 @@ namespace QtVsTools.QtMsBuild lock (CriticalSection) { project.ProjectUnloading -= OnProjectUnloadingAsync; - Instances.TryRemove(project.UnconfiguredProject.FullPath, out var _); + Instances.TryRemove(project.UnconfiguredProject.FullPath, out _); } await Task.Yield(); diff --git a/QtVsTools.Package/QtMsBuild/QtVersionProvider.cs b/QtVsTools.Package/QtMsBuild/QtVersionProvider.cs index f45daed5..e31bc125 100644 --- a/QtVsTools.Package/QtMsBuild/QtVersionProvider.cs +++ b/QtVsTools.Package/QtMsBuild/QtVersionProvider.cs @@ -38,7 +38,7 @@ namespace QtVsTools.QtMsBuild return await Task.FromResult( qtVersions.GetSubKeyNames() - .Select(x => new PageEnumValue(new EnumValue() + .Select(x => new PageEnumValue(new EnumValue { Name = x, DisplayName = x @@ -50,7 +50,7 @@ namespace QtVsTools.QtMsBuild public async Task<IEnumValue> TryCreateEnumValueAsync(string userSuppliedValue) { - return await Task.FromResult(new PageEnumValue(new EnumValue() + return await Task.FromResult(new PageEnumValue(new EnumValue { Name = userSuppliedValue, DisplayName = userSuppliedValue diff --git a/QtVsTools.RegExpr/expression/CharClassSet.cs b/QtVsTools.RegExpr/expression/CharClassSet.cs index 5dabeed6..fd4aad53 100644 --- a/QtVsTools.RegExpr/expression/CharClassSet.cs +++ b/QtVsTools.RegExpr/expression/CharClassSet.cs @@ -117,7 +117,7 @@ namespace QtVsTools.SyntaxAnalysis public IEnumerator<IEnumerable<Element>> GetEnumerator() { - return (new[] { Positives, Negatives }).AsEnumerable().GetEnumerator(); + return new[] { Positives, Negatives }.AsEnumerable().GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() @@ -258,7 +258,7 @@ namespace QtVsTools.SyntaxAnalysis case Op.Minus: classSet = new CharClassSet { - { context.SubSets.First() }, + context.SubSets.First(), { context.SubSets.Last(), Invert } }; break; diff --git a/QtVsTools.RegExpr/expression/RegExpr.cs b/QtVsTools.RegExpr/expression/RegExpr.cs index ac841ed0..dbc17975 100644 --- a/QtVsTools.RegExpr/expression/RegExpr.cs +++ b/QtVsTools.RegExpr/expression/RegExpr.cs @@ -83,7 +83,7 @@ namespace QtVsTools.SyntaxAnalysis StringBuilder pattern, ref RenderMode mode, Stack<Token> tokenStack) { } - public class RegExprException : System.Exception + public class RegExprException : Exception { public RegExprException(string message = null) : base(message) { } } diff --git a/QtVsTools.RegExpr/expression/RegExprLiteral.cs b/QtVsTools.RegExpr/expression/RegExprLiteral.cs index 6011e3f8..d3bee557 100644 --- a/QtVsTools.RegExpr/expression/RegExprLiteral.cs +++ b/QtVsTools.RegExpr/expression/RegExprLiteral.cs @@ -28,12 +28,12 @@ namespace QtVsTools.SyntaxAnalysis { public static RegExprLiteral RegX(string s) { - return new RegExprLiteral() { LiteralExpr = Escape(s) }; + return new RegExprLiteral { LiteralExpr = Escape(s) }; } public static RegExprLiteral RegXRaw(string s) { - return new RegExprLiteral() { LiteralExpr = s }; + return new RegExprLiteral { LiteralExpr = s }; } public static implicit operator RegExpr(string s) diff --git a/QtVsTools.RegExpr/expression/RegExprToken.cs b/QtVsTools.RegExpr/expression/RegExprToken.cs index e8c788ac..df05c393 100644 --- a/QtVsTools.RegExpr/expression/RegExprToken.cs +++ b/QtVsTools.RegExpr/expression/RegExprToken.cs @@ -57,7 +57,7 @@ namespace QtVsTools.SyntaxAnalysis public Token(string id, SkipWhitespace skipWs, RegExpr expr) { Id = id; - SkipLeadingWhitespace = (skipWs == SkipWhitespace.Enable); + SkipLeadingWhitespace = skipWs == SkipWhitespace.Enable; Expr = expr; Rules = new TokenRules(); Children = new HashSet<Token>(); diff --git a/QtVsTools.RegExpr/parser/ParseTree.cs b/QtVsTools.RegExpr/parser/ParseTree.cs index 254a96d7..9639ef9d 100644 --- a/QtVsTools.RegExpr/parser/ParseTree.cs +++ b/QtVsTools.RegExpr/parser/ParseTree.cs @@ -62,7 +62,7 @@ namespace QtVsTools.SyntaxAnalysis public Stack<Node> OperatorStack { get; set; } public Stack<Node> OperandStack { get; set; } - IProductionRule _Rule = null; + IProductionRule _Rule; public IProductionRule Rule { get { return _Rule ??= Token.SelectRule(this); } diff --git a/QtVsTools.RegExpr/parser/Parser.cs b/QtVsTools.RegExpr/parser/Parser.cs index 798fa9a2..9bb62737 100644 --- a/QtVsTools.RegExpr/parser/Parser.cs +++ b/QtVsTools.RegExpr/parser/Parser.cs @@ -89,7 +89,7 @@ namespace QtVsTools.SyntaxAnalysis Begin = capture.Index, End = capture.Index + capture.Length, GroupIdx = groupIdx, - CaptureIdx = captureIdx, + CaptureIdx = captureIdx })) .OrderBy(c => c.Begin) .ToList(); @@ -122,7 +122,7 @@ namespace QtVsTools.SyntaxAnalysis if (topNodes.Length == 1) return topNodes[0]; - var root = new ParseTree.Node() + var root = new ParseTree.Node { CaptureId = string.Empty, Token = null, @@ -130,7 +130,7 @@ namespace QtVsTools.SyntaxAnalysis Begin = 0, End = text.Length, GroupIdx = -1, - CaptureIdx = -1, + CaptureIdx = -1 }; foreach (var node in nodesByToken[Pattern.Root]) (node.Parent = root).ChildNodes.Add(node.Begin, node); diff --git a/QtVsTools.RegExpr/production/ProductionRule.cs b/QtVsTools.RegExpr/production/ProductionRule.cs index 874f455e..7dfbfa59 100644 --- a/QtVsTools.RegExpr/production/ProductionRule.cs +++ b/QtVsTools.RegExpr/production/ProductionRule.cs @@ -160,7 +160,7 @@ namespace QtVsTools.SyntaxAnalysis Action = a.Self, ActionIndex = a.Index, Production = p.Self, - ProductionIndex = p.Index, + ProductionIndex = p.Index }) .OrderByDescending(ap => ap.ProductionIndex) .ThenByDescending(ap => ap.ActionIndex); @@ -195,7 +195,7 @@ namespace QtVsTools.SyntaxAnalysis var type = typeof(T); if (type.IsValueType) - return default(T); + return default; if (type == typeof(string)) return (T)(object)string.Empty; diff --git a/QtVsTools.RegExpr/utils/Utils.cs b/QtVsTools.RegExpr/utils/Utils.cs index 5f2d0f45..5db541cc 100644 --- a/QtVsTools.RegExpr/utils/Utils.cs +++ b/QtVsTools.RegExpr/utils/Utils.cs @@ -17,10 +17,10 @@ namespace QtVsTools.SyntaxAnalysis { return new string(s.SelectMany(c => MetaChars.Contains(c) ? Items('\\', c) : - (c == ' ') ? "\\x20".Cast<char>() : - (c == '\t') ? "\\t".Cast<char>() : - (c == '\r') ? "\\r".Cast<char>() : - (c == '\n') ? "\\n".Cast<char>() : + c == ' ' ? "\\x20" : + c == '\t' ? "\\t" : + c == '\r' ? "\\r" : + c == '\n' ? "\\n" : Items(c)).ToArray()); } diff --git a/QtVsTools.Wizards/Common/WizardWindow.xaml.cs b/QtVsTools.Wizards/Common/WizardWindow.xaml.cs index eb0b6d41..335ec1c7 100644 --- a/QtVsTools.Wizards/Common/WizardWindow.xaml.cs +++ b/QtVsTools.Wizards/Common/WizardWindow.xaml.cs @@ -33,7 +33,7 @@ namespace QtVsTools.Wizards.Common public void Add(WizardPage page) { - bool isFirstPage = (Pages.Count == 0); + bool isFirstPage = Pages.Count == 0; page.Wizard = this; page.NavigateForward += OnNavigateForward; page.NavigatedBackward += OnNavigatedBackwards; diff --git a/QtVsTools.Wizards/ItemWizard/QtClass/QtClassPage.xaml.cs b/QtVsTools.Wizards/ItemWizard/QtClass/QtClassPage.xaml.cs index 8e6b0fa6..638b46f8 100644 --- a/QtVsTools.Wizards/ItemWizard/QtClass/QtClassPage.xaml.cs +++ b/QtVsTools.Wizards/ItemWizard/QtClass/QtClassPage.xaml.cs @@ -8,7 +8,7 @@ using System.Windows.Controls; namespace QtVsTools.Wizards.ItemWizard { - using Wizards.Common; + using Common; public partial class QtClassPage : WizardPage { diff --git a/QtVsTools.Wizards/ItemWizard/QtClass/QtClassWizard.cs b/QtVsTools.Wizards/ItemWizard/QtClass/QtClassWizard.cs index 693345b1..d93c770a 100644 --- a/QtVsTools.Wizards/ItemWizard/QtClass/QtClassWizard.cs +++ b/QtVsTools.Wizards/ItemWizard/QtClass/QtClassWizard.cs @@ -14,11 +14,11 @@ using EnvDTE; namespace QtVsTools.Wizards.ItemWizard { - using QtVsTools.Common; + using Common; using Core; - using Wizards.Common; - using Wizards.ProjectWizard; - using Wizards.Util; + using ProjectWizard; + using QtVsTools.Common; + using Util; using static QtVsTools.Common.EnumExt; @@ -70,8 +70,8 @@ namespace QtVsTools.Wizards.ItemWizard Data = WizardData, Header = @"Welcome to the Qt Class Wizard", Message = @"This wizard will add a new Qt class to your project. The " - + @"wizard creates a .h and .cpp file." + System.Environment.NewLine - + System.Environment.NewLine + "To continue, click Next.", + + @"wizard creates a .h and .cpp file." + Environment.NewLine + + Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, @@ -94,7 +94,7 @@ namespace QtVsTools.Wizards.ItemWizard var className = Parameter[NewClass.SafeItemName]; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); - var result = new Util.ClassNameValidationRule().Validate(className, null); + var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) className = @"QtClass"; diff --git a/QtVsTools.Wizards/ItemWizard/Translation/TranslationPage.xaml.cs b/QtVsTools.Wizards/ItemWizard/Translation/TranslationPage.xaml.cs index 6c12ef7f..b340a7db 100644 --- a/QtVsTools.Wizards/ItemWizard/Translation/TranslationPage.xaml.cs +++ b/QtVsTools.Wizards/ItemWizard/Translation/TranslationPage.xaml.cs @@ -13,8 +13,8 @@ using Microsoft.VisualStudio.Shell.Interop; namespace QtVsTools.Wizards.ItemWizard { - using QtVsTools.VisualStudio; - using Wizards.Common; + using Common; + using VisualStudio; using static Utils; public partial class TranslationPage : WizardPage diff --git a/QtVsTools.Wizards/ItemWizard/Translation/TranslationWizard.cs b/QtVsTools.Wizards/ItemWizard/Translation/TranslationWizard.cs index 758888bc..475c51e7 100644 --- a/QtVsTools.Wizards/ItemWizard/Translation/TranslationWizard.cs +++ b/QtVsTools.Wizards/ItemWizard/Translation/TranslationWizard.cs @@ -12,11 +12,11 @@ using EnvDTE; namespace QtVsTools.Wizards.ItemWizard { - using QtVsTools.Common; + using Common; using Core; - using Wizards.Common; - using Wizards.ProjectWizard; - using Wizards.Util; + using ProjectWizard; + using QtVsTools.Common; + using Util; using static QtVsTools.Common.EnumExt; @@ -59,7 +59,7 @@ namespace QtVsTools.Wizards.ItemWizard NextButtonEnabled = false, FinishButtonEnabled = true, CancelButtonEnabled = true - }, + } }); protected override void BeforeWizardRun() diff --git a/QtVsTools.Wizards/ItemWizard/WidgetsClass/WidgetsClassWizard.cs b/QtVsTools.Wizards/ItemWizard/WidgetsClass/WidgetsClassWizard.cs index 0c494eb6..3f84b8dd 100644 --- a/QtVsTools.Wizards/ItemWizard/WidgetsClass/WidgetsClassWizard.cs +++ b/QtVsTools.Wizards/ItemWizard/WidgetsClass/WidgetsClassWizard.cs @@ -15,11 +15,11 @@ using EnvDTE; namespace QtVsTools.Wizards.ItemWizard { - using QtVsTools.Common; + using Common; using Core; - using Wizards.Common; - using Wizards.ProjectWizard; - using Wizards.Util; + using ProjectWizard; + using QtVsTools.Common; + using Util; using static QtVsTools.Common.EnumExt; @@ -80,8 +80,8 @@ namespace QtVsTools.Wizards.ItemWizard Header = @"Welcome to the Qt Widgets Class Wizard", Message = @"This wizard will add a new Qt Widgets class to your project. " + @"The wizard creates a .h and .cpp file. It also creates a new " - + @"empty form." + System.Environment.NewLine - + System.Environment.NewLine + "To continue, click Next.", + + @"empty form." + Environment.NewLine + + Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, @@ -107,7 +107,7 @@ namespace QtVsTools.Wizards.ItemWizard var className = Parameter[NewClass.SafeItemName]; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); - var result = new Util.ClassNameValidationRule().Validate(className, null); + var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) className = @"QtWidgetsClass"; diff --git a/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs b/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs index 403ecfd9..857d8e2f 100644 --- a/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs +++ b/QtVsTools.Wizards/ProjectWizard/ConfigPage.xaml.cs @@ -17,10 +17,11 @@ using Microsoft.Win32; namespace QtVsTools.Wizards.ProjectWizard { + using Common; using Core; using QtVsTools.Common; - using Wizards.Common; - using static Wizards.Common.WizardData; + + using static Common.WizardData; using static Utils; public partial class ConfigPage : WizardPage @@ -67,7 +68,7 @@ namespace QtVsTools.Wizards.ProjectWizard public IEnumerable<Module> AllModules => Modules.Values.OrderBy(module => module.Name); public IEnumerable<Module> SelectedModules - => Modules.Values.Where((Module m) => m.IsSelected); + => Modules.Values.Where(m => m.IsSelected); IEnumerable<string> IWizardConfiguration.Modules { @@ -79,7 +80,7 @@ namespace QtVsTools.Wizards.ProjectWizard .Select(module => module.Id) .ToList(); } - return SelectedModules.SelectMany((Module m) => m.Id.Split(' ')); + return SelectedModules.SelectMany(m => m.Id.Split(' ')); } } @@ -95,15 +96,15 @@ namespace QtVsTools.Wizards.ProjectWizard Platform = Platform, IsDebug = IsDebug, Modules = AllModules - .Select((Module m) => m.Clone()) - .ToDictionary((Module m) => m.Name) + .Select(m => m.Clone()) + .ToDictionary(m => m.Name) }; } } class CloneableList<T> : List<T> where T : ICloneable<T> { - public CloneableList() : base() + public CloneableList() { } public CloneableList(IEnumerable<T> collection) : base(collection) @@ -163,12 +164,12 @@ namespace QtVsTools.Wizards.ProjectWizard DefaultModules = QtModules.Instance.GetAvailableModules(defaultQtVersionInfo.qtMajor) .Where(mi => mi.Selectable) - .Select(mi => new Module() + .Select(mi => new Module { Name = mi.Name, Id = mi.proVarQT, IsSelected = Data.DefaultModules.Contains(mi.LibraryPrefix), - IsReadOnly = Data.DefaultModules.Contains(mi.LibraryPrefix), + IsReadOnly = Data.DefaultModules.Contains(mi.LibraryPrefix) }).ToList(); defaultConfigs = new CloneableList<Config> { @@ -356,14 +357,14 @@ namespace QtVsTools.Wizards.ProjectWizard : string.Empty; config.Modules = QtModules.Instance.GetAvailableModules(config.QtVersion.qtMajor) - .Where((QtModule mi) => mi.Selectable) - .Select((QtModule mi) => new Module() + .Where(mi => mi.Selectable) + .Select(mi => new Module { Name = mi.Name, Id = mi.proVarQT, IsSelected = Data.DefaultModules.Contains(mi.LibraryPrefix), - IsReadOnly = Data.DefaultModules.Contains(mi.LibraryPrefix), - }).ToDictionary((Module m) => m.Name); + IsReadOnly = Data.DefaultModules.Contains(mi.LibraryPrefix) + }).ToDictionary(m => m.Name); } else if (config.QtVersionPath.StartsWith("SSH:")) { config.Target = ProjectTargets.LinuxSSH.Cast<string>(); } else if (config.QtVersionPath.StartsWith("WSL:")) { @@ -452,14 +453,14 @@ namespace QtVsTools.Wizards.ProjectWizard protected override void OnNextButtonClick(object sender, RoutedEventArgs e) { Data.ProjectModel = ProjectModel; - Data.Configs = currentConfigs.Cast<IWizardConfiguration>(); + Data.Configs = currentConfigs; base.OnNextButtonClick(sender, e); } protected override void OnFinishButtonClick(object sender, RoutedEventArgs e) { Data.ProjectModel = ProjectModel; - Data.Configs = currentConfigs.Cast<IWizardConfiguration>(); + Data.Configs = currentConfigs; base.OnFinishButtonClick(sender, e); } diff --git a/QtVsTools.Wizards/ProjectWizard/Console/ConsoleWizard.cs b/QtVsTools.Wizards/ProjectWizard/Console/ConsoleWizard.cs index b20c141f..b8599202 100644 --- a/QtVsTools.Wizards/ProjectWizard/Console/ConsoleWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/Console/ConsoleWizard.cs @@ -7,8 +7,8 @@ using System.Collections.Generic; namespace QtVsTools.Wizards.ProjectWizard { + using Common; using QtVsTools.Common; - using Wizards.Common; public class ConsoleWizard : ProjectTemplateWizard { diff --git a/QtVsTools.Wizards/ProjectWizard/Designer/DesignerPage.xaml.cs b/QtVsTools.Wizards/ProjectWizard/Designer/DesignerPage.xaml.cs index c0ea2d3b..59972318 100644 --- a/QtVsTools.Wizards/ProjectWizard/Designer/DesignerPage.xaml.cs +++ b/QtVsTools.Wizards/ProjectWizard/Designer/DesignerPage.xaml.cs @@ -8,7 +8,7 @@ using System.Windows.Controls; namespace QtVsTools.Wizards.ProjectWizard { - using Wizards.Common; + using Common; public partial class DesignerPage : WizardPage { diff --git a/QtVsTools.Wizards/ProjectWizard/Designer/DesignerWizard.cs b/QtVsTools.Wizards/ProjectWizard/Designer/DesignerWizard.cs index b647b237..cfb4c17e 100644 --- a/QtVsTools.Wizards/ProjectWizard/Designer/DesignerWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/Designer/DesignerWizard.cs @@ -11,9 +11,9 @@ using EnvDTE; namespace QtVsTools.Wizards.ProjectWizard { + using Common; using Core; using QtVsTools.Common; - using Wizards.Common; using static QtVsTools.Common.EnumExt; @@ -30,7 +30,7 @@ namespace QtVsTools.Wizards.ProjectWizard [String("baseclass")] BaseClass, [String("sourcefilename")] SourceFileName, [String("headerfilename")] HeaderFileName, - [String("include")] Include, + [String("include")] Include } enum NewDesignerPlugin @@ -39,7 +39,7 @@ namespace QtVsTools.Wizards.ProjectWizard [String("objname")] ObjectName, [String("pluginsourcefilename")] SourceFileName, [String("pluginheaderfilename")] HeaderFileName, - [String("plugin_json")] JsonFileName, + [String("plugin_json")] JsonFileName } protected override WizardData WizardData => Lazy.Get(() => @@ -143,7 +143,7 @@ namespace QtVsTools.Wizards.ProjectWizard protected override void OnProjectGenerated(Project project) { - if (Core.QtProject.Create(project) is {} qtPro) + if (QtProject.Create(project) is {} qtPro) QtProject.MarkAsQtPlugin(qtPro); } } diff --git a/QtVsTools.Wizards/ProjectWizard/Empty/EmptyWizard.cs b/QtVsTools.Wizards/ProjectWizard/Empty/EmptyWizard.cs index 6da5af51..86919580 100644 --- a/QtVsTools.Wizards/ProjectWizard/Empty/EmptyWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/Empty/EmptyWizard.cs @@ -7,8 +7,8 @@ using System.Collections.Generic; namespace QtVsTools.Wizards.ProjectWizard { + using Common; using QtVsTools.Common; - using Wizards.Common; public class EmptyWizard : ProjectTemplateWizard { @@ -19,7 +19,7 @@ namespace QtVsTools.Wizards.ProjectWizard protected override WizardData WizardData => Lazy.Get(() => WizardData, () => new WizardData { - DefaultModules = new List<string> { } + DefaultModules = new List<string>() }); protected override WizardWindow WizardWindow => Lazy.Get(() => @@ -45,7 +45,7 @@ namespace QtVsTools.Wizards.ProjectWizard PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = true, - CancelButtonEnabled = true, + CancelButtonEnabled = true } }); } diff --git a/QtVsTools.Wizards/ProjectWizard/Gui/GuiWizard.cs b/QtVsTools.Wizards/ProjectWizard/Gui/GuiWizard.cs index 2629e322..176192e3 100644 --- a/QtVsTools.Wizards/ProjectWizard/Gui/GuiWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/Gui/GuiWizard.cs @@ -14,9 +14,9 @@ using EnvDTE; namespace QtVsTools.Wizards.ProjectWizard { - using QtVsTools.Common; + using Common; using Core; - using Wizards.Common; + using QtVsTools.Common; using static QtVsTools.Common.EnumExt; @@ -27,7 +27,7 @@ namespace QtVsTools.Wizards.ProjectWizard protected override Options TemplateType => Options.Application | Options.GUISystem; readonly Func<IWizardConfiguration, bool> whereConfigTargetIsWindowsStore - = (IWizardConfiguration config) => config.Target.EqualTo(ProjectTargets.WindowsStore); + = config => config.Target.EqualTo(ProjectTargets.WindowsStore); enum NewClass { @@ -35,7 +35,7 @@ namespace QtVsTools.Wizards.ProjectWizard [String("baseclass")] BaseClass, [String("sourcefilename")] SourceFileName, [String("headerfilename")] HeaderFileName, - [String("include")] Include, + [String("include")] Include } enum NewGuiProject @@ -47,7 +47,7 @@ namespace QtVsTools.Wizards.ProjectWizard [String("forward_declare_class")] ForwardDeclClass, [String("multiple_inheritance")] MultipleInheritance, [String("ui_classname")] UiClassName, - [String("member")] Member, + [String("member")] Member } enum Meta @@ -77,8 +77,8 @@ namespace QtVsTools.Wizards.ProjectWizard Header = @"Welcome to the Qt Widgets Application Wizard", Message = @"This wizard generates a Qt Widgets application project. The " + @"application derives from QApplication and includes an empty " - + @"widget." + System.Environment.NewLine - + System.Environment.NewLine + "To continue, click Next.", + + @"widget." + Environment.NewLine + + Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, @@ -151,7 +151,7 @@ namespace QtVsTools.Wizards.ProjectWizard Include = "assets/logo_44x44.png", Filter = "Resource Files", WhereConfig = whereConfigTargetIsWindowsStore - }, + } }; } @@ -231,7 +231,7 @@ namespace QtVsTools.Wizards.ProjectWizard = Path.Combine(pkgInstallPath, @"ProjectTemplates\VC\Qt\1033\gui\gui.ico"); File.Copy(templateIcon, projectIcon); File.SetAttributes(projectIcon, - File.GetAttributes(projectIcon) & (~FileAttributes.ReadOnly)); + File.GetAttributes(projectIcon) & ~FileAttributes.ReadOnly); iconExists = true; } catch (Exception /*ex*/) { // Silently ignore any error, the project is working diff --git a/QtVsTools.Wizards/ProjectWizard/Library/LibraryClassPage.xaml.cs b/QtVsTools.Wizards/ProjectWizard/Library/LibraryClassPage.xaml.cs index 4ab0f236..d7eb04d5 100644 --- a/QtVsTools.Wizards/ProjectWizard/Library/LibraryClassPage.xaml.cs +++ b/QtVsTools.Wizards/ProjectWizard/Library/LibraryClassPage.xaml.cs @@ -8,7 +8,7 @@ using System.Windows.Controls; namespace QtVsTools.Wizards.ProjectWizard { - using Wizards.Common; + using Common; public partial class LibraryClassPage : WizardPage { diff --git a/QtVsTools.Wizards/ProjectWizard/Library/LibraryWizard.cs b/QtVsTools.Wizards/ProjectWizard/Library/LibraryWizard.cs index 7cb93c2f..426ca4ce 100644 --- a/QtVsTools.Wizards/ProjectWizard/Library/LibraryWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/Library/LibraryWizard.cs @@ -10,8 +10,8 @@ using System.Windows.Controls; namespace QtVsTools.Wizards.ProjectWizard { + using Common; using QtVsTools.Common; - using Wizards.Common; using static QtVsTools.Common.EnumExt; diff --git a/QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs b/QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs index 398d0e2c..bf14ec1e 100644 --- a/QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/ProjectTemplateWizard.cs @@ -18,11 +18,11 @@ using EnvDTE; namespace QtVsTools.Wizards.ProjectWizard { + using Common; using Core; using Core.QtMsBuild; - using VisualStudio; using QtVsTools.Common; - using Wizards.Common; + using VisualStudio; using WhereConfig = Func<IWizardConfiguration, bool>; @@ -53,14 +53,14 @@ namespace QtVsTools.Wizards.ProjectWizard [String("x64")] X64, Win32, ARM64, - ARM, + ARM } public abstract partial class ProjectTemplateWizard : IWizard { LazyFactory Lazy { get; } = new(); - private readonly WhereConfig WhereConfig_SelectAll = (x => true); + private readonly WhereConfig WhereConfig_SelectAll = x => true; protected struct ItemProperty { @@ -120,7 +120,7 @@ namespace QtVsTools.Wizards.ProjectWizard protected virtual bool UsePrecompiledHeaders => WizardData.UsePrecompiledHeader; private Dictionary<string, string> ParameterValues { get; set; } - protected EnvDTE.DTE Dte { get; private set; } + protected DTE Dte { get; private set; } protected virtual ItemDef PrecompiledHeader => Lazy.Get(() => PrecompiledHeader, () => new ItemDef @@ -136,7 +136,7 @@ namespace QtVsTools.Wizards.ProjectWizard ItemType = "ClCompile", Include = "stdafx.cpp", Properties = new ItemProperty("PrecompiledHeader", "Create"), - Filter = "Source Files", + Filter = "Source Files" }); protected class TemplateParameters @@ -175,7 +175,7 @@ namespace QtVsTools.Wizards.ProjectWizard QtSettings, BuildSettings, ProjectItems, - FilterItems, + FilterItems } protected TemplateParameters Parameter => Lazy.Get(() => @@ -675,7 +675,7 @@ namespace QtVsTools.Wizards.ProjectWizard xml = new StringBuilder(); foreach (ItemDef item in projectItems) { - bool itemHasProperties = (item.WhereConfig != null || item.Properties != null); + bool itemHasProperties = item.WhereConfig != null || item.Properties != null; xml.Append(string.Format(@" <{0} Include=""{1}""{2}", /*{0}*/ item.ItemType, @@ -747,10 +747,7 @@ namespace QtVsTools.Wizards.ProjectWizard protected static string FormatParam(string paramValue) { // Remove empty lines; replace with first newline (if any) - paramValue = patternEmptyLines.Replace(paramValue, - (Match m) => m.Groups["FIRST_NL"].Value); - - return paramValue; + return patternEmptyLines.Replace(paramValue, m => m.Groups["FIRST_NL"].Value); } } } diff --git a/QtVsTools.Wizards/ProjectWizard/Quick/QuickWizard.cs b/QtVsTools.Wizards/ProjectWizard/Quick/QuickWizard.cs index f7570afa..1bf671d6 100644 --- a/QtVsTools.Wizards/ProjectWizard/Quick/QuickWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/Quick/QuickWizard.cs @@ -7,8 +7,8 @@ using System.Collections.Generic; namespace QtVsTools.Wizards.ProjectWizard { + using Common; using QtVsTools.Common; - using Wizards.Common; using static QtVsTools.Common.EnumExt; public class QuickWizard : ProjectTemplateWizard @@ -51,7 +51,7 @@ namespace QtVsTools.Wizards.ProjectWizard PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = true, - CancelButtonEnabled = true, + CancelButtonEnabled = true } }); diff --git a/QtVsTools.Wizards/ProjectWizard/Server/ServerPage.xaml.cs b/QtVsTools.Wizards/ProjectWizard/Server/ServerPage.xaml.cs index 7bcf231a..d255599d 100644 --- a/QtVsTools.Wizards/ProjectWizard/Server/ServerPage.xaml.cs +++ b/QtVsTools.Wizards/ProjectWizard/Server/ServerPage.xaml.cs @@ -8,7 +8,7 @@ using System.Windows.Controls; namespace QtVsTools.Wizards.ProjectWizard { - using Wizards.Common; + using Common; public partial class ServerPage : WizardPage { diff --git a/QtVsTools.Wizards/ProjectWizard/Server/ServerWizard.cs b/QtVsTools.Wizards/ProjectWizard/Server/ServerWizard.cs index 991fa78a..95d7c836 100644 --- a/QtVsTools.Wizards/ProjectWizard/Server/ServerWizard.cs +++ b/QtVsTools.Wizards/ProjectWizard/Server/ServerWizard.cs @@ -8,14 +8,13 @@ using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Windows.Controls; -using Microsoft.VisualStudio.Shell; using EnvDTE; namespace QtVsTools.Wizards.ProjectWizard { - using QtVsTools.Common; + using Common; using Core; - using Wizards.Common; + using QtVsTools.Common; using static QtVsTools.Common.EnumExt; @@ -30,14 +29,14 @@ namespace QtVsTools.Wizards.ProjectWizard [String("classname")] ClassName, [String("sourcefilename")] SourceFileName, [String("headerfilename")] HeaderFileName, - [String("include")] Include, + [String("include")] Include } enum NewActiveQtProject { [String("pro_name")] Name, [String("uifilename")] UiFileName, - [String("ui_hdr")] UiHeaderName, + [String("ui_hdr")] UiHeaderName } protected override WizardData WizardData => Lazy.Get(() => diff --git a/Tests/Test_QtMsBuild.Tasks/Test_Join.cs b/Tests/Test_QtMsBuild.Tasks/Test_Join.cs index 12aa02b2..d194ad35 100644 --- a/Tests/Test_QtMsBuild.Tasks/Test_Join.cs +++ b/Tests/Test_QtMsBuild.Tasks/Test_Join.cs @@ -20,35 +20,35 @@ namespace QtVsTools.Test.QtMsBuild.Tasks { new("A", new Dictionary<string, string> { { "X", "foo" }, - { "Y", "42" }, + { "Y", "42" } }), new("B", new Dictionary<string, string> { { "X", "sna" }, - { "Y", "99" }, + { "Y", "99" } }), new("C", new Dictionary<string, string> { { "X", "bar" }, - { "Y", "3.14159" }, - }), + { "Y", "3.14159" } + }) }; readonly ITaskItem[] RightItems = new TaskItem[] { new("A", new Dictionary<string, string> { { "Z", "foo" }, - { "Y", "99" }, + { "Y", "99" } }), new("B", new Dictionary<string, string> { { "Z", "sna" }, - { "Y", "2.71828" }, + { "Y", "2.71828" } }), new("B", new Dictionary<string, string> { { "Z", "bar" }, - { "Y", "42" }, + { "Y", "42" } }), new("A", new Dictionary<string, string> { { "Z", "bar" }, - { "Y", "99" }, - }), + { "Y", "99" } + }) }; [TestMethod] @@ -156,7 +156,7 @@ namespace QtVsTools.Test.QtMsBuild.Tasks var newLeftItems = LeftItems .Append(new TaskItem("D", new Dictionary<string, string> { { "X", "zzz" }, - { "Y", "99" }, + { "Y", "99" } })) .ToArray(); diff --git a/Tests/Test_QtMsBuild.Tasks/Test_QtRunTask.cs b/Tests/Test_QtMsBuild.Tasks/Test_QtRunTask.cs index 8bd19ce5..a9168df0 100644 --- a/Tests/Test_QtMsBuild.Tasks/Test_QtRunTask.cs +++ b/Tests/Test_QtMsBuild.Tasks/Test_QtRunTask.cs @@ -45,7 +45,7 @@ namespace QtVsTools.Test.QtMsBuild.Tasks ITaskItem[] sourceItems = new TaskItem[] { new("main.cpp", new Dictionary<string, string> { - { "EnforceTypeConversionRules", "false" }, + { "EnforceTypeConversionRules", "false" } }) }; diff --git a/Tests/Test_QtVsTools.Core/Properties/AssemblyInfo.cs b/Tests/Test_QtVsTools.Core/Properties/AssemblyInfo.cs index f0732b21..65387b7d 100644 --- a/Tests/Test_QtVsTools.Core/Properties/AssemblyInfo.cs +++ b/Tests/Test_QtVsTools.Core/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Test_QtVsTools.Core")] diff --git a/Tests/Test_QtVsTools.Package/Properties/AssemblyInfo.cs b/Tests/Test_QtVsTools.Package/Properties/AssemblyInfo.cs index 2d8725ce..4e314fad 100644 --- a/Tests/Test_QtVsTools.Package/Properties/AssemblyInfo.cs +++ b/Tests/Test_QtVsTools.Package/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Test_QtVsTools.Package")] diff --git a/Tests/Test_QtVsTools.RegExpr/Test_Matches.cs b/Tests/Test_QtVsTools.RegExpr/Test_Matches.cs index 4ed24548..667dcde1 100644 --- a/Tests/Test_QtVsTools.RegExpr/Test_Matches.cs +++ b/Tests/Test_QtVsTools.RegExpr/Test_Matches.cs @@ -9,7 +9,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; namespace QtVsTools.Test.RegExpr { - using SyntaxAnalysis; using static SyntaxAnalysis.RegExpr; using Property = KeyValuePair<string, string>; diff --git a/Tests/Test_QtVsTools.RegExpr/Test_XmlIntParser.cs b/Tests/Test_QtVsTools.RegExpr/Test_XmlIntParser.cs index 1db34eab..6635a5fe 100644 --- a/Tests/Test_QtVsTools.RegExpr/Test_XmlIntParser.cs +++ b/Tests/Test_QtVsTools.RegExpr/Test_XmlIntParser.cs @@ -116,7 +116,7 @@ namespace QtVsTools.Test.RegExpr var exprLPar = new Token(IdExprLPar, charLPar & !LookAhead[SkipWs & (charRPar | charLt)]) { - new LeftDelimiterRule<string>() + new LeftDelimiterRule<string> { Capture(value => value) } @@ -147,8 +147,8 @@ namespace QtVsTools.Test.RegExpr { new Rule<string> { - Create(IdNum, (int expr) => "=" + expr.ToString()), - Create(IdExpr, (int expr) => "=" + expr.ToString()) + Create(IdNum, (int expr) => "=" + expr), + Create(IdExpr, (int expr) => "=" + expr) } }; |