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 3fa9f9a999..441bbfa6d9 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 c1a97f5263..283d82fc81 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 2b52843058..ce9e178ccd 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 d3c1b905a7..e7758b408f 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 491bb745ab..cab4dbcc24 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 629ff7bf63..741d922bbb 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 a4aa956340..e4fd5fd572 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) {