diff --git a/BililiveRecorder.Cli/Configure/ConfigureCommand.cs b/BililiveRecorder.Cli/Configure/ConfigureCommand.cs index f7ccdbd..571c98d 100644 --- a/BililiveRecorder.Cli/Configure/ConfigureCommand.cs +++ b/BililiveRecorder.Cli/Configure/ConfigureCommand.cs @@ -147,7 +147,7 @@ namespace BililiveRecorder.Cli.Configure table.AddRow(room.RoomId.ToString(), room.AutoRecord ? "[green]Enabled[/]" : "[red]Disabled[/]"); } - AnsiConsole.Render(table); + AnsiConsole.Write(table); } private static void AddRoom(ConfigV3 config) diff --git a/BililiveRecorder.Core/Config/V3/Config.gen.cs b/BililiveRecorder.Core/Config/V3/Config.gen.cs index 83fb4c9..1a7d4f3 100644 --- a/BililiveRecorder.Core/Config/V3/Config.gen.cs +++ b/BililiveRecorder.Core/Config/V3/Config.gen.cs @@ -179,7 +179,7 @@ namespace BililiveRecorder.Core.Config.V3 /// /// 自定义脚本 /// - public string UserScript => this.GetPropertyValue(); + public string? UserScript => this.GetPropertyValue(); } @@ -381,10 +381,10 @@ namespace BililiveRecorder.Core.Config.V3 /// /// 自定义脚本 /// - public string UserScript { get => this.GetPropertyValue(); set => this.SetPropertyValue(value); } + public string? UserScript { get => this.GetPropertyValue(); set => this.SetPropertyValue(value); } public bool HasUserScript { get => this.GetPropertyHasValue(nameof(this.UserScript)); set => this.SetPropertyHasValue(value, nameof(this.UserScript)); } [JsonProperty(nameof(UserScript)), EditorBrowsable(EditorBrowsableState.Never)] - public Optional OptionalUserScript { get => this.GetPropertyValueOptional(nameof(this.UserScript)); set => this.SetPropertyValueOptional(value, nameof(this.UserScript)); } + public Optional OptionalUserScript { get => this.GetPropertyValueOptional(nameof(this.UserScript)); set => this.SetPropertyValueOptional(value, nameof(this.UserScript)); } } diff --git a/BililiveRecorder.Core/Recorder.cs b/BililiveRecorder.Core/Recorder.cs index 13032c0..4fe2179 100644 --- a/BililiveRecorder.Core/Recorder.cs +++ b/BililiveRecorder.Core/Recorder.cs @@ -52,7 +52,9 @@ namespace BililiveRecorder.Core public event EventHandler>? RecordFileClosed; public event EventHandler>? IOStats; public event EventHandler>? RecordingStats; +#pragma warning disable CS0067 // The event 'Recorder.PropertyChanged' is never used public event PropertyChangedEventHandler? PropertyChanged; +#pragma warning restore CS0067 // The event 'Recorder.PropertyChanged' is never used public ConfigV3 Config { get; } diff --git a/BililiveRecorder.Core/Recording/RawDataRecordTask.cs b/BililiveRecorder.Core/Recording/RawDataRecordTask.cs index f40e4be..8d31bcc 100644 --- a/BililiveRecorder.Core/Recording/RawDataRecordTask.cs +++ b/BililiveRecorder.Core/Recording/RawDataRecordTask.cs @@ -97,7 +97,7 @@ namespace BililiveRecorder.Core.Recording this.timer.Stop(); this.RequestStop(); - RecordFileClosedEventArgs recordFileClosedEvent; + RecordFileClosedEventArgs? recordFileClosedEvent; if (this.fileOpeningEventArgs is { } openingEventArgs) recordFileClosedEvent = new RecordFileClosedEventArgs(this.room) { diff --git a/BililiveRecorder.Core/Scripting/Runtime/JintFetchSync.cs b/BililiveRecorder.Core/Scripting/Runtime/JintFetchSync.cs index 518678a..728bc51 100644 --- a/BililiveRecorder.Core/Scripting/Runtime/JintFetchSync.cs +++ b/BililiveRecorder.Core/Scripting/Runtime/JintFetchSync.cs @@ -31,10 +31,10 @@ namespace BililiveRecorder.Core.Scripting.Runtime ? throw new JavaScriptException(this._engine.Realm.Intrinsics.Error, "The provided value is not of type 'RequestInit'.") : arg1; - HttpClientHandler handler = new HttpClientHandler(); - HttpClient? httpClient = new HttpClient(handler); + var handler = new HttpClientHandler(); + var httpClient = new HttpClient(handler); var requestMessage = new HttpRequestMessage(HttpMethod.Get, urlString.ToString()); - bool throwOnRedirect = false; + var throwOnRedirect = false; if (initObject is not null) { @@ -101,7 +101,6 @@ namespace BililiveRecorder.Core.Scripting.Runtime } #pragma warning disable VSTHRD002 // Avoid problematic synchronous waits -#pragma warning disable VSTHRD104 // Offer async methods var resp = httpClient.SendAsync(requestMessage).Result; if (throwOnRedirect && (resp.StatusCode is (HttpStatusCode)301 or (HttpStatusCode)302 or (HttpStatusCode)303 or (HttpStatusCode)307 or (HttpStatusCode)308)) @@ -110,7 +109,6 @@ namespace BililiveRecorder.Core.Scripting.Runtime } var respString = resp.Content.ReadAsStringAsync().Result; -#pragma warning restore VSTHRD104 // Offer async methods #pragma warning restore VSTHRD002 // Avoid problematic synchronous waits var respHeaders = new ObjectInstance(this._engine); diff --git a/BililiveRecorder.Core/Scripting/UserScriptRunner.cs b/BililiveRecorder.Core/Scripting/UserScriptRunner.cs index 9436855..5b1bc1a 100644 --- a/BililiveRecorder.Core/Scripting/UserScriptRunner.cs +++ b/BililiveRecorder.Core/Scripting/UserScriptRunner.cs @@ -73,7 +73,7 @@ globalThis.recorderEvents = {}; return null; } - var parser = new JavaScriptParser(source, new ParserOptions("userscript.js")); + var parser = new JavaScriptParser(source!, new ParserOptions("userscript.js")); var script = parser.ParseScript(); this.cachedScript = script; diff --git a/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeResponse.cs b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeResponse.cs index 10c7106..a6b7fcb 100644 --- a/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeResponse.cs +++ b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeResponse.cs @@ -25,13 +25,13 @@ namespace BililiveRecorder.ToolBox.Tool.Analyze public void PrintToConsole() { if (this.NeedFix) - AnsiConsole.Render(new FigletText("Need Fix").Color(Color.Red)); + AnsiConsole.Write(new FigletText("Need Fix").Color(Color.Red)); else - AnsiConsole.Render(new FigletText("All Good").Color(Color.Green)); + AnsiConsole.Write(new FigletText("All Good").Color(Color.Green)); if (this.Unrepairable) { - AnsiConsole.Render(new Panel("This file contains error(s) that are identified as unrepairable (yet).\n" + + AnsiConsole.Write(new Panel("This file contains error(s) that are identified as unrepairable (yet).\n" + "Please check if you're using the newest version.\n" + "Please consider send a sample file to the developer.") { @@ -41,7 +41,7 @@ namespace BililiveRecorder.ToolBox.Tool.Analyze }); } - AnsiConsole.Render(new Panel(this.InputPath.EscapeMarkup()) + AnsiConsole.Write(new Panel(this.InputPath.EscapeMarkup()) { Header = new PanelHeader("Input"), Border = BoxBorder.Rounded @@ -49,7 +49,7 @@ namespace BililiveRecorder.ToolBox.Tool.Analyze AnsiConsole.MarkupLine("Will output [lime]{0}[/] file(s) if repaired", this.OutputFileCount); - AnsiConsole.Render(new Table() + AnsiConsole.Write(new Table() .Border(TableBorder.Rounded) .AddColumns("Category", "Count") .AddRow("Unrepairable", this.IssueTypeUnrepairable.ToString()) diff --git a/BililiveRecorder.ToolBox/Tool/DanmakuMerger/DanmakuMergerHandler.cs b/BililiveRecorder.ToolBox/Tool/DanmakuMerger/DanmakuMergerHandler.cs index aa718a7..8cfa25b 100644 --- a/BililiveRecorder.ToolBox/Tool/DanmakuMerger/DanmakuMergerHandler.cs +++ b/BililiveRecorder.ToolBox/Tool/DanmakuMerger/DanmakuMergerHandler.cs @@ -16,7 +16,9 @@ namespace BililiveRecorder.ToolBox.Tool.DanmakuMerger public string Name => "Merge Danmaku"; +#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task> Handle(DanmakuMergerRequest request, CancellationToken cancellationToken, ProgressCallback? progress) +#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { var inputLength = request.Inputs.Length; @@ -90,16 +92,16 @@ namespace BililiveRecorder.ToolBox.Tool.DanmakuMerger { // 使用传递进来的参数作为时间差 timeDiff = request.Offsets.Select(x => TimeSpan.FromSeconds(x)).ToArray(); - var b = startTimes[Array.IndexOf(timeDiff, timeDiff.Min())]; - recordInfo = b.element; - baseTime = b.time; + var (time, element) = startTimes[Array.IndexOf(timeDiff, timeDiff.Min())]; + recordInfo = element; + baseTime = time; } else { // 使用文件内的开始时间作为时间差 - var b = startTimes.OrderBy(x => x.time).First(); - recordInfo = b.element; - baseTime = b.time; + var (time, element) = startTimes.OrderBy(x => x.time).First(); + recordInfo = element; + baseTime = time; timeDiff = startTimes.Select(x => x.time - baseTime).ToArray(); } } diff --git a/BililiveRecorder.ToolBox/Tool/DanmakuStartTime/DanmakuStartTimeHandler.cs b/BililiveRecorder.ToolBox/Tool/DanmakuStartTime/DanmakuStartTimeHandler.cs index 6f2110b..c4598b6 100644 --- a/BililiveRecorder.ToolBox/Tool/DanmakuStartTime/DanmakuStartTimeHandler.cs +++ b/BililiveRecorder.ToolBox/Tool/DanmakuStartTime/DanmakuStartTimeHandler.cs @@ -12,7 +12,9 @@ namespace BililiveRecorder.ToolBox.Tool.DanmakuStartTime { public string Name => "Read Danmaku start_time"; +#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task> Handle(DanmakuStartTimeRequest request, CancellationToken cancellationToken, ProgressCallback? progress) +#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { List result = new(); diff --git a/BililiveRecorder.ToolBox/Tool/DanmakuStartTime/DanmakuStartTimeResponse.cs b/BililiveRecorder.ToolBox/Tool/DanmakuStartTime/DanmakuStartTimeResponse.cs index de1a72a..e810cae 100644 --- a/BililiveRecorder.ToolBox/Tool/DanmakuStartTime/DanmakuStartTimeResponse.cs +++ b/BililiveRecorder.ToolBox/Tool/DanmakuStartTime/DanmakuStartTimeResponse.cs @@ -18,7 +18,7 @@ namespace BililiveRecorder.ToolBox.Tool.DanmakuStartTime t.AddRow(item.StartTime.ToString().EscapeMarkup(), item.Path.EscapeMarkup()); } - AnsiConsole.Render(t); + AnsiConsole.Write(t); } public class DanmakuStartTime diff --git a/BililiveRecorder.ToolBox/Tool/Fix/FixResponse.cs b/BililiveRecorder.ToolBox/Tool/Fix/FixResponse.cs index 66f6e1d..69e339a 100644 --- a/BililiveRecorder.ToolBox/Tool/Fix/FixResponse.cs +++ b/BililiveRecorder.ToolBox/Tool/Fix/FixResponse.cs @@ -27,11 +27,11 @@ namespace BililiveRecorder.ToolBox.Tool.Fix public void PrintToConsole() { - AnsiConsole.Render(new FigletText("Done").Color(Color.Green)); + AnsiConsole.Write(new FigletText("Done").Color(Color.Green)); if (this.Unrepairable) { - AnsiConsole.Render(new Panel("This file contains error(s) that are identified as unrepairable (yet).\n" + + AnsiConsole.Write(new Panel("This file contains error(s) that are identified as unrepairable (yet).\n" + "Please check if you're using the newest version.\n" + "Please consider send a sample file to the developer.") { @@ -41,7 +41,7 @@ namespace BililiveRecorder.ToolBox.Tool.Fix }); } - AnsiConsole.Render(new Panel(this.InputPath.EscapeMarkup()) + AnsiConsole.Write(new Panel(this.InputPath.EscapeMarkup()) { Header = new PanelHeader("Input"), Border = BoxBorder.Rounded @@ -54,9 +54,9 @@ namespace BililiveRecorder.ToolBox.Tool.Fix for (var i = 0; i < this.OutputPaths.Length; i++) table_output.AddRow(this.OutputPaths[i].EscapeMarkup()); - AnsiConsole.Render(table_output); + AnsiConsole.Write(table_output); - AnsiConsole.Render(new Table() + AnsiConsole.Write(new Table() .Border(TableBorder.Rounded) .AddColumns("Category", "Count") .AddRow("Unrepairable", this.IssueTypeUnrepairable.ToString()) diff --git a/BililiveRecorder.ToolBox/ToolCommand.cs b/BililiveRecorder.ToolBox/ToolCommand.cs index 73ca3ea..9f7a76e 100644 --- a/BililiveRecorder.ToolBox/ToolCommand.cs +++ b/BililiveRecorder.ToolBox/ToolCommand.cs @@ -86,7 +86,9 @@ namespace BililiveRecorder.ToolBox { var t = ctx.AddTask(handler.Name); t.MaxValue = 1d; +#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously var r = await handler.Handle(request, default, async p => t.Value = p).ConfigureAwait(false); +#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously t.Value = 1d; return r; }) @@ -107,7 +109,7 @@ namespace BililiveRecorder.ToolBox } else { - AnsiConsole.Render(new FigletText("Error").Color(Color.Red)); + AnsiConsole.Write(new FigletText("Error").Color(Color.Red)); var errorInfo = new Table { @@ -116,10 +118,10 @@ namespace BililiveRecorder.ToolBox errorInfo.AddColumn(new TableColumn("Error Code").Centered()); errorInfo.AddColumn(new TableColumn("Error Message").Centered()); errorInfo.AddRow("[red]" + response.Status.ToString().EscapeMarkup() + "[/]", "[red]" + (response.ErrorMessage ?? string.Empty) + "[/]"); - AnsiConsole.Render(errorInfo); + AnsiConsole.Write(errorInfo); if (response.Exception is not null) - AnsiConsole.Render(new Panel(response.Exception.GetRenderable(ExceptionFormats.ShortenPaths | ExceptionFormats.ShowLinks)) + AnsiConsole.Write(new Panel(response.Exception.GetRenderable(ExceptionFormats.ShortenPaths | ExceptionFormats.ShowLinks)) { Header = new PanelHeader("Exception Info"), Border = BoxBorder.Rounded diff --git a/BililiveRecorder.WPF/Models/AboutModel.cs b/BililiveRecorder.WPF/Models/AboutModel.cs index 59bd364..4a5604d 100644 --- a/BililiveRecorder.WPF/Models/AboutModel.cs +++ b/BililiveRecorder.WPF/Models/AboutModel.cs @@ -1,16 +1,13 @@ -using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; #nullable enable namespace BililiveRecorder.WPF.Models { public class AboutModel : INotifyPropertyChanged { +#pragma warning disable CS0067 // The event 'Recorder.PropertyChanged' is never used public event PropertyChangedEventHandler? PropertyChanged; +#pragma warning restore CS0067 // The event 'Recorder.PropertyChanged' is never used public string InformationalVersion => GitVersionInformation.InformationalVersion; } diff --git a/BililiveRecorder.WPF/NewMainWindow.xaml.cs b/BililiveRecorder.WPF/NewMainWindow.xaml.cs index 9add0fb..5d5c40a 100644 --- a/BililiveRecorder.WPF/NewMainWindow.xaml.cs +++ b/BililiveRecorder.WPF/NewMainWindow.xaml.cs @@ -45,7 +45,7 @@ namespace BililiveRecorder.WPF internal void CloseWithoutConfirmAction() { this.CloseConfirmed = true; - this.Dispatcher.BeginInvoke(this.Close, DispatcherPriority.Normal); + _ = this.Dispatcher.BeginInvoke(this.Close, DispatcherPriority.Normal); } internal void SuperActivateAction() diff --git a/BililiveRecorder.WPF/Pages/RootPage.xaml.cs b/BililiveRecorder.WPF/Pages/RootPage.xaml.cs index d7ff624..24ad40e 100644 --- a/BililiveRecorder.WPF/Pages/RootPage.xaml.cs +++ b/BililiveRecorder.WPF/Pages/RootPage.xaml.cs @@ -41,7 +41,7 @@ namespace BililiveRecorder.WPF.Pages private int SettingsClickCount = 0; internal static IServiceProvider? ServiceProvider { get; private set; } - private ServiceProvider serviceProvider; + private ServiceProvider serviceProvider = null!; internal RootModel Model { get; private set; } internal static Action? SwitchToSettingsPage { get; private set; } diff --git a/BililiveRecorder.WPF/Pages/ToolboxDanmakuMergerPage.xaml.cs b/BililiveRecorder.WPF/Pages/ToolboxDanmakuMergerPage.xaml.cs index b5b7c4f..42797a7 100644 --- a/BililiveRecorder.WPF/Pages/ToolboxDanmakuMergerPage.xaml.cs +++ b/BililiveRecorder.WPF/Pages/ToolboxDanmakuMergerPage.xaml.cs @@ -44,7 +44,9 @@ namespace BililiveRecorder.WPF.Pages this.CalculateOffsets(); } +#pragma warning disable VSTHRD100 // Avoid async void methods private async void DragDrop(object sender, DragEventArgs e) +#pragma warning restore VSTHRD100 // Avoid async void methods { try { @@ -58,7 +60,9 @@ namespace BililiveRecorder.WPF.Pages { } } +#pragma warning disable VSTHRD100 // Avoid async void methods private async void AddFile_Click(object sender, RoutedEventArgs e) +#pragma warning restore VSTHRD100 // Avoid async void methods { var d = new CommonOpenFileDialog { @@ -112,7 +116,9 @@ namespace BililiveRecorder.WPF.Pages this.listView.DataContext = this.Files; } +#pragma warning disable VSTHRD100 // Avoid async void methods private async void Merge_Click(object sender, RoutedEventArgs e) +#pragma warning restore VSTHRD100 // Avoid async void methods { AutoFixProgressDialog? progressDialog = null; diff --git a/BililiveRecorder.Web/Models/Config.gen.cs b/BililiveRecorder.Web/Models/Config.gen.cs index bf975e2..9a9fafd 100644 --- a/BililiveRecorder.Web/Models/Config.gen.cs +++ b/BililiveRecorder.Web/Models/Config.gen.cs @@ -64,7 +64,7 @@ namespace BililiveRecorder.Web.Models public Optional? OptionalRecordDanmakuFlushInterval { get; set; } public Optional? OptionalNetworkTransportUseSystemProxy { get; set; } public Optional? OptionalNetworkTransportAllowedAddressFamily { get; set; } - public Optional? OptionalUserScript { get; set; } + public Optional? OptionalUserScript { get; set; } public void ApplyTo(GlobalConfig config) { @@ -140,7 +140,7 @@ namespace BililiveRecorder.Web.Models.Rest public Optional OptionalRecordDanmakuFlushInterval { get; set; } public Optional OptionalNetworkTransportUseSystemProxy { get; set; } public Optional OptionalNetworkTransportAllowedAddressFamily { get; set; } - public Optional OptionalUserScript { get; set; } + public Optional OptionalUserScript { get; set; } } } diff --git a/config_gen/data.ts b/config_gen/data.ts index 4e51da3..dd780f8 100644 --- a/config_gen/data.ts +++ b/config_gen/data.ts @@ -237,7 +237,7 @@ export const data: Array = [ { name: "UserScript", description: "自定义脚本", - type: "string", + type: "string?", defaultValue: "string.Empty", configType: "globalOnly", advancedConfig: true, diff --git a/test/BililiveRecorder.Core.UnitTests/Danmaku/ManualTests.cs b/test/BililiveRecorder.Core.UnitTests/Danmaku/ManualTests.cs index ed20fe2..505644f 100644 --- a/test/BililiveRecorder.Core.UnitTests/Danmaku/ManualTests.cs +++ b/test/BililiveRecorder.Core.UnitTests/Danmaku/ManualTests.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Net.Http; using System.Threading.Tasks; -using BililiveRecorder.Core.Api; using BililiveRecorder.Core.Api.Danmaku; using BililiveRecorder.Core.Api.Http; -using Newtonsoft.Json.Linq; using Xunit; namespace BililiveRecorder.Core.UnitTests.Danmaku @@ -15,7 +11,7 @@ namespace BililiveRecorder.Core.UnitTests.Danmaku [Fact(Skip = "skip")] public async Task TestAsync() { - var client = new DanmakuClient(new HttpApiClient(null!), null); + var client = new DanmakuClient(new HttpApiClient(null!), null!); client.StatusChanged += this.Client_StatusChanged; client.DanmakuReceived += this.Client_DanmakuReceived; @@ -28,11 +24,11 @@ namespace BililiveRecorder.Core.UnitTests.Danmaku // await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false); } - private void Client_DanmakuReceived(object sender, DanmakuReceivedEventArgs e) + private void Client_DanmakuReceived(object? sender, DanmakuReceivedEventArgs e) { } - private void Client_StatusChanged(object sender, StatusChangedEventArgs e) + private void Client_StatusChanged(object? sender, StatusChangedEventArgs e) { } } diff --git a/test/BililiveRecorder.Core.UnitTests/Expectations/PublicApi.HasNoChangesAsync.verified.txt b/test/BililiveRecorder.Core.UnitTests/Expectations/PublicApi.HasNoChangesAsync.verified.txt index 0df5231..12788d3 100644 --- a/test/BililiveRecorder.Core.UnitTests/Expectations/PublicApi.HasNoChangesAsync.verified.txt +++ b/test/BililiveRecorder.Core.UnitTests/Expectations/PublicApi.HasNoChangesAsync.verified.txt @@ -169,7 +169,7 @@ namespace BililiveRecorder.Core.Config.V3 [Newtonsoft.Json.JsonProperty("TimingWatchdogTimeout")] public HierarchicalPropertyDefault.Optional OptionalTimingWatchdogTimeout { get; set; } [Newtonsoft.Json.JsonProperty("UserScript")] - public HierarchicalPropertyDefault.Optional OptionalUserScript { get; set; } + public HierarchicalPropertyDefault.Optional OptionalUserScript { get; set; } [Newtonsoft.Json.JsonProperty("WebHookUrls")] public HierarchicalPropertyDefault.Optional OptionalWebHookUrls { get; set; } [Newtonsoft.Json.JsonProperty("WebHookUrlsV2")] @@ -190,7 +190,7 @@ namespace BililiveRecorder.Core.Config.V3 public uint TimingStreamRetry { get; set; } public uint TimingStreamRetryNoQn { get; set; } public uint TimingWatchdogTimeout { get; set; } - public string UserScript { get; set; } + public string? UserScript { get; set; } public string? WebHookUrls { get; set; } public string? WebHookUrlsV2 { get; set; } public string? WorkDirectory { get; set; } @@ -256,7 +256,7 @@ namespace BililiveRecorder.Core.Config.V3 public uint TimingStreamRetry { get; } public uint TimingStreamRetryNoQn { get; } public uint TimingWatchdogTimeout { get; } - public string UserScript { get; } + public string? UserScript { get; } public string? WebHookUrls { get; } public string? WebHookUrlsV2 { get; } public string? WorkDirectory { get; } diff --git a/test/BililiveRecorder.Flv.Tests/AssertTags.cs b/test/BililiveRecorder.Flv.Tests/AssertTags.cs index 9aa365e..d8d4da8 100644 --- a/test/BililiveRecorder.Flv.Tests/AssertTags.cs +++ b/test/BililiveRecorder.Flv.Tests/AssertTags.cs @@ -6,10 +6,8 @@ namespace BililiveRecorder.Flv.Tests { public static class AssertTags { - public static void ShouldHaveLinearTimestamps(List tags) - { + public static void ShouldHaveLinearTimestamps(List tags) => Assert.True(tags.Any2((a, b) => (a.Timestamp <= b.Timestamp) && (b.Timestamp - a.Timestamp < 50))); - } public static void ShouldHaveFullHeaderTags(List tags) { diff --git a/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedBadTests.cs b/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedBadTests.cs index 8c1cf7c..a42183f 100644 --- a/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedBadTests.cs +++ b/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedBadTests.cs @@ -84,17 +84,12 @@ namespace BililiveRecorder.Flv.Tests.RuleTests this.Count = count; } - public override bool Equals(object? obj) - { - return obj is CommentCount other && - this.Type == other.Type && - this.Count == other.Count; - } + public override bool Equals(object? obj) => + obj is CommentCount other && + this.Type == other.Type && + this.Count == other.Count; - public override int GetHashCode() - { - return HashCode.Combine(this.Type, this.Count); - } + public override int GetHashCode() => HashCode.Combine(this.Type, this.Count); public void Deconstruct(out CommentType type, out int count) { @@ -111,6 +106,16 @@ namespace BililiveRecorder.Flv.Tests.RuleTests { return new CommentCount(value.Item1, value.Item2); } + + public static bool operator ==(CommentCount left, CommentCount right) + { + return left.Equals(right); + } + + public static bool operator !=(CommentCount left, CommentCount right) + { + return !(left == right); + } } } }