[#13] Client: Use code analyzers

Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
Pavel Gross 2024-09-23 18:53:21 +03:00
parent d7dbbf8da8
commit d1271df207
102 changed files with 2168 additions and 733 deletions

View file

@ -4,7 +4,7 @@ using Frostfs.V2.Ape;
namespace FrostFS.SDK.ClientV2
{
public struct FrostFsChainTarget(FrostFsTargetType type, string name)
public struct FrostFsChainTarget(FrostFsTargetType type, string name) : IEquatable<FrostFsChainTarget>
{
private ChainTarget? chainTarget;
@ -33,5 +33,31 @@ namespace FrostFS.SDK.ClientV2
_ => throw new ArgumentException("Unexpected value for TargetType", nameof(type)),
};
}
public override readonly bool Equals(object obj)
{
var target = (FrostFsChainTarget)obj;
return Equals(target);
}
public override readonly int GetHashCode()
{
return $"{Name}{Type}".GetHashCode();
}
public static bool operator ==(FrostFsChainTarget left, FrostFsChainTarget right)
{
return left.Equals(right);
}
public static bool operator !=(FrostFsChainTarget left, FrostFsChainTarget right)
{
return !(left == right);
}
public readonly bool Equals(FrostFsChainTarget other)
{
return Type == other.Type && Name.Equals(other.Name, StringComparison.Ordinal);
}
}
}

View file

@ -2,7 +2,7 @@
namespace FrostFS.SDK.ClientV2
{
public struct FrostFsChain (byte[] raw)
public struct FrostFsChain(byte[] raw) : System.IEquatable<FrostFsChain>
{
private ByteString? grpcRaw;
@ -12,5 +12,31 @@ namespace FrostFS.SDK.ClientV2
{
return grpcRaw ??= ByteString.CopyFrom(Raw);
}
public override readonly bool Equals(object obj)
{
var chain = (FrostFsChain)obj;
return Equals(chain);
}
public override readonly int GetHashCode()
{
return Raw.GetHashCode();
}
public static bool operator ==(FrostFsChain left, FrostFsChain right)
{
return left.Equals(right);
}
public static bool operator !=(FrostFsChain left, FrostFsChain right)
{
return !(left == right);
}
public readonly bool Equals(FrostFsChain other)
{
return Raw == other.Raw;
}
}
}

View file

@ -1,6 +1,6 @@
namespace FrostFS.SDK.ClientV2
{
public enum FrostFsTargetType
public enum FrostFsTargetType
{
Undefined = 0,
Namespace,