Skip to content

Commit

Permalink
Prefer collection expression
Browse files Browse the repository at this point in the history
  • Loading branch information
sjp committed Feb 2, 2024
1 parent 01066e9 commit 2583616
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/SJP.Schematic.Lint/Rules/NoSurrogatePrimaryKeyRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected IEnumerable<IRuleMessage> AnalyseTable(IRelationalDatabaseTable table)
Some: pk =>
{
if (pk.Columns.Count == 1)
return Array.Empty<IRuleMessage>();
return [];

var fkColumns = table.ParentKeys
.Select(fk => fk.ChildKey)
Expand All @@ -62,7 +62,7 @@ protected IEnumerable<IRuleMessage> AnalyseTable(IRelationalDatabaseTable table)

var areAllColumnsFks = pk.Columns.All(c => fkColumns.Contains(c.Name.LocalName));
return areAllColumnsFks
? Array.Empty<IRuleMessage>()
? []
: [BuildMessage(table.Name)];
},
None: Array.Empty<IRuleMessage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private async Task<IReadOnlyCollection<IDatabaseTrigger>> LoadTriggersAsyncCore(
var events = TriggerEvent.None;
var triggerEventPieces = triggerRow.TriggerEvent != null
? triggerRow.TriggerEvent.Split(new[] { " OR " }, StringSplitOptions.RemoveEmptyEntries)
: Array.Empty<string>();
: [];

foreach (var triggerEventPiece in triggerEventPieces)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public DatabaseTestFixtureAttribute(Type target, string propertyName, string ign
IDbConnectionFactory factory;
try
{
var methodResult = getMethod.Invoke(null, Array.Empty<object>());
var methodResult = getMethod.Invoke(null, []);
if (methodResult is not IDbConnectionFactory connFactory)
{
ResultCache.AddOrUpdate(getMethod, false, static (_, __) => false);
Expand Down
2 changes: 1 addition & 1 deletion src/SJP.Schematic.Tests.Utilities/NoneConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override ConstraintResult ApplyTo<TActual>(TActual actual)
throw new ArgumentException($"Expected an Option<T> object, instead received {actualType.FullName}", nameof(actual));

var propGet = actualType.GetProperty(nameof(Option<object>.IsNone))!.GetGetMethod()!;
var isNone = (bool)propGet.Invoke(actual, Array.Empty<object>())!;
var isNone = (bool)propGet.Invoke(actual, [])!;

return new OptionConstraintResult(this, false, isNone);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SJP.Schematic.Tests.Utilities/SomeConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override ConstraintResult ApplyTo<TActual>(TActual actual)
throw new ArgumentException($"Expected an Option<T> object, instead received {actualType.FullName}", nameof(actual));

var propGet = actualType.GetProperty(nameof(Option<object>.IsSome))!.GetGetMethod()!;
var isSome = (bool)propGet.Invoke(actual, Array.Empty<object>())!;
var isSome = (bool)propGet.Invoke(actual, [])!;

return new OptionConstraintResult(this, true, isSome);
}
Expand Down

0 comments on commit 2583616

Please sign in to comment.