Skip to content

Commit

Permalink
Simplify collection initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corniel committed Mar 28, 2024
1 parent 322c87c commit 62ac735
Show file tree
Hide file tree
Showing 14 changed files with 334 additions and 334 deletions.
2 changes: 1 addition & 1 deletion specs/Qowaiv.Specs/Debug_SVO_specs.cs
Expand Up @@ -42,7 +42,7 @@ public void display(Type svoType, object display)
public class Unknown_value : SingleValueObjectSpecs
{
public static IEnumerable<Type> SvosWithDefaultUnknown
=> SvosWithUnknown.Except(new[] { typeof(Sex), typeof(InternetMediaType) });
=> SvosWithUnknown.Except([typeof(Sex), typeof(InternetMediaType)]);

[TestCaseSource(nameof(SvosWithDefaultUnknown))]
public void displays_unknown_for(Type svoType)
Expand Down
2 changes: 1 addition & 1 deletion specs/Qowaiv.Specs/Month_specs.cs
Expand Up @@ -545,7 +545,7 @@ public void with_info()
type: "string",
example: "Jun",
format: "month",
@enum: new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "?" },
@enum: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "?"],
nullable: true));
}

Expand Down
2 changes: 1 addition & 1 deletion specs/Qowaiv.Specs/Sex_specs.cs
Expand Up @@ -439,7 +439,7 @@ public void with_info()
type: "string",
example: "female",
format: "sex",
@enum: new[] { "NotKnown", "Male", "Female", "NotApplicable" },
@enum: ["NotKnown", "Male", "Female", "NotApplicable"],
nullable: true));
}

Expand Down
6 changes: 3 additions & 3 deletions specs/Qowaiv.Specs/TestTools/SingleValueObjectSpecs.cs
Expand Up @@ -30,11 +30,11 @@ public static IEnumerable<Type> SvosWithUnknown
public static IEnumerable<Type> JsonSerializable
=> AllSvos
.Where(IsJsonSerializable)
.Except(new[]
{
.Except(
[
typeof(Secret),
typeof(CryptographicSeed)
});
]);

private static bool IsJsonSerializable(Type type)
=> type
Expand Down
2 changes: 1 addition & 1 deletion specs/Qowaiv.Specs/YesNo_specs.cs
Expand Up @@ -524,7 +524,7 @@ public void with_info()
example: "yes",
type: "string",
format: "yes-no",
@enum: new[] { "yes", "no", "?" },
@enum: ["yes", "no", "?"],
nullable: true));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Qowaiv.Data.SqlClient/Data/SvoParameter.cs
Expand Up @@ -45,7 +45,7 @@ public static SqlParameter CreateForSql(string parameterName, object? value)
else
{
MethodInfo cast = GetCast(sourceType, attr);
var casted = cast.Invoke(null, new[] { value });
var casted = cast.Invoke(null, [value]);
return new SqlParameter(parameterName, casted);
}
}
Expand Down
630 changes: 315 additions & 315 deletions src/Qowaiv/Globalization/CountryToCurrencyMappings.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Qowaiv/Month.cs
Expand Up @@ -53,8 +53,8 @@ namespace Qowaiv;
public static Month December /*..*/ => new(12);

/// <summary>Represents all months (January till December).</summary>
public static IReadOnlyList<Month> All { get; } = new[]
{
public static IReadOnlyList<Month> All { get; } =
[
January,
February,
March,
Expand All @@ -67,7 +67,7 @@ namespace Qowaiv;
October,
November,
December,
};
];
/// <summary>Gets the full name of the month.</summary>
public string FullName => GetFullName(formatProvider: null);
Expand Down
2 changes: 1 addition & 1 deletion src/Qowaiv/OpenApi/OpenApiDataTypes.cs
Expand Up @@ -17,7 +17,7 @@ public static IEnumerable<OpenApiDataType> FromAssemblies(params Assembly[] asse
[ExcludeFromCodeCoverage]
[Pure]
public static IEnumerable<OpenApiDataType> FromTypes(params Type[] types)
=> FromTypes(types?.AsEnumerable() ?? Array.Empty<Type>());
=> FromTypes(types?.AsEnumerable() ?? []);

/// <summary>Gets all <see cref="OpenApiDataTypeAttribute"/>s of the
/// specified types that are decorated as such.
Expand Down
6 changes: 3 additions & 3 deletions src/Qowaiv/Sex.cs
Expand Up @@ -44,13 +44,13 @@ namespace Qowaiv;
public static Sex NotApplicable => new(18);

/// <summary>Contains not known, male, female, not applicable.</summary>
public static IReadOnlyCollection<Sex> All { get; } = new[] { Male, Female, NotApplicable, Unknown, };
public static IReadOnlyCollection<Sex> All { get; } = [Male, Female, NotApplicable, Unknown];

/// <summary>Contains male and female.</summary>
public static IReadOnlyCollection<Sex> MaleAndFemale { get; } = new[] { Male, Female, };
public static IReadOnlyCollection<Sex> MaleAndFemale { get; } = [Male, Female];

/// <summary>Contains male, female, not applicable.</summary>
public static IReadOnlyCollection<Sex> MaleFemaleAndNotApplicable { get; } = new[] { Male, Female, NotApplicable, };
public static IReadOnlyCollection<Sex> MaleFemaleAndNotApplicable { get; } = [Male, Female, NotApplicable];

/// <summary>Gets the display name.</summary>
public string DisplayName => GetDisplayName(null);
Expand Down
2 changes: 1 addition & 1 deletion src/Qowaiv/UuidDefaultComparer.cs
Expand Up @@ -10,7 +10,7 @@ internal sealed class UuidDefaultComparer : UuidComparer
/// 2 <see cref="ushort"/>
/// 8 <see cref="byte"/>.
/// </remarks>
public override IReadOnlyList<int> Priority { get; } = new[] { 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 };
public override IReadOnlyList<int> Priority { get; } = [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15];

/// <inheritdoc/>
[Pure]
Expand Down
2 changes: 1 addition & 1 deletion src/Qowaiv/UuidMongoDbComparer.cs
Expand Up @@ -4,7 +4,7 @@
internal sealed class UuidMongoDbComparer : UuidComparer
{
/// <inheritdoc/>
public override IReadOnlyList<int> Priority { get; } = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
public override IReadOnlyList<int> Priority { get; } = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

/// <inheritdoc/>
[Pure]
Expand Down
2 changes: 1 addition & 1 deletion src/Qowaiv/UuidSqlServerComparer.cs
Expand Up @@ -9,7 +9,7 @@ internal sealed class UuidSqlServerComparer : UuidComparer
/// 10: the most significant byte in Guid ByteArray [for SQL Server ORDERY BY clause]
/// 3: the least significant byte in Guid ByteArray [for SQL Server ORDER BY clause].
/// </remarks>
public override IReadOnlyList<int> Priority { get; } = new[] { 10, 11, 12, 13, 14, 15, 8, 9, 6, 7, 4, 5, 0, 1, 2, 3 };
public override IReadOnlyList<int> Priority { get; } = [10, 11, 12, 13, 14, 15, 8, 9, 6, 7, 4, 5, 0, 1, 2, 3];

/// <inheritdoc/>
[Pure]
Expand Down
2 changes: 1 addition & 1 deletion src/Qowaiv/YesNo.cs
Expand Up @@ -32,7 +32,7 @@ namespace Qowaiv;
public static YesNo Unknown => new(3);

/// <summary>Contains yes and no.</summary>
public static readonly IReadOnlyCollection<YesNo> YesAndNo = new[] { Yes, No };
public static readonly IReadOnlyCollection<YesNo> YesAndNo = [Yes, No];

/// <summary>Returns true if the yes-no value represents no, otherwise false.</summary>
[Pure]
Expand Down

0 comments on commit 62ac735

Please sign in to comment.