From 58907e2c290473326e5ab74bdfe1429b8a518ba4 Mon Sep 17 00:00:00 2001 From: Marco Carvalho Date: Thu, 22 Jun 2023 13:36:07 -0300 Subject: [PATCH] GetHashCode should not reference mutable fields (#5331) --- src/ARMeilleure/State/V128.cs | 4 ++-- src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs | 2 +- src/Ryujinx.Tests.Unicorn/SimdValue.cs | 4 ++-- src/Spv.Generator/ConstantKey.cs | 2 +- src/Spv.Generator/DeterministicStringKey.cs | 2 +- src/Spv.Generator/LiteralString.cs | 2 +- src/Spv.Generator/TypeDeclarationKey.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ARMeilleure/State/V128.cs b/src/ARMeilleure/State/V128.cs index 3fa9f9a99..441bbfa6d 100644 --- a/src/ARMeilleure/State/V128.cs +++ b/src/ARMeilleure/State/V128.cs @@ -13,8 +13,8 @@ namespace ARMeilleure.State // _e0 & _e1 could be marked as readonly, however they are not readonly because we modify them through the Unsafe // APIs. This also means that one should be careful when changing the layout of this struct. - private ulong _e0; - private ulong _e1; + private readonly ulong _e0; + private readonly ulong _e1; /// /// Gets a new with all bits set to zero. diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs index c1a97f526..283d82fc8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x10)] struct CreateId : IEquatable { - public UInt128 Raw; + public readonly UInt128 Raw; public bool IsNull => Raw == UInt128.Zero; public bool IsValid => !IsNull && ((Raw >> 64) & 0xC0) == 0x80; diff --git a/src/Ryujinx.Tests.Unicorn/SimdValue.cs b/src/Ryujinx.Tests.Unicorn/SimdValue.cs index 2b5284305..ce9e178cc 100644 --- a/src/Ryujinx.Tests.Unicorn/SimdValue.cs +++ b/src/Ryujinx.Tests.Unicorn/SimdValue.cs @@ -4,8 +4,8 @@ namespace Ryujinx.Tests.Unicorn { public struct SimdValue : IEquatable { - private ulong _e0; - private ulong _e1; + private readonly ulong _e0; + private readonly ulong _e1; public SimdValue(ulong e0, ulong e1) { diff --git a/src/Spv.Generator/ConstantKey.cs b/src/Spv.Generator/ConstantKey.cs index d3c1b905a..e7758b408 100644 --- a/src/Spv.Generator/ConstantKey.cs +++ b/src/Spv.Generator/ConstantKey.cs @@ -5,7 +5,7 @@ namespace Spv.Generator { internal struct ConstantKey : IEquatable { - private Instruction _constant; + private readonly Instruction _constant; public ConstantKey(Instruction constant) { diff --git a/src/Spv.Generator/DeterministicStringKey.cs b/src/Spv.Generator/DeterministicStringKey.cs index 491bb745a..cab4dbcc2 100644 --- a/src/Spv.Generator/DeterministicStringKey.cs +++ b/src/Spv.Generator/DeterministicStringKey.cs @@ -5,7 +5,7 @@ namespace Spv.Generator { internal class DeterministicStringKey : IEquatable { - private string _value; + private readonly string _value; public DeterministicStringKey(string value) { diff --git a/src/Spv.Generator/LiteralString.cs b/src/Spv.Generator/LiteralString.cs index 629ff7bf6..741d922bb 100644 --- a/src/Spv.Generator/LiteralString.cs +++ b/src/Spv.Generator/LiteralString.cs @@ -8,7 +8,7 @@ namespace Spv.Generator { public OperandType Type => OperandType.String; - private string _value; + private readonly string _value; public LiteralString(string value) { diff --git a/src/Spv.Generator/TypeDeclarationKey.cs b/src/Spv.Generator/TypeDeclarationKey.cs index a4aa95634..e4fd5fd57 100644 --- a/src/Spv.Generator/TypeDeclarationKey.cs +++ b/src/Spv.Generator/TypeDeclarationKey.cs @@ -5,7 +5,7 @@ namespace Spv.Generator { internal struct TypeDeclarationKey : IEquatable { - private Instruction _typeDeclaration; + private readonly Instruction _typeDeclaration; public TypeDeclarationKey(Instruction typeDeclaration) {