aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2023-03-01 09:53:29 +0100
committerKarsten Heimrich <karsten.heimrich@qt.io>2023-03-15 13:19:29 +0000
commita5ff00dbc59f2ec1400e756e886c0c9f2738d3ba (patch)
tree0861763c37350192ee1db7a11c494a437aa113d0
parentff4bac46d98a9e33b5f074bae055e957f418bfb8 (diff)
Use Array.Empty<T>() method
Change-Id: I2401b92f730c007af27263ddb57d7573edb05d7a Reviewed-by: Miguel Costa <miguel.costa@qt.io>
-rw-r--r--QtMSBuild/Tasks/Flatten.cs4
-rw-r--r--QtMSBuild/Tasks/HostExec_LinuxSSL.cs6
-rw-r--r--QtMSBuild/Tasks/QtRunTask.cs2
-rw-r--r--QtVsTools.Core/Common/Json/Serializer.cs2
-rw-r--r--QtVsTools.Core/Common/Prototyped.cs2
-rw-r--r--QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs2
-rw-r--r--QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Client.cs2
-rw-r--r--QtVsTools.RegExpr/production/ProductionRule.cs2
8 files changed, 13 insertions, 9 deletions
diff --git a/QtMSBuild/Tasks/Flatten.cs b/QtMSBuild/Tasks/Flatten.cs
index a427097e..7b365aef 100644
--- a/QtMSBuild/Tasks/Flatten.cs
+++ b/QtMSBuild/Tasks/Flatten.cs
@@ -6,6 +6,8 @@
#region Task TaskName="Flatten"
#region Using
+
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Build.Framework;
@@ -65,7 +67,7 @@ namespace QtVsTools.QtMsBuild.Tasks
"RecursiveDir", "RelativeDir", "RootDir",
};
if (Metadata == null)
- Metadata = new string[0];
+ Metadata = Array.Empty<string>();
var requestedNames = new HashSet<string>(Metadata.Where(x => !string.IsNullOrEmpty(x)));
var newItems = new List<ITaskItem>();
foreach (var item in Items) {
diff --git a/QtMSBuild/Tasks/HostExec_LinuxSSL.cs b/QtMSBuild/Tasks/HostExec_LinuxSSL.cs
index e2ecbef0..5f2af32b 100644
--- a/QtMSBuild/Tasks/HostExec_LinuxSSL.cs
+++ b/QtMSBuild/Tasks/HostExec_LinuxSSL.cs
@@ -10,6 +10,8 @@
#endregion
#region Using
+
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Build.Framework;
@@ -70,7 +72,7 @@ namespace QtVsTools.QtMsBuild.Tasks
string.Format("{0}/{1}", RemoteProjectDir, WorkingDirectory)
};
- var localFilesToCopyRemotelyMapping = new string[0];
+ var localFilesToCopyRemotelyMapping = Array.Empty<string>();
if (Inputs != null) {
localFilesToCopyRemotelyMapping = Inputs
.Select(x => string.Format(@"{0}:={1}/{2}",
@@ -82,7 +84,7 @@ namespace QtVsTools.QtMsBuild.Tasks
.Select(x => string.Format("\x24(dirname {0})", x.GetMetadata("Value"))));
}
- var remoteFilesToCopyLocallyMapping = new string[0];
+ var remoteFilesToCopyLocallyMapping = Array.Empty<string>();
if (Outputs != null) {
remoteFilesToCopyLocallyMapping = Outputs
.Select(x => string.Format(@"{0}/{1}:={2}",
diff --git a/QtMSBuild/Tasks/QtRunTask.cs b/QtMSBuild/Tasks/QtRunTask.cs
index d0b51391..14983336 100644
--- a/QtMSBuild/Tasks/QtRunTask.cs
+++ b/QtMSBuild/Tasks/QtRunTask.cs
@@ -148,7 +148,7 @@ namespace QtVsTools.QtMsBuild.Tasks
// For each source item ...
// Instantiate task
- var task = ctorInfo.Invoke(new object[0]) as ToolTask;
+ var task = ctorInfo.Invoke(Array.Empty<object>()) as ToolTask;
task.BuildEngine = BuildEngine;
task.HostObject = HostObject;
diff --git a/QtVsTools.Core/Common/Json/Serializer.cs b/QtVsTools.Core/Common/Json/Serializer.cs
index 6ab8aed1..3fd82084 100644
--- a/QtVsTools.Core/Common/Json/Serializer.cs
+++ b/QtVsTools.Core/Common/Json/Serializer.cs
@@ -153,7 +153,7 @@ namespace QtVsTools.Json
///
public static IJsonData Parse(byte[] rawJsonData)
{
- rawJsonData ??= new byte[0];
+ rawJsonData ??= Array.Empty<byte>();
var data = new JsonData()
{
diff --git a/QtVsTools.Core/Common/Prototyped.cs b/QtVsTools.Core/Common/Prototyped.cs
index 3cff15cd..45c64c8e 100644
--- a/QtVsTools.Core/Common/Prototyped.cs
+++ b/QtVsTools.Core/Common/Prototyped.cs
@@ -47,7 +47,7 @@ namespace QtVsTools
if (ctorInfo == null)
throw new NotSupportedException("No default constructor: " + type.Name);
- return ctorInfo.Invoke(new object[0]) as TBase;
+ return ctorInfo.Invoke(Array.Empty<object>()) as TBase;
}
private static TBase CreatePrototype(Type type)
diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs
index 3901fbb0..cba715f9 100644
--- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs
+++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Property.cs
@@ -142,7 +142,7 @@ namespace QtVsTools.Qml.Debug.AD7
{
var info = new DEBUG_PROPERTY_INFO[1];
(x.Value as IDebugProperty2).GetPropertyInfo(dwFields, dwRadix, 0,
- new IDebugReference2[0], 0, info);
+ Array.Empty<IDebugReference2>(), 0, info);
return info[0];
}));
return VSConstants.S_OK;
diff --git a/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Client.cs b/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Client.cs
index 0864b599..4e6059de 100644
--- a/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Client.cs
+++ b/QtVsTools.Package/QML/Debugging/V4/QmlDebugV4Client.cs
@@ -264,7 +264,7 @@ namespace QtVsTools.Qml.Debug.V4
if (State != DebugClientState.Connected)
return false;
var messageTypeData = Encoding.UTF8.GetBytes(messageType);
- messageParams ??= new byte[0];
+ messageParams ??= Array.Empty<byte>();
System.Diagnostics.Debug.WriteLine(
$">> {messageType} {Encoding.UTF8.GetString(messageParams)}");
diff --git a/QtVsTools.RegExpr/production/ProductionRule.cs b/QtVsTools.RegExpr/production/ProductionRule.cs
index 503c10a8..c275a146 100644
--- a/QtVsTools.RegExpr/production/ProductionRule.cs
+++ b/QtVsTools.RegExpr/production/ProductionRule.cs
@@ -217,7 +217,7 @@ namespace QtVsTools.SyntaxAnalysis
if (ctorInfo == null)
throw new InvalidOperationException("No default constructor: " + type.Name);
- return (T)ctorInfo.Invoke(new object[0]);
+ return (T)ctorInfo.Invoke(Array.Empty<object>());
}
}