OctetSerializableBase & IByteSerializable: Remove "FromHex", constructors are expected to be used to instantiate classes.
MODIFY
WalletWasabi/Tor/Socks5/Models/Bases/OctetSerializableBase.cs
WalletWasabi/Tor/Socks5/Models/Bases/OctetSerializableBase.cs
using System;
-using WalletWasabi.Helpers;
using WalletWasabi.Tor.Socks5.Models.Interfaces;
namespace WalletWasabi.Tor.Socks5.Models.Bases
{
public abstract class OctetSerializableBase : IByteSerializable, IEquatable<OctetSerializableBase>, IEquatable<byte>
{
- protected byte ByteValue { get; set; }
+ protected byte ByteValue { get; init; }
#region Serialization
@@ -21,19 +20,6 @@ namespace WalletWasabi.Tor.Socks5.Models.Bases
return ByteHelpers.ToHex(ToByte());
}
- public void FromHex(string hex)
- {
- hex = Guard.NotNullOrEmptyOrWhitespace(nameof(hex), hex, true);
-
- byte[] bytes = ByteHelpers.FromHex(hex);
- if (bytes.Length != 1)
- {
- throw new FormatException($"{nameof(hex)} must be exactly one byte. Actual: {bytes.Length} bytes. Value: {hex}.");
- }
-
- ByteValue = bytes[0];
- }
-
public override string ToString()
{
return ToHex(xhhSyntax: true);

MODIFY
WalletWasabi/Tor/Socks5/Models/Interfaces/IByteSerializable.cs
WalletWasabi/Tor/Socks5/Models/Interfaces/IByteSerializable.cs
@@ -5,7 +5,5 @@ namespace WalletWasabi.Tor.Socks5.Models.Interfaces
byte ToByte();
string ToHex(bool xhhSyntax);
-
- void FromHex(string hex);
}
}

OctetSerializableBase & IByteSerializable: Remove "FromHex", constructors are expected to be used to instantiate classes.