diff --git a/MatroskaLib/MatroskaLib.Test/ByteHelperTest.cs b/MatroskaLib/MatroskaLib.Test/ByteHelperTest.cs index ca7b327..5d33723 100644 --- a/MatroskaLib/MatroskaLib.Test/ByteHelperTest.cs +++ b/MatroskaLib/MatroskaLib.Test/ByteHelperTest.cs @@ -6,9 +6,9 @@ namespace MatroskaLib.Test; public class ByteHelperTest { public static TheoryData> TestData1 = new() { - { 2UL, new () { 0x2 } }, - { 909UL, new () { 0x3, 0x8D } }, - { 1_800_70UL, new () { 0x2, 0xBF, 0x66 } }, + { 2UL, [0x2] }, + { 909UL, [0x3, 0x8D] }, + { 1_800_70UL, [0x2, 0xBF, 0x66] }, }; [Theory, MemberData(nameof(TestData1))] public void ToBytesTest(ulong value, List lsBytesExpected) @@ -19,10 +19,10 @@ public void ToBytesTest(ulong value, List lsBytesExpected) } public static TheoryData, List> TestData2 = new() { - { new() {0x0, 0x0, 0x0, 0x96}, new () { 0x96 } }, - { new() {0x0, 0x0, 0x5, 0x0, 0x9}, new () { 0x5, 0x0, 0x9 } }, - { new() {0x9}, new () { 0x9 } }, - { new() {}, new () { } } + { [0x0, 0x0, 0x0, 0x96], [0x96] }, + { [0x0, 0x0, 0x5, 0x0, 0x9], [0x5, 0x0, 0x9] }, + { [0x9], [0x9] }, + { [], [] } }; [Theory, MemberData(nameof(TestData2))] public void RemoveLeftZeroesTest(List lsBytes, List lsBytesExpected) @@ -34,34 +34,34 @@ public void RemoveLeftZeroesTest(List lsBytes, List lsBytesExpected) public static IEnumerable Data() { - yield return new object[] - { + yield return + [ new List{ 0x6B, 0x2D, 0xAE, 0xBB, 0xD7, 0x81, 0x02 }, new List{ 0x6B, 0x2D, 0xAE, 0xBE, 0xD7, 0x81, 0x02 }, 4, 3 - }; - yield return new object[] - { + ]; + yield return + [ new List{ 0x81, 0x02, 0xAE, 0x42, 0x83, 0xD7, 0x81, 0x03 }, new List{ 0x81, 0x02, 0xAE, 0x42, 0x87, 0xD7, 0x81, 0x03 }, 5, 4 - }; - yield return new object[] - { + ]; + yield return + [ new List{ 0x81, 0x02, 0xAE, 0x42, 0x83, 0xD7, 0x81, 0x03 }, new List{ 0x81, 0x02, 0xAE, 0x42, 0x87, 0xD7, 0x81, 0x03 }, 5, 4 - }; - yield return new object[] - { + ]; + yield return + [ new List{ 0x00, 0x00, 0xAE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0, 0x3A, 0xD7, 81 }, new List{ 0x00, 0x00, 0xAE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0, 0x3D, 0xD7, 81 }, 11, 3 - }; + ]; } [Theory, MemberData(nameof(Data))] diff --git a/MatroskaLib/MatroskaLib.Test/Helpers/MkvValidator.cs b/MatroskaLib/MatroskaLib.Test/Helpers/MkvValidator.cs index 7e84dc7..d462c1b 100644 --- a/MatroskaLib/MatroskaLib.Test/Helpers/MkvValidator.cs +++ b/MatroskaLib/MatroskaLib.Test/Helpers/MkvValidator.cs @@ -11,6 +11,7 @@ public static class MkvValidator private const string OutputRemoveRegex = @"(^At least one output file must be specified)|(^\[(.*)\] )"; public static void Validate(string filePath) { + // Validate with ffmpeg Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardError = true; @@ -26,6 +27,7 @@ public static void Validate(string filePath) throw new Exception("ffmpeg's mkv validation produced errors:" + Environment.NewLine + output); } + // Validate with mkvalidator p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardError = true; diff --git a/MatroskaLib/MatroskaLib.Test/MatroskaLibTest.cs b/MatroskaLib/MatroskaLib.Test/MatroskaLibTest.cs index 5ac6e75..f39665c 100644 --- a/MatroskaLib/MatroskaLib.Test/MatroskaLibTest.cs +++ b/MatroskaLib/MatroskaLib.Test/MatroskaLibTest.cs @@ -25,7 +25,7 @@ public class MatroskaLibTest [InlineData("mkv files/TestFile1_MkvToolNix.mkv")] public void ReadTestFile1(string file) { - string[] filePaths = { file }; + string[] filePaths = [file]; List lsMkvFiles = MatroskaReader.ReadMkvFiles(filePaths); List lsTracks = lsMkvFiles[0].tracks; @@ -43,12 +43,12 @@ public void ReadTestFile1(string file) public void WriteTestFile1(string file) { File.Copy(file, TestFilePath, true); - List lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + List lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); lsMkvFiles[0].tracks[0].flagDefault = false; lsMkvFiles[0].tracks[2].flagDefault = false; MatroskaWriter.WriteMkvFile(lsMkvFiles[0]); - lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); List lsTracks = lsMkvFiles[0].tracks; lsTracks.Should().HaveCount(3); @@ -62,7 +62,7 @@ public void WriteTestFile1(string file) [InlineData("mkv files/TestFile2_MkvToolNix.mkv")] public void ReadTestFile2(string file) { - string[] filePaths = { file }; + string[] filePaths = [file]; List lsMkvFiles = MatroskaReader.ReadMkvFiles(filePaths); List lsTracks = lsMkvFiles[0].tracks; @@ -82,12 +82,12 @@ public void ReadTestFile2(string file) public void WriteTestFile2(string file) { File.Copy(file, TestFilePath, true); - List lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + List lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); lsMkvFiles[0].tracks[1].flagDefault = true; lsMkvFiles[0].tracks[3].flagDefault = true; MatroskaWriter.WriteMkvFile(lsMkvFiles[0]); - lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); List lsTracks = lsMkvFiles[0].tracks; lsTracks.Should().HaveCount(5); @@ -103,7 +103,7 @@ public void WriteTestFile2(string file) [InlineData("mkv files/TestFile3_HandBrake.mkv")] public void ReadTestFile3(string file) { - string[] filePaths = { file }; + string[] filePaths = [file]; List lsMkvFiles = MatroskaReader.ReadMkvFiles(filePaths); List lsTracks = lsMkvFiles[0].tracks; @@ -122,12 +122,12 @@ public void ReadTestFile3(string file) public void WriteTestFile3(string file) { File.Copy(file, TestFilePath, true); - List lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + List lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); lsMkvFiles[0].tracks[1].flagDefault = true; lsMkvFiles[0].tracks[3].flagDefault = true; MatroskaWriter.WriteMkvFile(lsMkvFiles[0]); - lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); List lsTracks = lsMkvFiles[0].tracks; lsTracks.Should().HaveCount(4); @@ -143,7 +143,7 @@ public void WriteTestFile3(string file) [InlineData("mkv files/TestFile5_MkvProEdit.mkv")] public void ReadTestFile4(string file) { - string[] filePaths = { file }; + string[] filePaths = [file]; List lsMkvFiles = MatroskaReader.ReadMkvFiles(filePaths); List lsTracks = lsMkvFiles[0].tracks; @@ -161,12 +161,12 @@ public void ReadTestFile4(string file) public void WriteTestFile4(string file) { File.Copy(file, TestFilePath, true); - List lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + List lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); lsMkvFiles[0].tracks[0].flagDefault = false; lsMkvFiles[0].tracks[2].flagDefault = false; MatroskaWriter.WriteMkvFile(lsMkvFiles[0]); - lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); List lsTracks = lsMkvFiles[0].tracks; lsTracks.Should().HaveCount(3); @@ -180,7 +180,7 @@ public void WriteTestFile4(string file) public void FileWithSeekHeadSizeOf2ShouldNotThrow() { File.Copy("mkv files/TestFile6_SmallSeekHead.mkv", TestFilePath, true); - List lsMkvFiles = MatroskaReader.ReadMkvFiles(new[] { TestFilePath }); + List lsMkvFiles = MatroskaReader.ReadMkvFiles([TestFilePath]); lsMkvFiles[0].tracks[0].flagDefault = false; MatroskaWriter.WriteMkvFile(lsMkvFiles[0]); diff --git a/MatroskaLib/MatroskaLib/Types/MkvFile.cs b/MatroskaLib/MatroskaLib/Types/MkvFile.cs index 99e1ae6..4e83feb 100644 --- a/MatroskaLib/MatroskaLib/Types/MkvFile.cs +++ b/MatroskaLib/MatroskaLib/Types/MkvFile.cs @@ -29,11 +29,11 @@ public record MkvFile var trackOther = other.tracks.ElementAtOrDefault(i); if (trackOther is null) - return $"Track at index {i} does not exist, expected {track.type}{track.language}."; + return $"Track at index {i} does not exist, expected {track.type} with language {track.language}."; if (track.number != trackOther.number) - return $"Track number {i} does not match. Expected {track.number}, got {trackOther.number}."; + return $"Track number at index {i} does not match. Expected {track.number}, got {trackOther.number}."; if (track.language != trackOther.language) - return $"Track language {i} does not match. Expected {track.language}, got {trackOther.language}."; + return $"Track language at index {i} does not match. Expected {track.language}, got {trackOther.language}."; } return null; diff --git a/MkvReadCrawler/MkvReadCrawler.csproj b/MkvReadCrawler/MkvReadCrawler.csproj index 78a6861..e9a5c6a 100644 --- a/MkvReadCrawler/MkvReadCrawler.csproj +++ b/MkvReadCrawler/MkvReadCrawler.csproj @@ -1,8 +1,8 @@ - Exe net8.0 + Exe