Skip to content

Commit

Permalink
Fix to avoid IDE0300
Browse files Browse the repository at this point in the history
  • Loading branch information
y-iihoshi committed Dec 17, 2023
1 parent 861cc6c commit d79e517
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 40 deletions.
14 changes: 4 additions & 10 deletions ThScoreFileConverter.Tests/Models/BitReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public void BitReaderTestUnreadable()
[TestMethod]
public void ReadBitsTestOneBit()
{
#pragma warning disable IDE0230 // Use UTF-8 string literal
using var stream = new MemoryStream(new byte[] { 0b_0101_0011 });
#pragma warning restore IDE0230 // Use UTF-8 string literal
using var stream = new MemoryStream([0b_0101_0011]);

var reader = new BitReader(stream);

Expand All @@ -56,7 +54,7 @@ public void ReadBitsTestOneBit()
[TestMethod]
public void ReadBitsTestZeroBit()
{
using var stream = new MemoryStream(new byte[] { 0xFF });
using var stream = new MemoryStream([0xFF]);
var reader = new BitReader(stream);

Assert.AreEqual(0, reader.ReadBits(0));
Expand Down Expand Up @@ -101,9 +99,7 @@ public void ReadBitsTestMultiBytes()
[TestMethod]
public void ReadBitsTestNegativeNumBits()
{
#pragma warning disable IDE0230 // Use UTF-8 string literal
using var stream = new MemoryStream(new byte[] { 0x53 });
#pragma warning restore IDE0230 // Use UTF-8 string literal
using var stream = new MemoryStream([0x53]);

var reader = new BitReader(stream);

Expand Down Expand Up @@ -133,9 +129,7 @@ public void ReadBitsTestExceededNumBits()
[TestMethod]
public void ReadBitsTestEndOfStream()
{
#pragma warning disable IDE0230 // Use UTF-8 string literal
using var stream = new MemoryStream(new byte[] { 0x53 });
#pragma warning restore IDE0230 // Use UTF-8 string literal
using var stream = new MemoryStream([0x53]);

var reader = new BitReader(stream);

Expand Down
6 changes: 3 additions & 3 deletions ThScoreFileConverter.Tests/Models/LzssTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class LzssTests
// f <--- offset ---> len>
// 0 0_0000_0000_0001 0000
// 0 0_0000_0000_0000
private readonly byte[] compressed = new byte[]
{
private readonly byte[] compressed =
[
0b_1010_0000,
0b_1101_1000,
0b_1010_1100,
Expand All @@ -27,7 +27,7 @@ public class LzssTests
0b_1000_0000,
0b_0000_0000,
0b_0000_0000,
};
];

[TestMethod]
public void CompressTest()
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter.Tests/Models/Th06/ChapterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal struct Properties
signature = "ABCD",
size1 = 12,
size2 = 34,
data = new byte[] { 0x56, 0x78, 0x9A, 0xBC },
data = [0x56, 0x78, 0x9A, 0xBC],
};

internal static byte[] MakeByteArray(in Properties properties)
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter.Tests/Models/Th06/HeaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal struct Properties
signature = "TH6K",
size1 = 12,
size2 = 12,
data = new byte[] { 0x10, 0x00, 0x00, 0x00 },
data = [0x10, 0x00, 0x00, 0x00],
};

internal static byte[] MakeByteArray(in Properties properties)
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter.Tests/Models/Th07/HeaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal struct Properties
signature = "TH7K",
size1 = 12,
size2 = 12,
data = new byte[] { 0x10, 0x00, 0x00, 0x00 },
data = [0x10, 0x00, 0x00, 0x00],
};

internal static byte[] MakeByteArray(in Properties properties)
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter.Tests/Models/Th075/StatusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Properties(in Properties properties)

internal static Properties ValidProperties { get; } = new Properties()
{
encodedLastName = new byte[] { 15, 37, 26, 50, 30, 43, 53, 103 },
encodedLastName = [15, 37, 26, 50, 30, 43, 53, 103],
decodedLastName = "Player1 ",
arcadeScores = EnumHelper.Cartesian<CharaWithReserved, CharaWithReserved>()
.ToDictionary(pair => pair, pair => ((int)pair.First * 100) + (int)pair.Second),
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter.Tests/Models/Th08/HeaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal struct Properties
signature = "TH8K",
size1 = 12,
size2 = 12,
data = new byte[] { 0x10, 0x00, 0x00, 0x00 },
data = [0x10, 0x00, 0x00, 0x00],
};

internal static byte[] MakeByteArray(in Properties properties)
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter.Tests/Models/Th09/HeaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal struct Properties
signature = "TH9K",
size1 = 12,
size2 = 12,
data = new byte[] { 0x10, 0x00, 0x00, 0x00 },
data = [0x10, 0x00, 0x00, 0x00],
};

internal static byte[] MakeByteArray(in Properties properties)
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter.Tests/Models/Th095/ChapterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal struct Properties
version = 1234,
size = 16,
checksum = 0xC16CBAA7u,
data = new byte[] { 0x56, 0x78, 0x9A, 0xBC },
data = [0x56, 0x78, 0x9A, 0xBC],
};

internal static byte[] MakeByteArray(in Properties properties)
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter.Tests/Models/Th10/ChapterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal struct Properties
version = 1234,
checksum = 0xE0u,
size = 16,
data = new byte[] { 0x01, 0x23, 0x45, 0x67 },
data = [0x01, 0x23, 0x45, 0x67],
};

internal static byte[] MakeByteArray(in Properties properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ThScoreFileConverter.Tests.Models.Th175;
[TestClass]
public class AllScoreDataTests
{
private static readonly byte[] NullChar = new byte[] { 0 };
private static readonly byte[] NullChar = [0];
private static readonly BindingFlags BindingAttribute = BindingFlags.NonPublic | BindingFlags.Static;
private static readonly MethodInfo FromArrayMethodInfo =
typeof(AllScoreDataTests).GetMethod(nameof(MakeByteArrayFromArray), BindingAttribute)!;
Expand Down
17 changes: 3 additions & 14 deletions ThScoreFileConverter.Tests/Models/ThCryptTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,9 @@ namespace ThScoreFileConverter.Tests.Models;
[TestClass]
public class ThCryptTests
{
private readonly byte[] decrypted = new byte[]
{
0x01, 0x04, 0x09, 0x10, 0x19, 0x24, 0x31, 0x40,
};

private readonly byte[] encryptedBySmallBlock = new byte[]
{
0x02, 0x42, 0x73, 0xAF, 0xA2, 0x32, 0x7B, 0x67,
};

private readonly byte[] encryptedByLargeBlock = new byte[]
{
0x52, 0x62, 0x6A, 0xAA, 0xD3, 0x0F, 0x43, 0x7F,
};
private readonly byte[] decrypted = [0x01, 0x04, 0x09, 0x10, 0x19, 0x24, 0x31, 0x40];
private readonly byte[] encryptedBySmallBlock = [0x02, 0x42, 0x73, 0xAF, 0xA2, 0x32, 0x7B, 0x67];
private readonly byte[] encryptedByLargeBlock = [0x52, 0x62, 0x6A, 0xAA, 0xD3, 0x0F, 0x43, 0x7F];

private const int KEY = 0x12;
private const int STEP = 0x34;
Expand Down
6 changes: 3 additions & 3 deletions ThScoreFileConverter/Models/Th125/ShotExReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ private static Detail[] MakeDetailList(IBestShotHeader header, INumberFormatter
{
Func<int, string> str = formatter.FormatNumber;

return new Detail[]
{
return
[
new(true, "Base Point {0,9}", str(header.BasePoint)),
new(header.Fields.ClearShot, "Clear Shot! {0,9}", StringHelper.Create($"+ {header.ClearShot}")),
new(header.Fields.SoloShot, "Solo Shot {0,9}", "+ 100"),
Expand All @@ -111,7 +111,7 @@ private static Detail[] MakeDetailList(IBestShotHeader header, INumberFormatter
new(true, "Angle Bonus {0,9}", StringHelper.Create($"* {header.AngleBonus:F2}")),
new(true, string.Empty, string.Empty),
new(true, "Result Score {0,9}", str(header.ResultScore)),
};
];
}

private sealed class Detail
Expand Down
2 changes: 1 addition & 1 deletion ThScoreFileConverter/Models/Th165/HashtagFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static HashtagFields()

public HashtagFields(int data1, int data2, int data3)
{
this.data = new[] { new BitVector32(data1), new BitVector32(data2), new BitVector32(data3) };
this.data = [new BitVector32(data1), new BitVector32(data2), new BitVector32(data3)];

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Release, net6.0-windows) / build

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Release, net48) / build

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Release, net8.0-windows) / build

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Debug, net8.0-windows) / build

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Debug, net8.0-windows) / build

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Debug, net48) / build

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Debug, net48) / build

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Debug, net6.0-windows) / build

Check warning on line 36 in ThScoreFileConverter/Models/Th165/HashtagFields.cs

View workflow job for this annotation

GitHub Actions / build (Debug, net6.0-windows) / build

}

public IEnumerable<int> Data => this.data?.Select(vector => vector.Data) ?? Enumerable.Empty<int>();
Expand Down

0 comments on commit d79e517

Please sign in to comment.