From 05650ce1d9965077caecaebd62b439c1c95a3764 Mon Sep 17 00:00:00 2001 From: wherewhere Date: Sun, 28 Jul 2024 20:34:56 +0800 Subject: [PATCH] Remove struct default construct --- AdvancedSharpAdbClient.Tests/Models/DeviceDataTests.cs | 5 ++++- .../DeviceCommands/Models/AndroidProcess.cs | 7 +------ AdvancedSharpAdbClient/DeviceMonitor.Async.cs | 5 ----- AdvancedSharpAdbClient/Models/ColorData.cs | 5 ----- AdvancedSharpAdbClient/Models/DeviceData.cs | 2 +- AdvancedSharpAdbClient/Models/ForwardData.cs | 9 ++------- AdvancedSharpAdbClient/Models/ForwardSpec.cs | 7 +------ AdvancedSharpAdbClient/Models/FramebufferHeader.cs | 9 ++------- 8 files changed, 11 insertions(+), 38 deletions(-) diff --git a/AdvancedSharpAdbClient.Tests/Models/DeviceDataTests.cs b/AdvancedSharpAdbClient.Tests/Models/DeviceDataTests.cs index 85a6333..b5ff278 100644 --- a/AdvancedSharpAdbClient.Tests/Models/DeviceDataTests.cs +++ b/AdvancedSharpAdbClient.Tests/Models/DeviceDataTests.cs @@ -230,7 +230,10 @@ public void EqualityTest(string data, string serial, string product, string mode Model = model, Name = name, TransportId = transportId, - State = DeviceState.Online + State = DeviceState.Online, + Usb = string.Empty, + Features = [], + Message = string.Empty }; Assert.True(d1 == d2); diff --git a/AdvancedSharpAdbClient/DeviceCommands/Models/AndroidProcess.cs b/AdvancedSharpAdbClient/DeviceCommands/Models/AndroidProcess.cs index b5ef9d3..578ce72 100644 --- a/AdvancedSharpAdbClient/DeviceCommands/Models/AndroidProcess.cs +++ b/AdvancedSharpAdbClient/DeviceCommands/Models/AndroidProcess.cs @@ -11,18 +11,13 @@ namespace AdvancedSharpAdbClient.DeviceCommands.Models /// public readonly struct AndroidProcess { - /// - /// Initializes a new instance of the struct. - /// - public AndroidProcess() { } - /// /// Initializes a new instance of the struct from it representation. /// /// A which represents a . /// A value indicating whether the output of /proc/{pid}/stat is prefixed with /proc/{pid}/cmdline or not. /// Because stat does not contain the full process name, this can be useful. - public AndroidProcess(string line, bool cmdLinePrefix = false) : this() + public AndroidProcess(string line, bool cmdLinePrefix = false) { ExceptionExtensions.ThrowIfNull(line); diff --git a/AdvancedSharpAdbClient/DeviceMonitor.Async.cs b/AdvancedSharpAdbClient/DeviceMonitor.Async.cs index 97037e6..195bbd9 100644 --- a/AdvancedSharpAdbClient/DeviceMonitor.Async.cs +++ b/AdvancedSharpAdbClient/DeviceMonitor.Async.cs @@ -249,11 +249,6 @@ private async Task InitializeSocketAsync(CancellationToken cancellationToken) [EditorBrowsable(EditorBrowsableState.Never)] private readonly struct ThreadSwitcher : INotifyCompletion { - /// - /// Initializes a new instance of the struct. - /// - public ThreadSwitcher() { } - /// /// Gets a value that indicates whether the asynchronous operation has completed. /// diff --git a/AdvancedSharpAdbClient/Models/ColorData.cs b/AdvancedSharpAdbClient/Models/ColorData.cs index 855a2dc..f15e151 100644 --- a/AdvancedSharpAdbClient/Models/ColorData.cs +++ b/AdvancedSharpAdbClient/Models/ColorData.cs @@ -32,11 +32,6 @@ public readonly record struct ColorData(uint Offset, uint Length) : IReadOnlyLis /// private const int count = 8; - /// - /// Initializes a new instance of the struct. - /// - public ColorData() : this(0, 0) { } - /// /// Gets or sets the offset, in bits, within the byte array for a pixel, at which the /// bytes that contain information for this color are stored. diff --git a/AdvancedSharpAdbClient/Models/DeviceData.cs b/AdvancedSharpAdbClient/Models/DeviceData.cs index cb9041d..9d5e25c 100644 --- a/AdvancedSharpAdbClient/Models/DeviceData.cs +++ b/AdvancedSharpAdbClient/Models/DeviceData.cs @@ -33,7 +33,7 @@ namespace AdvancedSharpAdbClient.Models /// data retrieved from the Android Debug Bridge. /// /// The data retrieved from the Android Debug Bridge that represents a device. - public DeviceData(string data) : this() + public DeviceData(string data) { Match match = Regex.Match(data); if (match.Success) diff --git a/AdvancedSharpAdbClient/Models/ForwardData.cs b/AdvancedSharpAdbClient/Models/ForwardData.cs index 8a4f1f3..a2ebad6 100644 --- a/AdvancedSharpAdbClient/Models/ForwardData.cs +++ b/AdvancedSharpAdbClient/Models/ForwardData.cs @@ -14,18 +14,13 @@ namespace AdvancedSharpAdbClient.Models [DebuggerDisplay($"{nameof(AdbServerStatus)} \\{{ {nameof(SerialNumber)} = {{{nameof(SerialNumber)}}}, {nameof(LocalSpec)} = {{{nameof(LocalSpec)}}}, {nameof(RemoteSpec)} = {{{nameof(RemoteSpec)}}} }}")] public readonly struct ForwardData : IEquatable { - /// - /// Initializes a new instance of the struct. - /// - public ForwardData() { } - /// /// Initializes a new instance of the struct. /// /// The serial number of the device for which the port forwarding is configured. /// The that represents the local (PC) endpoint. /// The that represents the remote (device) endpoint. - public ForwardData(string serialNumber, string local, string remote) : this() + public ForwardData(string serialNumber, string local, string remote) { SerialNumber = serialNumber; Local = local; @@ -36,7 +31,7 @@ public ForwardData(string serialNumber, string local, string remote) : this() /// Initializes a new instance of the class by parsing a . /// /// The value to parse. - public ForwardData(string value) : this() + public ForwardData(string value) { string[] parts = value.Split(' '); SerialNumber = parts[0]; diff --git a/AdvancedSharpAdbClient/Models/ForwardSpec.cs b/AdvancedSharpAdbClient/Models/ForwardSpec.cs index 50dba8d..1f35075 100644 --- a/AdvancedSharpAdbClient/Models/ForwardSpec.cs +++ b/AdvancedSharpAdbClient/Models/ForwardSpec.cs @@ -31,16 +31,11 @@ namespace AdvancedSharpAdbClient.Models { "jdwp", ForwardProtocol.JavaDebugWireProtocol } }; - /// - /// Initializes a new instance of the struct. - /// - public ForwardSpec() { } - /// /// Initializes a new instance of the struct from its representation. /// /// A which represents a . - public ForwardSpec(string spec) : this() + public ForwardSpec(string spec) { ExceptionExtensions.ThrowIfNull(spec); diff --git a/AdvancedSharpAdbClient/Models/FramebufferHeader.cs b/AdvancedSharpAdbClient/Models/FramebufferHeader.cs index c7d1741..d1ea553 100644 --- a/AdvancedSharpAdbClient/Models/FramebufferHeader.cs +++ b/AdvancedSharpAdbClient/Models/FramebufferHeader.cs @@ -38,17 +38,12 @@ namespace AdvancedSharpAdbClient.Models /// public const int MiniLength = 52; - /// - /// Initializes a new instance of the struct. - /// - public FramebufferHeader() { } - /// /// Initializes a new instance of the struct based on a byte array which contains the data. /// /// The data that feeds the struct. /// As defined in - public FramebufferHeader(byte[] data) : this() + public FramebufferHeader(byte[] data) { if (data.Length is < MiniLength or > MaxLength) { @@ -102,7 +97,7 @@ public FramebufferHeader(byte[] data) : this() /// /// The data that feeds the struct. /// As defined in - public FramebufferHeader(ReadOnlySpan data) : this() + public FramebufferHeader(ReadOnlySpan data) { if (data.Length is < MiniLength or > MaxLength) {