Use concrete types when possible for improved performance

This commit is contained in:
Marco Carvalho 2025-01-05 11:54:53 -03:00
parent 850df38f1e
commit c80c397967
45 changed files with 150 additions and 171 deletions

View file

@ -236,37 +236,4 @@ dotnet_naming_style.IPascalCase.required_suffix =
dotnet_naming_style.IPascalCase.word_separator =
dotnet_naming_style.IPascalCase.capitalization = pascal_case
# TODO:
# .NET 8 migration (new warnings are caused by the NET 8 C# compiler and analyzer)
# The following info messages might need to be fixed in the source code instead of hiding the actual message
# Without the following lines, dotnet format would fail
# Disable "Collection initialization can be simplified"
dotnet_diagnostic.IDE0028.severity = none
dotnet_diagnostic.IDE0300.severity = none
dotnet_diagnostic.IDE0301.severity = none
dotnet_diagnostic.IDE0302.severity = none
dotnet_diagnostic.IDE0305.severity = none
# Disable "'new' expression can be simplified"
dotnet_diagnostic.IDE0090.severity = none
# Disable "Use primary constructor"
dotnet_diagnostic.IDE0290.severity = none
# Disable "Member '' does not access instance data and can be marked as static"
dotnet_diagnostic.CA1822.severity = none
# Disable "Change type of field '' from '' to '' for improved performance"
dotnet_diagnostic.CA1859.severity = none
# Disable "Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array"
dotnet_diagnostic.CA1861.severity = none
# Disable "Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison, but keep in mind that this might cause subtle changes in behavior, so make sure to conduct thorough testing after applying the suggestion, or if culturally sensitive comparison is not required, consider using 'StringComparison.OrdinalIgnoreCase'"
dotnet_diagnostic.CA1862.severity = none
[src/Ryujinx/UI/ViewModels/**.cs]
# Disable "mark members as static" rule for ViewModels
dotnet_diagnostic.CA1822.severity = none
[src/Ryujinx.HLE/HOS/Services/**.cs]
# Disable "mark members as static" rule for services
dotnet_diagnostic.CA1822.severity = none
[src/Ryujinx.Tests/Cpu/*.cs]
# Disable naming rules for CPU tests
dotnet_diagnostic.IDE1006.severity = none
dotnet_diagnostic.CA1859.severity = error

View file

@ -1,6 +1,7 @@
using ARMeilleure.CodeGen.Linking;
using ARMeilleure.CodeGen.RegisterAllocators;
using ARMeilleure.IntermediateRepresentation;
using Microsoft.IO;
using Ryujinx.Common.Memory;
using System;
using System.Collections.Generic;
@ -14,7 +15,7 @@ namespace ARMeilleure.CodeGen.Arm64
private const int CbnzInstLength = 4;
private const int LdrLitInstLength = 4;
private readonly Stream _stream;
private readonly RecyclableMemoryStream _stream;
public int StreamOffset => (int)_stream.Length;

View file

@ -1,5 +1,6 @@
using ARMeilleure.CodeGen.RegisterAllocators;
using ARMeilleure.IntermediateRepresentation;
using Microsoft.IO;
using Ryujinx.Common.Memory;
using System.IO;
using System.Numerics;
@ -8,7 +9,7 @@ namespace ARMeilleure.CodeGen.X86
{
class CodeGenContext
{
private readonly Stream _stream;
private readonly RecyclableMemoryStream _stream;
private readonly Operand[] _blockLabels;
public int StreamOffset => (int)_stream.Length;

View file

@ -266,7 +266,7 @@ namespace ARMeilleure.Instructions
}
}
private static Exception InvalidOpCodeType(OpCode opCode)
private static InvalidOperationException InvalidOpCodeType(OpCode opCode)
{
return new InvalidOperationException($"Invalid OpCode type \"{opCode?.GetType().Name ?? "null"}\".");
}

View file

@ -717,7 +717,7 @@ namespace ARMeilleure.Instructions
};
}
private static Exception InvalidOpCodeType(OpCode opCode)
private static InvalidOperationException InvalidOpCodeType(OpCode opCode)
{
return new InvalidOperationException($"Invalid OpCode type \"{opCode?.GetType().Name ?? "null"}\".");
}

View file

@ -1,5 +1,6 @@
using ARMeilleure.State;
using Humanizer;
using Microsoft.IO;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
@ -73,7 +74,7 @@ namespace ARMeilleure.Translation.PTC
Enabled = false;
}
private void TimerElapsed(object _, ElapsedEventArgs __)
private void TimerElapsed(object _, ElapsedEventArgs __)
=> new Thread(PreSave) { Name = "Ptc.DiskWriter" }.Start();
public void AddEntry(ulong address, ExecutionMode mode, bool highCq)
@ -191,7 +192,7 @@ namespace ARMeilleure.Translation.PTC
return false;
}
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
Debug.Assert(stream.Seek(0L, SeekOrigin.Begin) == 0L && stream.Length == 0L);
try

View file

@ -5,7 +5,7 @@ namespace Ryujinx.Common.Logging.Targets
{
public class ConsoleLogTarget : ILogTarget
{
private readonly ILogFormatter _formatter;
private readonly DefaultLogFormatter _formatter;
private readonly string _name;

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Common.Logging.Targets
public class FileLogTarget : ILogTarget
{
private readonly StreamWriter _logWriter;
private readonly ILogFormatter _formatter;
private readonly DefaultLogFormatter _formatter;
private readonly string _name;
string ILogTarget.Name { get => _name; }

View file

@ -12,8 +12,8 @@ namespace Ryujinx.Common.SystemInterop
public partial class StdErrAdapter : IDisposable
{
private bool _disposable;
private Stream _pipeReader;
private Stream _pipeWriter;
private FileStream _pipeReader;
private FileStream _pipeWriter;
private CancellationTokenSource _cancellationTokenSource;
private Task _worker;
@ -46,7 +46,7 @@ namespace Ryujinx.Common.SystemInterop
[SupportedOSPlatform("macos")]
private async Task EventWorkerAsync(CancellationToken cancellationToken)
{
using TextReader reader = new StreamReader(_pipeReader, leaveOpen: true);
using StreamReader reader = new StreamReader(_pipeReader, leaveOpen: true);
string line;
while (cancellationToken.IsCancellationRequested == false && (line = await reader.ReadLineAsync(cancellationToken)) != null)
{
@ -92,7 +92,7 @@ namespace Ryujinx.Common.SystemInterop
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
private static Stream CreateFileDescriptorStream(int fd)
private static FileStream CreateFileDescriptorStream(int fd)
{
return new FileStream(
new SafeFileHandle(fd, ownsHandle: true),

View file

@ -58,7 +58,7 @@ namespace Ryujinx.Common.Utilities
public static async Task<byte[]> StreamToBytesAsync(Stream input, CancellationToken cancellationToken = default)
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
await input.CopyToAsync(stream, cancellationToken);

View file

@ -55,7 +55,7 @@ namespace Ryujinx.Cpu.LightningJit
}
}
private static IStackWalker CreateStackWalker()
private static StackWalker CreateStackWalker()
{
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{

View file

@ -379,8 +379,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="hash">Code and constant buffer data hash</param>
/// <returns>Entry index</returns>
private int WriteNewEntry(
Stream tocFileStream,
Stream dataFileStream,
FileStream tocFileStream,
FileStream dataFileStream,
ref TocHeader header,
ReadOnlySpan<byte> data,
ReadOnlySpan<byte> cb1Data,

View file

@ -746,7 +746,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="magic">Magic value to be written</param>
/// <param name="codegenVersion">Shader codegen version, only valid for the host file</param>
/// <param name="timestamp">File creation timestamp</param>
private static void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp)
private static void CreateToc(FileStream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp)
{
BinarySerializer writer = new(tocFileStream);

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common;
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
@ -12,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
public static byte[] Pack(ShaderSource[] sources)
{
using MemoryStream output = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream output = MemoryStreamManager.Shared.GetStream();
output.Write(sources.Length);

View file

@ -19,18 +19,18 @@ namespace Ryujinx.Graphics.Metal
private readonly Pipeline _pipeline;
private MTLDevice _device;
private readonly ISampler _samplerLinear;
private readonly ISampler _samplerNearest;
private readonly IProgram _programColorBlitF;
private readonly IProgram _programColorBlitI;
private readonly IProgram _programColorBlitU;
private readonly IProgram _programColorBlitMsF;
private readonly IProgram _programColorBlitMsI;
private readonly IProgram _programColorBlitMsU;
private readonly SamplerHolder _samplerLinear;
private readonly SamplerHolder _samplerNearest;
private readonly Program _programColorBlitF;
private readonly Program _programColorBlitI;
private readonly Program _programColorBlitU;
private readonly Program _programColorBlitMsF;
private readonly Program _programColorBlitMsI;
private readonly Program _programColorBlitMsU;
private readonly List<IProgram> _programsColorClearF = new();
private readonly List<IProgram> _programsColorClearI = new();
private readonly List<IProgram> _programsColorClearU = new();
private readonly IProgram _programDepthStencilClear;
private readonly Program _programDepthStencilClear;
private readonly IProgram _programStrideChange;
private readonly IProgram _programConvertD32S8ToD24S8;
private readonly IProgram _programConvertIndexBuffer;

View file

@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
}
private static readonly IReadOnlyDictionary<int, AttributeEntry> _attributes;
private static readonly Dictionary<int, AttributeEntry> _attributes;
private static readonly IReadOnlyDictionary<int, AttributeEntry> _attributesPerPatch;
static AttributeMap()
@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
_attributesPerPatch = CreatePerPatchMap();
}
private static IReadOnlyDictionary<int, AttributeEntry> CreateMap()
private static Dictionary<int, AttributeEntry> CreateMap()
{
var map = new Dictionary<int, AttributeEntry>();
@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return map;
}
private static IReadOnlyDictionary<int, AttributeEntry> CreatePerPatchMap()
private static Dictionary<int, AttributeEntry> CreatePerPatchMap()
{
var map = new Dictionary<int, AttributeEntry>();

View file

@ -102,7 +102,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return false;
}
IAstNode block;
AstBlock block;
IAstNode other;
int blockLvl, otherLvl;
@ -441,7 +441,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
return path.ToArray();
}
private static int Level(IAstNode node)
private static int Level(AstBlock node)
{
int level = 0;

View file

@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
return functionId;
}
public bool TryGetFunctionId(Operation baseOp, bool isMultiTarget, IReadOnlyList<uint> targetCbs, out int functionId)
public bool TryGetFunctionId(Operation baseOp, bool isMultiTarget, List<uint> targetCbs, out int functionId)
{
foreach (Entry entry in _entries)
{

View file

@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
return x == y || x.Type == OperandType.Constant || x.Type == OperandType.ConstantBuffer;
}
private static bool AreAllSourcesEqual(INode node, INode otherNode)
private static bool AreAllSourcesEqual(Operation node, Operation otherNode)
{
if (node.SourcesCount != otherNode.SourcesCount)
{

View file

@ -32,29 +32,29 @@ namespace Ryujinx.Graphics.Vulkan
private readonly PipelineHelperShader _pipeline;
private readonly ISampler _samplerLinear;
private readonly ISampler _samplerNearest;
private readonly IProgram _programColorBlit;
private readonly IProgram _programColorBlitMs;
private readonly IProgram _programColorBlitClearAlpha;
private readonly IProgram _programColorClearF;
private readonly IProgram _programColorClearSI;
private readonly IProgram _programColorClearUI;
private readonly IProgram _programDepthStencilClear;
private readonly IProgram _programStrideChange;
private readonly IProgram _programConvertD32S8ToD24S8;
private readonly IProgram _programConvertIndexBuffer;
private readonly IProgram _programConvertIndirectData;
private readonly IProgram _programColorCopyShortening;
private readonly IProgram _programColorCopyToNonMs;
private readonly IProgram _programColorCopyWidening;
private readonly IProgram _programColorDrawToMs;
private readonly IProgram _programDepthBlit;
private readonly IProgram _programDepthBlitMs;
private readonly IProgram _programDepthDrawToMs;
private readonly IProgram _programDepthDrawToNonMs;
private readonly IProgram _programStencilBlit;
private readonly IProgram _programStencilBlitMs;
private readonly IProgram _programStencilDrawToMs;
private readonly IProgram _programStencilDrawToNonMs;
private readonly ShaderCollection _programColorBlit;
private readonly ShaderCollection _programColorBlitMs;
private readonly ShaderCollection _programColorBlitClearAlpha;
private readonly ShaderCollection _programColorClearF;
private readonly ShaderCollection _programColorClearSI;
private readonly ShaderCollection _programColorClearUI;
private readonly ShaderCollection _programDepthStencilClear;
private readonly ShaderCollection _programStrideChange;
private readonly ShaderCollection _programConvertD32S8ToD24S8;
private readonly ShaderCollection _programConvertIndexBuffer;
private readonly ShaderCollection _programConvertIndirectData;
private readonly ShaderCollection _programColorCopyShortening;
private readonly ShaderCollection _programColorCopyToNonMs;
private readonly ShaderCollection _programColorCopyWidening;
private readonly ShaderCollection _programColorDrawToMs;
private readonly ShaderCollection _programDepthBlit;
private readonly ShaderCollection _programDepthBlitMs;
private readonly ShaderCollection _programDepthDrawToMs;
private readonly ShaderCollection _programDepthDrawToNonMs;
private readonly ShaderCollection _programStencilBlit;
private readonly ShaderCollection _programStencilBlitMs;
private readonly ShaderCollection _programStencilDrawToMs;
private readonly ShaderCollection _programStencilDrawToNonMs;
public HelperShader(VulkanRenderer gd, Device device)
{

View file

@ -641,7 +641,7 @@ namespace Ryujinx.HLE.FileSystem
return file.Release();
}
private static Stream GetZipStream(ZipArchiveEntry entry)
private static MemoryStream GetZipStream(ZipArchiveEntry entry)
{
MemoryStream dest = MemoryStreamManager.Shared.GetStream();
@ -1058,7 +1058,7 @@ namespace Ryujinx.HLE.FileSystem
}
return;
bool VerifyKeys(string[] lines, string regex)
{
foreach (string line in lines)
@ -1071,7 +1071,7 @@ namespace Ryujinx.HLE.FileSystem
return true;
}
}
public bool AreKeysAlredyPresent(string pathToCheck)
{
string[] fileNames = { "prod.keys", "title.keys", "console.keys", "dev.keys" };

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
@ -63,7 +64,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser
private static byte[] BuildResponseOld(WebCommonReturnValue result)
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.WriteStruct(result);
@ -71,7 +72,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser
}
private byte[] BuildResponseNew(List<BrowserOutput> outputArguments)
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.WriteStruct(new WebArgHeader
{

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
@ -119,7 +120,7 @@ namespace Ryujinx.HLE.HOS.Applets
private static byte[] BuildResponse(ControllerSupportResultInfo result)
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.Write(MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(ref result, Unsafe.SizeOf<ControllerSupportResultInfo>())));
@ -129,7 +130,7 @@ namespace Ryujinx.HLE.HOS.Applets
private static byte[] BuildResponse()
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.Write((ulong)ResultCode.Success);

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
using Ryujinx.HLE.HOS.Applets;
@ -11,14 +12,14 @@ namespace Ryujinx.HLE.HOS.Applets.Dummy
{
private readonly Horizon _system;
private AppletSession _normalSession;
public event EventHandler AppletStateChanged;
public DummyApplet(Horizon system)
{
_system = system;
}
public ResultCode Start(AppletSession normalSession, AppletSession interactiveSession)
{
_normalSession = normalSession;
@ -27,10 +28,10 @@ namespace Ryujinx.HLE.HOS.Applets.Dummy
_system.ReturnFocus();
return ResultCode.Success;
}
private static byte[] BuildResponse()
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.Write((ulong)ResultCode.Success);
return stream.ToArray();

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common.Memory;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
@ -41,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Applets
{
UserProfile currentUser = _system.AccountManager.LastOpenedUser;
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.Write((ulong)PlayerSelectResult.Success);

View file

@ -252,7 +252,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// <exception-spec> ::= Do # non-throwing exception-specification (e.g., noexcept, throw())
// ::= DO <expression> E # computed (instantiation-dependent) noexcept
// ::= Dw <type>+ E # dynamic exception specification with instantiation-dependent types
private BaseNode ParseFunctionType()
private FunctionType ParseFunctionType()
{
Cv cvQualifiers = ParseCvQualifiers();
@ -347,7 +347,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// <array-type> ::= A <positive dimension number> _ <element type>
// ::= A [<dimension expression>] _ <element type>
private BaseNode ParseArrayType()
private ArrayType ParseArrayType()
{
if (!ConsumeIf("A"))
{
@ -945,7 +945,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
}
// <source-name> ::= <positive length number> <identifier>
private BaseNode ParseSourceName()
private NameType ParseSourceName()
{
int length = ParsePositiveNumber();
if (Count() < length || length <= 0)
@ -1320,7 +1320,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// ::= D0 # deleting destructor
// ::= D1 # complete object destructor
// ::= D2 # base object destructor
private BaseNode ParseCtorDtorName(NameParserContext context, BaseNode prev)
private CtorDtorNameType ParseCtorDtorName(NameParserContext context, BaseNode prev)
{
if (prev.Type == NodeType.SpecialSubstitution && prev is SpecialSubstitution substitution)
{
@ -1377,7 +1377,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// ::= fp <top-level CV-qualifiers> <parameter-2 non-negative number> _ # L == 0, second and later parameters
// ::= fL <L-1 non-negative number> p <top-level CV-qualifiers> _ # L > 0, first parameter
// ::= fL <L-1 non-negative number> p <top-level CV-qualifiers> <parameter-2 non-negative number> _ # L > 0, second and later parameters
private BaseNode ParseFunctionParameter()
private FunctionParameter ParseFunctionParameter()
{
if (ConsumeIf("fp"))
{
@ -1422,7 +1422,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// ::= fR <binary-operator-name> <expression> <expression>
// ::= fl <binary-operator-name> <expression>
// ::= fr <binary-operator-name> <expression>
private BaseNode ParseFoldExpression()
private FoldExpression ParseFoldExpression()
{
if (!ConsumeIf("f"))
{
@ -1571,7 +1571,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// ::= cv <type> <expression> # type (expression), conversion with one argument
// ::= cv <type> _ <expression>* E # type (expr-list), conversion with other than one argument
private BaseNode ParseConversionExpression()
private ConversionExpression ParseConversionExpression()
{
if (!ConsumeIf("cv"))
{
@ -1616,7 +1616,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return new ConversionExpression(type, new NodeArray(expressions));
}
private BaseNode ParseBinaryExpression(string name)
private BinaryExpression ParseBinaryExpression(string name)
{
BaseNode leftPart = ParseExpression();
if (leftPart == null)
@ -1633,7 +1633,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return new BinaryExpression(leftPart, name, rightPart);
}
private BaseNode ParsePrefixExpression(string name)
private PrefixExpression ParsePrefixExpression(string name)
{
BaseNode expression = ParseExpression();
if (expression == null)
@ -1720,7 +1720,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// ::= [gs] na <expression>* _ <type> <initializer> # new[] (expr-list) type (init)
//
// <initializer> ::= pi <expression>* E # parenthesized initialization
private BaseNode ParseNewExpression()
private NewExpression ParseNewExpression()
{
bool isGlobal = ConsumeIf("gs");
bool isArray = Peek(1) == 'a';
@ -2404,7 +2404,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return null;
}
private BaseNode ParseIntegerLiteral(string literalName)
private IntegerLiteral ParseIntegerLiteral(string literalName)
{
string number = ParseNumber(true);
if (number == null || number.Length == 0 || !ConsumeIf("E"))
@ -2521,7 +2521,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// <decltype> ::= Dt <expression> E # decltype of an id-expression or class member access (C++0x)
// ::= DT <expression> E # decltype of an expression (C++0x)
private BaseNode ParseDecltype()
private EnclosedExpression ParseDecltype()
{
if (!ConsumeIf("D") || (!ConsumeIf("t") && !ConsumeIf("T")))
{
@ -2588,7 +2588,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
}
// <template-args> ::= I <template-arg>+ E
private BaseNode ParseTemplateArguments(bool hasContext = false)
private TemplateArguments ParseTemplateArguments(bool hasContext = false)
{
if (!ConsumeIf("I"))
{
@ -2740,7 +2740,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// <destructor-name> ::= <unresolved-type> # e.g., ~T or ~decltype(f())
// ::= <simple-id> # e.g., ~A<2*N>
private BaseNode ParseDestructorName()
private DtorName ParseDestructorName()
{
BaseNode node;
if (char.IsDigit(Peek()))
@ -3134,7 +3134,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// <local-name> ::= Z <function encoding> E <entity name> [<discriminator>]
// ::= Z <function encoding> E s [<discriminator>]
// ::= Z <function encoding> Ed [ <parameter number> ] _ <entity name>
private BaseNode ParseLocalName(NameParserContext context)
private LocalName ParseLocalName(NameParserContext context)
{
if (!ConsumeIf("Z"))
{

View file

@ -534,7 +534,7 @@ namespace Ryujinx.HLE.HOS
return newStorage;
}
private static void AddFiles(IFileSystem fs, string modName, string rootPath, ISet<string> fileSet, RomFsBuilder builder)
private static void AddFiles(IFileSystem fs, string modName, string rootPath, HashSet<string> fileSet, RomFsBuilder builder)
{
foreach (var entry in fs.EnumerateEntries()
.AsParallel()

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common.Memory;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using System.IO;
@ -11,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage
public static byte[] MakeLaunchParams(UserProfile userProfile)
{
// Size needs to be at least 0x88 bytes otherwise application errors.
using MemoryStream ms = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream ms = MemoryStreamManager.Shared.GetStream();
BinaryWriter writer = new(ms);
ms.SetLength(0x88);

View file

@ -313,7 +313,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
return ResultCode.Success;
}
private Result SetNroMemoryPermissions(KProcess process, IExecutable relocatableObject, ulong baseAddress)
private Result SetNroMemoryPermissions(KProcess process, NroExecutable relocatableObject, ulong baseAddress)
{
ulong textStart = baseAddress + relocatableObject.TextOffset;
ulong roStart = baseAddress + relocatableObject.RoOffset;

View file

@ -5,6 +5,7 @@ using LibHac.FsSystem;
using LibHac.Ncm;
using LibHac.Tools.FsSystem;
using LibHac.Tools.FsSystem.NcaUtils;
using Microsoft.IO;
using Ryujinx.Common.Memory;
using Ryujinx.HLE.Exceptions;
using Ryujinx.HLE.FileSystem;
@ -161,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl
static uint KXor(uint data) => data ^ FontKey;
using BinaryReader reader = new(bfttfStream);
using MemoryStream ttfStream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream ttfStream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter output = new(ttfStream);
if (KXor(reader.ReadUInt32()) != BFTTFMagic)

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
@ -46,10 +47,10 @@ namespace Ryujinx.HLE.HOS.Services
private readonly Dictionary<int, IpcService> _sessions = new();
private readonly Dictionary<int, Func<IpcService>> _ports = new();
private readonly MemoryStream _requestDataStream;
private readonly RecyclableMemoryStream _requestDataStream;
private readonly BinaryReader _requestDataReader;
private readonly MemoryStream _responseDataStream;
private readonly RecyclableMemoryStream _responseDataStream;
private readonly BinaryWriter _responseDataWriter;
private int _isDisposed = 0;

View file

@ -95,7 +95,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
}
}
ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol, context.Device.Configuration.MultiplayerLanInterfaceId)
ManagedSocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol, context.Device.Configuration.MultiplayerLanInterfaceId)
{
Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking),
};

View file

@ -415,7 +415,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
return true;
}
private static IList<ArraySegment<byte>> ConvertMessagesToBuffer(BsdMMsgHdr message)
private static ArraySegment<byte>[] ConvertMessagesToBuffer(BsdMMsgHdr message)
{
int segmentCount = 0;
int index = 0;

View file

@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
private SessionCacheMode _sessionCacheMode;
private string _hostName;
private ISslConnectionBase _connection;
private SslManagedSocketConnection _connection;
private BsdContext _bsdContext;
private readonly ulong _processId;

View file

@ -54,7 +54,7 @@ namespace Ryujinx.HLE.HOS.Tamper
return null;
}
private ITamperProgram CompileImpl(string name, IEnumerable<string> rawInstructions)
private AtmosphereProgram CompileImpl(string name, IEnumerable<string> rawInstructions)
{
CompilationContext context = new(_exeAddress, _heapAddress, _aliasAddress, _aslrAddress, _process);
context.BlockStack.Push(new OperationBlock(null));

View file

@ -5,7 +5,7 @@ namespace Ryujinx.Horizon.Common
static class ResultNames
{
// Reference: https://github.com/Thealexbarney/LibHac/blob/master/build/CodeGen/results.csv
private static readonly IReadOnlyDictionary<int, string> _names = new Dictionary<int, string>()
private static readonly Dictionary<int, string> _names = new Dictionary<int, string>()
{
{ 0x0, "Success" },
{ 0xE01, "OutOfSessions" },

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common;
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller;
@ -380,7 +381,7 @@ namespace Ryujinx.Input.Motion.CemuHook
Header header = GenerateHeader(clientId);
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.WriteStruct(header);
@ -419,7 +420,7 @@ namespace Ryujinx.Input.Motion.CemuHook
Header header = GenerateHeader(clientId);
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.WriteStruct(header);

View file

@ -261,7 +261,7 @@ namespace Ryujinx.Ava.UI.Helpers
string.Empty,
LocaleManager.Instance[LocaleKeys.InputDialogOk],
(int)Symbol.Important);
internal static async Task<UserResult> CreateUpdaterUpToDateInfoDialog(string primary, string secondaryText)
=> await ShowTextDialog(
LocaleManager.Instance[LocaleKeys.DialogUpdaterTitle],
@ -319,7 +319,7 @@ namespace Ryujinx.Ava.UI.Helpers
return response == UserResult.Yes;
}
internal static async Task<UserResult> CreateUpdaterChoiceDialog(string title, string primary, string secondaryText)
{
if (_isChoiceDialogOpen)
@ -456,7 +456,7 @@ namespace Ryujinx.Ava.UI.Helpers
await dialogWindow.ShowDialog(_contentDialogOverlayWindow ?? mainWindow ?? GetMainWindow());
}
private static Window GetMainWindow()
private static MainWindow GetMainWindow()
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime al)
{

View file

@ -116,7 +116,7 @@ namespace Ryujinx.Ava.UI.Renderer
}
[SupportedOSPlatform("linux")]
private IPlatformHandle CreateLinux(IPlatformHandle control)
private PlatformHandle CreateLinux(IPlatformHandle control)
{
if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan)
{
@ -135,7 +135,7 @@ namespace Ryujinx.Ava.UI.Renderer
}
[SupportedOSPlatform("windows")]
IPlatformHandle CreateWin32(IPlatformHandle control)
PlatformHandle CreateWin32(IPlatformHandle control)
{
_className = "NativeWindow-" + Guid.NewGuid();
@ -172,7 +172,7 @@ namespace Ryujinx.Ava.UI.Renderer
}
[SupportedOSPlatform("macos")]
IPlatformHandle CreateMacOS()
PlatformHandle CreateMacOS()
{
// Create a new CAMetalLayer.
ObjectiveC.Object layerObject = new("CAMetalLayer");

View file

@ -105,7 +105,7 @@ namespace Ryujinx.Ava.UI.ViewModels
[ObservableProperty] private bool _isSubMenuOpen;
[ObservableProperty] private ApplicationContextMenu _listAppContextMenu;
[ObservableProperty] private ApplicationContextMenu _gridAppContextMenu;
private bool _showLoadProgress;
private bool _isGameRunning;
private bool _isAmiiboRequested;
@ -126,7 +126,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private int _customVSyncIntervalPercentageProxy;
private ApplicationData _listSelectedApplication;
private ApplicationData _gridSelectedApplication;
// Key is Title ID
public SafeDictionary<string, LdnGameData.Array> LdnData = [];
@ -299,7 +299,7 @@ namespace Ryujinx.Ava.UI.ViewModels
OnPropertyChanged(nameof(ShowFirmwareStatus));
}
}
public ApplicationData ListSelectedApplication
{
get => _listSelectedApplication;
@ -332,7 +332,7 @@ namespace Ryujinx.Ava.UI.ViewModels
else if (_gridSelectedApplication == null && _gridAppContextMenu != null)
GridAppContextMenu = null!;
#pragma warning restore MVVMTK0034
OnPropertyChanged();
}
}
@ -358,7 +358,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool OpenBcatSaveDirectoryEnabled => SelectedApplication.HasControlHolder && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0;
public bool ShowCustomVSyncIntervalPicker
public bool ShowCustomVSyncIntervalPicker
=> _isGameRunning && AppHost.Device.VSyncMode == VSyncMode.Custom;
public void UpdateVSyncIntervalPicker()
@ -529,7 +529,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool ShowNames
{
get => ConfigurationState.Instance.UI.ShowNames && ConfigurationState.Instance.UI.GridSize > 1;
get => ConfigurationState.Instance.UI.ShowNames && ConfigurationState.Instance.UI.GridSize > 1;
set
{
ConfigurationState.Instance.UI.ShowNames.Value = value;
@ -710,7 +710,7 @@ namespace Ryujinx.Ava.UI.ViewModels
#region PrivateMethods
private static IComparer<ApplicationData> CreateComparer(bool ascending, Func<ApplicationData, IComparable> selector) =>
private static SortExpressionComparer<ApplicationData> CreateComparer(bool ascending, Func<ApplicationData, IComparable> selector) =>
ascending
? SortExpressionComparer<ApplicationData>.Ascending(selector)
: SortExpressionComparer<ApplicationData>.Descending(selector);
@ -818,10 +818,10 @@ namespace Ryujinx.Ava.UI.ViewModels
string message = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogFirmwareInstallerFirmwareInstallSuccessMessage, firmwareVersion.VersionString);
await ContentDialogHelper.CreateInfoDialog(
dialogTitle,
message,
LocaleManager.Instance[LocaleKeys.InputDialogOk],
string.Empty,
dialogTitle,
message,
LocaleManager.Instance[LocaleKeys.InputDialogOk],
string.Empty,
LocaleManager.Instance[LocaleKeys.RyujinxInfo]);
Logger.Info?.Print(LogClass.Application, message);
@ -1134,11 +1134,11 @@ namespace Ryujinx.Ava.UI.ViewModels
{
await ContentDialogHelper.ShowTextDialog(
LocaleManager.Instance[numAdded > 0 || numRemoved > 0 ? LocaleKeys.RyujinxConfirm : LocaleKeys.RyujinxInfo],
msg,
string.Empty,
string.Empty,
string.Empty,
LocaleManager.Instance[LocaleKeys.InputDialogOk],
msg,
string.Empty,
string.Empty,
string.Empty,
LocaleManager.Instance[LocaleKeys.InputDialogOk],
(int)Symbol.Checkmark);
});
}

View file

@ -179,17 +179,17 @@ namespace Ryujinx.Ava.UI.ViewModels
ApplicationLibrary.SaveTitleUpdatesForGame(ApplicationData, updates);
}
private Task ShowNewUpdatesAddedDialog(int numAdded)
private Task<UserResult> ShowNewUpdatesAddedDialog(int numAdded)
{
var msg = string.Format(LocaleManager.Instance[LocaleKeys.UpdateWindowUpdateAddedMessage], numAdded);
return Dispatcher.UIThread.InvokeAsync(async () =>
return Dispatcher.UIThread.InvokeAsync(async () =>
await ContentDialogHelper.ShowTextDialog(
LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle],
msg,
string.Empty,
string.Empty,
string.Empty,
LocaleManager.Instance[LocaleKeys.InputDialogOk],
LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle],
msg,
string.Empty,
string.Empty,
string.Empty,
LocaleManager.Instance[LocaleKeys.InputDialogOk],
(int)Symbol.Checkmark
));
}

View file

@ -128,7 +128,7 @@ namespace Ryujinx.Ava.UI.ViewModels
}
}
private static byte[] DecompressYaz0(Stream stream)
private static byte[] DecompressYaz0(MemoryStream stream)
{
using BinaryReader reader = new(stream);

View file

@ -60,7 +60,7 @@ namespace Ryujinx.Ava.UI.ViewModels
return false;
}
private IComparer<SaveModel> GetComparer()
private SortExpressionComparer<SaveModel> GetComparer()
{
return SortIndex switch
{

View file

@ -15,7 +15,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
public partial class SettingsHotkeysView : UserControl
{
private ButtonKeyAssigner _currentAssigner;
private readonly IGamepadDriver _avaloniaKeyboardDriver;
private readonly AvaloniaKeyboardDriver _avaloniaKeyboardDriver;
public SettingsHotkeysView()
{

View file

@ -32,9 +32,9 @@ namespace Ryujinx.Ava
internal static class Updater
{
private const string GitHubApiUrl = "https://api.github.com";
private const string LatestReleaseUrl =
private const string LatestReleaseUrl =
$"{GitHubApiUrl}/repos/{ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo}/releases/latest";
private static readonly GithubReleasesJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static readonly string _homeDir = AppDomain.CurrentDomain.BaseDirectory;
@ -92,7 +92,7 @@ namespace Ryujinx.Ava
try
{
using HttpClient jsonClient = ConstructHttpClient();
string fetchedJson = await jsonClient.GetStringAsync(LatestReleaseUrl);
var fetched = JsonHelper.Deserialize(fetchedJson, _serializerContext.GithubReleasesJsonResponse);
_buildVer = fetched.TagName;
@ -213,7 +213,7 @@ namespace Ryujinx.Ava
string newVersionString = ReleaseInformation.IsCanaryBuild
? $"Canary {currentVersion} -> Canary {newVersion}"
: $"{currentVersion} -> {newVersion}";
RequestUserToUpdate:
// Show a message asking the user if they want to update
UserResult shouldUpdate = await ContentDialogHelper.CreateUpdaterChoiceDialog(
@ -472,7 +472,7 @@ namespace Ryujinx.Ava
using HttpResponseMessage response = client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead).Result;
using Stream remoteFileStream = response.Content.ReadAsStreamAsync().Result;
using Stream updateFileStream = File.Open(updateFile, FileMode.Create);
using FileStream updateFileStream = File.Open(updateFile, FileMode.Create);
long totalBytes = response.Content.Headers.ContentLength.Value;
long bytesWritten = 0;
@ -519,7 +519,7 @@ namespace Ryujinx.Ava
[SupportedOSPlatform("macos")]
private static void ExtractTarGzipFile(TaskDialog taskDialog, string archivePath, string outputDirectoryPath)
{
using Stream inStream = File.OpenRead(archivePath);
using FileStream inStream = File.OpenRead(archivePath);
using GZipInputStream gzipStream = new(inStream);
using TarInputStream tarStream = new(gzipStream, Encoding.ASCII);