misc: chore: Fix object creation

This commit is contained in:
KeatonTheBot
2025-09-24 13:44:00 -05:00
parent 378dc33cca
commit 1f979e5c6f
42 changed files with 303 additions and 304 deletions
@@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser
{
List<BrowserOutput> result =
[
new BrowserOutput(BrowserOutputType.ExitReason, (uint)WebExitReason.ExitButton)
new(BrowserOutputType.ExitReason, (uint)WebExitReason.ExitButton)
];
_normalSession.Push(BuildResponseNew(result));
@@ -85,7 +85,7 @@ namespace Ryujinx.HLE.HOS.Applets.Cabinet
{
_system.Device.UIHandler.DisplayCabinetDialog(out string newName);
byte[] nameBytes = Encoding.UTF8.GetBytes(newName);
Array41<byte> nickName = new Array41<byte>();
Array41<byte> nickName = new();
nameBytes.CopyTo(nickName.AsSpan());
startParam.RegisterInfo.Nickname = nickName;
NfpDevice devicePlayer1 = new()
@@ -60,7 +60,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
}
}
public void AddUser(string name, byte[] image, UserId userId = new UserId())
public void AddUser(string name, byte[] image, UserId userId = new())
{
if (userId.IsNull)
{
@@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
{
public bool NeedsRealId => true;
private static InitializeMessage InitializeMemory = new InitializeMessage();
private static InitializeMessage InitializeMemory = new();
private const int InactiveTimeout = 6000;
private const int FailureTimeout = 4000;
@@ -31,11 +31,11 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
private bool _useP2pProxy;
private NetworkError _lastError;
private readonly ManualResetEvent _connected = new ManualResetEvent(false);
private readonly ManualResetEvent _error = new ManualResetEvent(false);
private readonly ManualResetEvent _scan = new ManualResetEvent(false);
private readonly ManualResetEvent _reject = new ManualResetEvent(false);
private readonly AutoResetEvent _apConnected = new AutoResetEvent(false);
private readonly ManualResetEvent _connected = new(false);
private readonly ManualResetEvent _error = new(false);
private readonly ManualResetEvent _scan = new(false);
private readonly ManualResetEvent _reject = new(false);
private readonly AutoResetEvent _apConnected = new(false);
private readonly RyuLdnProtocol _protocol;
private readonly NetworkTimeout _timeout;
@@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
public IPAddress LocalAddress { get; }
private readonly List<LdnProxySocket> _sockets = [];
private readonly Dictionary<ProtocolType, EphemeralPortPool> _ephemeralPorts = new Dictionary<ProtocolType, EphemeralPortPool>();
private readonly Dictionary<ProtocolType, EphemeralPortPool> _ephemeralPorts = new();
private readonly IProxyClient _parent;
private RyuLdnProtocol _protocol;
@@ -132,7 +132,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
public void HandleData(LdnHeader header, ProxyDataHeader proxyHeader, byte[] data)
{
ProxyDataPacket packet = new ProxyDataPacket() { Header = proxyHeader, Data = data };
ProxyDataPacket packet = new() { Header = proxyHeader, Data = data };
ForRoutedSockets(proxyHeader.Info, (socket) =>
{
@@ -179,7 +179,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
{
// We must ask the other side to initialize a connection, so they can accept a socket for us.
ProxyConnectRequest request = new ProxyConnectRequest
ProxyConnectRequest request = new()
{
Info = MakeInfo(localEp, remoteEp, type)
};
@@ -191,7 +191,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
{
// We must tell the other side that we have accepted their request for connection.
ProxyConnectResponse request = new ProxyConnectResponse
ProxyConnectResponse request = new()
{
Info = MakeInfo(localEp, remoteEp, type)
};
@@ -203,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
{
// We must tell the other side that our connection is dropped.
ProxyDisconnectMessage request = new ProxyDisconnectMessage
ProxyDisconnectMessage request = new()
{
Info = MakeInfo(localEp, remoteEp, type),
DisconnectReason = 0 // TODO
@@ -217,7 +217,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
// We send exactly as much as the user wants us to, currently instantly.
// TODO: handle over "virtual mtu" (we have a max packet size to worry about anyways). fragment if tcp? throw if udp?
ProxyDataHeader request = new ProxyDataHeader
ProxyDataHeader request = new()
{
Info = MakeInfo(localEp, remoteEp, type),
DataLength = (uint)buffer.Length
@@ -20,19 +20,19 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private bool _isListening;
private readonly List<LdnProxySocket> _listenSockets = [];
private readonly Queue<ProxyConnectRequest> _connectRequests = new Queue<ProxyConnectRequest>();
private readonly Queue<ProxyConnectRequest> _connectRequests = new();
private readonly AutoResetEvent _acceptEvent = new AutoResetEvent(false);
private readonly AutoResetEvent _acceptEvent = new(false);
private readonly int _acceptTimeout = -1;
private readonly Queue<int> _errors = new Queue<int>();
private readonly Queue<int> _errors = new();
private readonly AutoResetEvent _connectEvent = new AutoResetEvent(false);
private readonly AutoResetEvent _connectEvent = new(false);
private ProxyConnectResponse _connectResponse;
private int _receiveTimeout = -1;
private readonly AutoResetEvent _receiveEvent = new AutoResetEvent(false);
private readonly Queue<ProxyDataPacket> _receiveQueue = new Queue<ProxyDataPacket>();
private readonly AutoResetEvent _receiveEvent = new(false);
private readonly Queue<ProxyDataPacket> _receiveQueue = new();
// private int _sendTimeout = -1; // Sends are techically instant right now, so not _really_ used.
@@ -42,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
// private bool _writeShutdown;
private bool _closed;
private readonly Dictionary<SocketOptionName, int> _socketOptions = new Dictionary<SocketOptionName, int>()
private readonly Dictionary<SocketOptionName, int> _socketOptions = new()
{
{ SocketOptionName.Broadcast, 0 }, //TODO: honor this value
{ SocketOptionName.DontLinger, 0 },
@@ -147,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
}
}
IPEndPoint localEp = new IPEndPoint(_proxy.LocalAddress, _proxy.GetEphemeralPort(ProtocolType));
IPEndPoint localEp = new(_proxy.LocalAddress, _proxy.GetEphemeralPort(ProtocolType));
LocalEndPoint = localEp;
return localEp;
@@ -16,9 +16,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private readonly RyuLdnProtocol _protocol;
private readonly ManualResetEvent _connected = new ManualResetEvent(false);
private readonly ManualResetEvent _ready = new ManualResetEvent(false);
private readonly AutoResetEvent _error = new AutoResetEvent(false);
private readonly ManualResetEvent _connected = new(false);
private readonly ManualResetEvent _ready = new(false);
private readonly AutoResetEvent _error = new(false);
public P2pProxyClient(string address, int port) : base(address, port)
{
@@ -27,14 +27,14 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private const ushort AuthWaitSeconds = 1;
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
private readonly ReaderWriterLockSlim _lock = new(LockRecursionPolicy.SupportsRecursion);
public ushort PrivatePort { get; }
private ushort _publicPort;
private bool _disposed;
private readonly CancellationTokenSource _disposedCancellation = new CancellationTokenSource();
private readonly CancellationTokenSource _disposedCancellation = new();
private NatDevice _natDevice;
private Mapping _portMapping;
@@ -42,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private readonly List<P2pProxySession> _players = [];
private readonly List<ExternalProxyToken> _waitingTokens = [];
private readonly AutoResetEvent _tokenEvent = new AutoResetEvent(false);
private readonly AutoResetEvent _tokenEvent = new(false);
private uint _broadcastAddress;
@@ -110,8 +110,8 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
public async Task<ushort> NatPunch()
{
NatDiscoverer discoverer = new NatDiscoverer();
CancellationTokenSource cts = new CancellationTokenSource(2500);
NatDiscoverer discoverer = new();
CancellationTokenSource cts = new(2500);
NatDevice device;
@@ -292,7 +292,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
session.SetIpv4(waitToken.VirtualIp);
ProxyConfig pconfig = new ProxyConfig
ProxyConfig pconfig = new()
{
ProxyIp = session.VirtualIpAddress,
ProxySubnetMask = 0xFFFF0000 // TODO: Use from server.
@@ -131,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
string nickName = amiiboDump.AmiiboNickname;
LogFinalData(titleId, appId, head, tail, finalID, nickName, initDateTime, writeDateTime, settingsValue, writeCounterValue, applicationAreas);
VirtualAmiiboFile virtualAmiiboFile = new VirtualAmiiboFile
VirtualAmiiboFile virtualAmiiboFile = new()
{
FileVersion = 1,
TagUuid = uid,
@@ -182,7 +182,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
readBytes = newFileBytes;
}
AmiiboDecryptor amiiboDecryptor = new AmiiboDecryptor(keyRetailBinPath);
AmiiboDecryptor amiiboDecryptor = new(keyRetailBinPath);
AmiiboDump amiiboDump = amiiboDecryptor.DecryptAmiiboDump(readBytes);
byte[] oldData = amiiboDump.GetData();
@@ -250,7 +250,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
readBytes = newFileBytes;
}
AmiiboDecryptor amiiboDecryptor = new AmiiboDecryptor(keyRetailBinPath);
AmiiboDecryptor amiiboDecryptor = new(keyRetailBinPath);
AmiiboDump amiiboDump = amiiboDecryptor.DecryptAmiiboDump(readBytes);
amiiboDump.AmiiboNickname = newNickName;
byte[] oldData = amiiboDump.GetData();
@@ -33,8 +33,8 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
byte[] dataBin = combinedBin.Take(80).ToArray();
byte[] tagBin = combinedBin.Skip(80).Take(80).ToArray();
AmiiboMasterKey dataKey = new AmiiboMasterKey(dataBin);
AmiiboMasterKey tagKey = new AmiiboMasterKey(tagBin);
AmiiboMasterKey dataKey = new(dataBin);
AmiiboMasterKey tagKey = new(tagBin);
return (dataKey, tagKey);
}
@@ -34,8 +34,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
private static readonly VmRegion[] _vmRegions =
[
new VmRegion((ulong)BigPageSize << 16, SmallRegionLimit),
new VmRegion(SmallRegionLimit, DefaultUserSize)
new((ulong)BigPageSize << 16, SmallRegionLimit),
new(SmallRegionLimit, DefaultUserSize)
];
private readonly AddressSpaceContext _asContext;