Skip to content

Commit

Permalink
use newer collection initializer syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ssg committed Sep 12, 2024
1 parent 0453a88 commit 2a3187c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ dotnet_diagnostic.SA1101.severity = none
# SA1300: Element should begin with upper-case letter
dotnet_diagnostic.SA1300.severity = silent
dotnet_diagnostic.SA1311.severity = silent
csharp_style_prefer_primary_constructors = true:suggestion

[*.vb]
#### Naming styles ####
Expand Down Expand Up @@ -188,3 +189,4 @@ dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
10 changes: 4 additions & 6 deletions src/Base32Alphabet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,23 @@ public class Base32Alphabet : CodingAlphabet
private static readonly Lazy<AliasedBase32Alphabet> crockfordAlphabet = new
(() => new AliasedBase32Alphabet(
"0123456789ABCDEFGHJKMNPQRSTVWXYZ",
new CharMap[]
{
[
new('O', '0'),
new('I', '1'),
new('L', '1'),
}));
]));

private static readonly Lazy<AliasedBase32Alphabet> base32HAlphabet = new(
() => new AliasedBase32Alphabet(
"0123456789ABCDEFGHJKLMNPQRTVWXYZ",
paddingChar: '0',
PaddingPosition.Start,
new CharMap[]
{
[
new('O', '0'),
new('I', '1'),
new('S', '5'),
new('U', 'V'),
}));
]));

/// <summary>
/// Initializes a new instance of the <see cref="Base32Alphabet"/> class.
Expand Down
2 changes: 1 addition & 1 deletion test/Base16/Base16Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void GetSafeByteCountForDecoding_InvalidBufferSize_ReturnsZero(Base16 enc
public void CustomCtor()
{
var encoder = new Base16(new Base16Alphabet("abcdefghijklmnop"));
var result = encoder.Encode(new byte[] { 0, 1, 16, 128, 255 });
var result = encoder.Encode([0, 1, 16, 128, 255]);
Assert.That(result, Is.EqualTo("aaabbaiapp"));
}

Expand Down
2 changes: 1 addition & 1 deletion test/Base32/CrockfordTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void TryDecode_ReturnsExpectedValues(string expectedOutput, string input,
[Test]
public void TryDecode_ZeroBuffer_ReturnsFalse()
{
var success = Base32.Crockford.TryDecode("test", Array.Empty<byte>(), out int numBytesWritten);
var success = Base32.Crockford.TryDecode("test", [], out int numBytesWritten);
Assert.That(success, Is.False);
Assert.That(numBytesWritten, Is.EqualTo(0));
}
Expand Down
2 changes: 1 addition & 1 deletion test/Base32/Rfc4648Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ public string Encode_long_ReturnsExpectedValues(long number)
[Test]
public void Encode_long_NegativeValues_Throws()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Base32.Rfc4648.Encode(-1));
_ = Assert.Throws<ArgumentOutOfRangeException>(() => Base32.Rfc4648.Encode(-1));
}
}
2 changes: 1 addition & 1 deletion test/Base58/BitcoinTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void TryEncode_Bitcoin_ReturnsExpectedResults(string input, string expect
[Test]
public void Encode_EmptyBuffer_ReturnsEmptyString()
{
Assert.That(Base58.Bitcoin.Encode(Array.Empty<byte>()), Is.EqualTo(String.Empty));
Assert.That(Base58.Bitcoin.Encode([]), Is.EqualTo(String.Empty));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion test/Base58/FlickrTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void TryEncode_Flickr_ReturnsExpectedResults(string input, string expecte
[Test]
public void Encode_EmptyBuffer_ReturnsEmptyString()
{
Assert.That(Base58.Flickr.Encode(Array.Empty<byte>()), Is.EqualTo(String.Empty));
Assert.That(Base58.Flickr.Encode([]), Is.EqualTo(String.Empty));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion test/Base58/RippleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void TryEncode_Ripple_ReturnsExpectedResults(string input, string expecte
[Test]
public void Encode_EmptyBuffer_ReturnsEmptyString()
{
Assert.That(Base58.Ripple.Encode(Array.Empty<byte>()), Is.EqualTo(String.Empty));
Assert.That(Base58.Ripple.Encode([]), Is.EqualTo(String.Empty));
}

[Test]
Expand Down
6 changes: 6 additions & 0 deletions test/SimpleBase.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;IDE0130</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>1701;1702;IDE0130</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\src\SimpleBase.csproj" />
</ItemGroup>
Expand Down

0 comments on commit 2a3187c

Please sign in to comment.