Enable MA0066 and fix noncompliance

"Hash table unfriendly type is used in a hash table"
This commit is contained in:
YoshiRulz 2022-07-22 06:26:23 +10:00
parent 41d46dd37d
commit d142555ec3
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
5 changed files with 24 additions and 5 deletions

View File

@ -309,7 +309,7 @@
<Rule Id="MA0065" Action="Error" />
<!-- Hash table unfriendly type is used in a hash table -->
<Rule Id="MA0066" Action="Hidden" />
<Rule Id="MA0066" Action="Error" />
<!-- Use Guid.Empty -->
<Rule Id="MA0067" Action="Error" />

View File

@ -174,6 +174,7 @@ let
({ name = "Menees.Analyzers"; version = "3.0.8"; sha256 = "1apv06cmnrakaylyh85hjyn380cnj0h53j3pakyp0f4jnpgw0bgf"; })
({ name = "Meziantou.Analyzer"; version = "1.0.707"; sha256 = "09drs16fr0xly4k8drznw7pa5f2byjc9km0pm0c3rrhl7jsz4ds5"; })
({ name = "Microsoft.AspNetCore.App.Ref"; version = "6.0.6"; sha256 = "08pjgsq2vcsdy4vgff146izvxq5hpg02a8lvih0wcsgghv1m1qki"; })
({ name = "Microsoft.Bcl.HashCode"; version = "1.1.1"; sha256 = "0xwfph92p92d8hgrdiaka4cazqsjpg4ywfxfx6qbk3939f29kzl0"; })
({ name = "Nullable"; version = "1.3.1"; sha256 = "0hwrr4q22c0i056dqy3v431rxjv7md910ihz0pjsi16qxsbpw7p7"; })
({ name = "StyleCop.Analyzers"; version = "1.2.0-beta.435"; sha256 = "0dirz0av24ds2k7hgpss15y4wlhwlzz22qdjvkq0n3g3sxcckrsy"; })
({ name = "StyleCop.Analyzers.Unstable"; version = "1.2.0.435"; sha256 = "1jv4ha4y2c9922n21yf2dvfkmi8qfa8z28gk5zsqdyck08izp9mh"; })

View File

@ -7,6 +7,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" PrivateAssets="all" />

View File

@ -1,7 +1,15 @@
using System;
namespace BizHawk.Emulation.Common
{
public readonly struct FirmwareRecord
public readonly struct FirmwareRecord : IEquatable<FirmwareRecord>
{
public static bool operator ==(FirmwareRecord a, FirmwareRecord b)
=> a.Equals(b);
public static bool operator !=(FirmwareRecord a, FirmwareRecord b)
=> !(a == b);
public readonly string Description;
public readonly FirmwareID ID;
@ -11,5 +19,14 @@ namespace BizHawk.Emulation.Common
Description = desc;
ID = id;
}
public bool Equals(FirmwareRecord other)
=> ID == other.ID && Description == other.Description;
public readonly override bool Equals(object? obj)
=> obj is FirmwareRecord fr && Equals(fr);
public readonly override int GetHashCode()
=> HashCode.Combine(ID, Description);
}
}

View File

@ -191,9 +191,9 @@ namespace BizHawk.Emulation.Cores.Waterbox
if (xx != yy)
return PutSettingsDirtyBits.RebootCore;
}
if (!new HashSet<KeyValuePair<int, string>>(x.PortDevices).SetEquals(y.PortDevices))
return PutSettingsDirtyBits.RebootCore;
return PutSettingsDirtyBits.None;
return x.PortDevices.OrderBy(static kvp => kvp.Key).SequenceEqual(y.PortDevices.OrderBy(static kvp => kvp.Key))
? PutSettingsDirtyBits.None
: PutSettingsDirtyBits.RebootCore;
}
}