Fix IDE0028, IDE0300, IDE0301, IDE0302, IDE0303, IDE0304.

Silence IDE0305.
This commit is contained in:
RoosterDragon
2025-03-03 17:29:45 +00:00
committed by Pavel Penev
parent 0740991c12
commit 79454d8fd2
559 changed files with 1661 additions and 1751 deletions

View File

@@ -16,7 +16,7 @@ namespace OpenRA
{
public class Arguments
{
readonly Dictionary<string, string> args = new();
readonly Dictionary<string, string> args = [];
public static Arguments Empty => new();

View File

@@ -105,34 +105,34 @@ namespace OpenRA.Support
static readonly string[] NativeLibraryPrefixes;
static readonly string[] ManagedAssemblyExtensions =
{
[
".dll",
".ni.dll",
".exe",
".ni.exe"
};
];
static ManagedLoadContext()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
NativeLibraryPrefixes = new[] { "" };
NativeLibraryExtensions = new[] { ".dll" };
NativeLibraryPrefixes = [""];
NativeLibraryExtensions = [".dll"];
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
NativeLibraryPrefixes = new[] { "", "lib", };
NativeLibraryExtensions = new[] { ".dylib" };
NativeLibraryPrefixes = ["", "lib",];
NativeLibraryExtensions = [".dylib"];
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
NativeLibraryPrefixes = new[] { "", "lib" };
NativeLibraryExtensions = new[] { ".so", ".so.1" };
NativeLibraryPrefixes = ["", "lib"];
NativeLibraryExtensions = [".so", ".so.1"];
}
else
{
NativeLibraryPrefixes = Array.Empty<string>();
NativeLibraryExtensions = Array.Empty<string>();
NativeLibraryPrefixes = [];
NativeLibraryExtensions = [];
}
}
@@ -344,7 +344,7 @@ namespace OpenRA.Support
static IEnumerable<string> GetRids(RuntimeFallbacks runtimeGraph)
{
return Enumerable.Concat(new[] { runtimeGraph.Runtime }, runtimeGraph?.Fallbacks ?? Enumerable.Empty<string>());
return Enumerable.Concat([runtimeGraph.Runtime], runtimeGraph?.Fallbacks ?? Enumerable.Empty<string>());
}
static IEnumerable<string> SelectAssets(IEnumerable<string> rids, IReadOnlyCollection<RuntimeAssetGroup> groups)

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Support
sealed class Benchmark
{
readonly string prefix;
readonly Dictionary<string, List<BenchmarkPoint>> samples = new();
readonly Dictionary<string, List<BenchmarkPoint>> samples = [];
public Benchmark(string prefix)
{

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Support
public class HttpQueryBuilder : IEnumerable<KeyValuePair<string, string>>
{
readonly string url;
readonly List<KeyValuePair<string, string>> parameters = new();
readonly List<KeyValuePair<string, string>> parameters = [];
public HttpQueryBuilder(string url)
{

View File

@@ -42,7 +42,7 @@ namespace OpenRA
{
const int CreateLogFileMaxRetryCount = 128;
static readonly ConcurrentDictionary<string, ChannelInfo> Channels = new();
static readonly ConcurrentDictionary<string, ChannelInfo> Channels = [];
static readonly Channel<ChannelData> Channel;
static readonly ChannelWriter<ChannelData> ChannelWriter;
static readonly CancellationTokenSource CancellationToken = new();

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Support
public static class PerfHistory
{
static readonly Color[] Colors =
{
[
Color.Red, Color.Green,
Color.Orange, Color.Yellow,
Color.Fuchsia, Color.Lime,
@@ -24,7 +24,7 @@ namespace OpenRA.Support
Color.White, Color.Teal,
Color.Pink, Color.MediumPurple,
Color.Olive, Color.CornflowerBlue
};
];
static int nextColor;

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Support
Write();
else if (ticks > thresholdTicks)
{
parent.children ??= new List<PerfTimer>();
parent.children ??= [];
parent.children.Add(this);
}
}

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Support
public static readonly IReadOnlyDictionary<string, int> NoVariables = new ReadOnlyDictionary<string, int>(new Dictionary<string, int>());
public readonly string Expression;
readonly HashSet<string> variables = new();
readonly HashSet<string> variables = [];
public IEnumerable<string> Variables => variables;
enum CharClass { Whitespace, Operator, Mixed, Id, Digit }
@@ -717,8 +717,8 @@ namespace OpenRA.Support
sealed class AstStack
{
readonly List<Expression> expressions = new();
readonly List<ExpressionType> types = new();
readonly List<Expression> expressions = [];
readonly List<ExpressionType> types = [];
public ExpressionType PeekType() { return types[^1]; }