mirror of
https://github.com/Pathoschild/SMAPI.git
synced 2026-10-12 02:08:51 +00:00
prefer empty collection expression
This commit is contained in:
@@ -45,7 +45,7 @@ public struct DiagnosticResult
|
||||
{
|
||||
if (this.locations == null)
|
||||
{
|
||||
this.locations = new DiagnosticResultLocation[] { };
|
||||
this.locations = [];
|
||||
}
|
||||
return this.locations;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public abstract partial class DiagnosticVerifier
|
||||
var diagnostics = new List<Diagnostic>();
|
||||
foreach (Project project in projects)
|
||||
{
|
||||
CompilationWithAnalyzers compilationWithAnalyzers = project.GetCompilationAsync().Result!.WithAnalyzers(ImmutableArray.Create(analyzer));
|
||||
CompilationWithAnalyzers compilationWithAnalyzers = project.GetCompilationAsync().Result!.WithAnalyzers([analyzer]);
|
||||
var diags = compilationWithAnalyzers.GetAnalyzerDiagnosticsAsync().Result;
|
||||
foreach (Diagnostic diag in diags)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract partial class DiagnosticVerifier
|
||||
/// <param name="expected"> DiagnosticResults that should appear after the analyzer is run on the source</param>
|
||||
protected void VerifyCSharpDiagnostic(string source, params DiagnosticResult[] expected)
|
||||
{
|
||||
this.VerifyDiagnostics(new[] { source }, LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzer(), expected);
|
||||
this.VerifyDiagnostics([source], LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzer(), expected);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -263,7 +263,7 @@ public class ModResolverTests
|
||||
public void ProcessDependencies_NoMods_DoesNothing()
|
||||
{
|
||||
// act
|
||||
IModMetadata[] mods = new ModResolver().ProcessDependencies(Array.Empty<IModMetadata>(), new ModDatabase()).ToArray();
|
||||
IModMetadata[] mods = new ModResolver().ProcessDependencies([], new ModDatabase()).ToArray();
|
||||
|
||||
// assert
|
||||
mods.Should().BeEmpty("it should match number of mods input");
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ModDatabase
|
||||
*********/
|
||||
/// <summary>Construct an empty instance.</summary>
|
||||
public ModDatabase()
|
||||
: this(Array.Empty<ModDataRecord>(), _ => null) { }
|
||||
: this([], _ => null) { }
|
||||
|
||||
/// <summary>Construct an instance.</summary>
|
||||
/// <param name="records">The underlying mod data records indexed by default display name.</param>
|
||||
|
||||
@@ -86,7 +86,7 @@ internal class ModsApiController : Controller
|
||||
metrics.TrackRequest(model?.ApiVersion, model?.GameVersion, model?.Platform);
|
||||
|
||||
if (model?.Mods == null)
|
||||
return Array.Empty<ModEntryModel>();
|
||||
return [];
|
||||
|
||||
ModUpdateCheckConfig config = this.Config.Value;
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ internal class MultiplayerPeer : IMultiplayerPeer
|
||||
this.Mods = model.Mods.Select(mod => new MultiplayerPeerMod(mod)).ToArray();
|
||||
}
|
||||
else
|
||||
this.Mods = Array.Empty<IMultiplayerPeerMod>();
|
||||
this.Mods = [];
|
||||
|
||||
this.SendMessageImpl = sendMessage;
|
||||
}
|
||||
|
||||
@@ -1627,7 +1627,7 @@ internal class SCore : IDisposable
|
||||
{
|
||||
using RegistryKey? key = Registry.LocalMachine.OpenSubKey(registryKey);
|
||||
if (key == null)
|
||||
return Array.Empty<string>();
|
||||
return [];
|
||||
|
||||
return key
|
||||
.GetSubKeyNames()
|
||||
|
||||
@@ -20,10 +20,10 @@ internal class ImmutableCollectionWatcher<TValue> : BaseDisposableWatcher, IColl
|
||||
public bool IsChanged { get; } = false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<TValue> Added { get; } = Array.Empty<TValue>();
|
||||
public IEnumerable<TValue> Added { get; } = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<TValue> Removed { get; } = Array.Empty<TValue>();
|
||||
public IEnumerable<TValue> Removed { get; } = [];
|
||||
|
||||
|
||||
/*********
|
||||
|
||||
@@ -89,7 +89,7 @@ internal class LocationTracker : IWatcher
|
||||
this.FurnitureWatcher
|
||||
]);
|
||||
|
||||
this.UpdateChestWatcherList(added: location.Objects.Pairs, removed: Array.Empty<KeyValuePair<Vector2, SObject>>());
|
||||
this.UpdateChestWatcherList(added: location.Objects.Pairs, removed: []);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user