[Ryujinx.Horizon] Address dotnet-format issues (#5381)

* dotnet format style --severity info

Some changes were manually reverted.

* dotnet format analyzers --serverity info

Some changes have been minimally adapted.

* Restore a few unused methods and variables

* Silence dotnet format IDE0060 warnings

* Silence dotnet format IDE0052 warnings

* Address dotnet format CA1822 warnings

* Address most dotnet format whitespace warnings

* Apply dotnet format whitespace formatting

A few of them have been manually reverted and the corresponding warning was silenced

* Revert formatting changes for while and for-loops

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Add comments to disabled warnings

* Remove a few unused parameters

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Address IDE0251 warnings

* Silence IDE0060 in .editorconfig

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* First dotnet format pass

* Add trailing commas and fix formatting issues

* Convert if-else chain to switch block

* Address review feedback
This commit is contained in:
TSRBerry
2023-07-01 12:42:10 +02:00
committed by GitHub
parent 801b71a128
commit 02b5c7ea89
105 changed files with 617 additions and 637 deletions

View File

@@ -10,6 +10,7 @@ using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
using System;
using System.Text;
using ApplicationId = Ryujinx.Horizon.Sdk.Ncm.ApplicationId;
namespace Ryujinx.Horizon.Prepo.Ipc
{
@@ -18,14 +19,14 @@ namespace Ryujinx.Horizon.Prepo.Ipc
enum PlayReportKind
{
Normal,
System
System,
}
private readonly PrepoServicePermissionLevel _permissionLevel;
private ulong _systemSessionId;
private bool _immediateTransmissionEnabled = false;
private bool _userAgreementCheckEnabled = true;
private bool _immediateTransmissionEnabled;
private bool _userAgreementCheckEnabled = true;
public PrepoService(PrepoServicePermissionLevel permissionLevel)
{
@@ -107,7 +108,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc
}
[CmifCommand(20100)]
public Result SaveSystemReport([Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<byte> gameRoomBuffer, Sdk.Ncm.ApplicationId applicationId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> reportBuffer)
public Result SaveSystemReport([Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<byte> gameRoomBuffer, ApplicationId applicationId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> reportBuffer)
{
if ((_permissionLevel & PrepoServicePermissionLevel.System) != 0)
{
@@ -118,7 +119,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc
}
[CmifCommand(20101)]
public Result SaveSystemReportWithUser(Uid userId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<byte> gameRoomBuffer, Sdk.Ncm.ApplicationId applicationId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> reportBuffer)
public Result SaveSystemReportWithUser(Uid userId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<byte> gameRoomBuffer, ApplicationId applicationId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> reportBuffer)
{
if ((_permissionLevel & PrepoServicePermissionLevel.System) != 0)
{
@@ -164,7 +165,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc
return PrepoResult.PermissionDenied;
}
private static Result ProcessPlayReport(PlayReportKind playReportKind, ReadOnlySpan<byte> gameRoomBuffer, ReadOnlySpan<byte> reportBuffer, ulong pid, Uid userId, bool withUserId = false, Sdk.Ncm.ApplicationId applicationId = default)
private static Result ProcessPlayReport(PlayReportKind playReportKind, ReadOnlySpan<byte> gameRoomBuffer, ReadOnlySpan<byte> reportBuffer, ulong pid, Uid userId, bool withUserId = false, ApplicationId applicationId = default)
{
if (withUserId)
{
@@ -191,7 +192,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc
return PrepoResult.InvalidBufferSize;
}
StringBuilder builder = new();
StringBuilder builder = new();
MessagePackObject deserializedReport = MessagePackSerializer.UnpackMessagePackObject(reportBuffer.ToArray());
builder.AppendLine();
@@ -222,4 +223,4 @@ namespace Ryujinx.Horizon.Prepo.Ipc
return Result.Success;
}
}
}
}

View File

@@ -6,13 +6,13 @@ namespace Ryujinx.Horizon.Prepo
{
class PrepoIpcServer
{
private const int PrepoMaxSessionsCount = 12;
private const int PrepoMaxSessionsCount = 12;
private const int PrepoTotalMaxSessionsCount = PrepoMaxSessionsCount * 6;
private const int PointerBufferSize = 0x80;
private const int MaxDomains = 64;
private const int MaxDomainObjects = 16;
private const int MaxPortsCount = 6;
private const int MaxDomains = 64;
private const int MaxDomainObjects = 16;
private const int MaxPortsCount = 6;
private static readonly ManagerOptions _prepoManagerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
@@ -28,12 +28,14 @@ namespace Ryujinx.Horizon.Prepo
_serverManager = new PrepoServerManager(allocator, _sm, MaxPortsCount, _prepoManagerOptions, PrepoTotalMaxSessionsCount);
#pragma warning disable IDE0055 // Disable formatting
_serverManager.RegisterServer((int)PrepoPortIndex.Admin, ServiceName.Encode("prepo:a"), PrepoMaxSessionsCount); // 1.0.0-5.1.0
_serverManager.RegisterServer((int)PrepoPortIndex.Admin2, ServiceName.Encode("prepo:a2"), PrepoMaxSessionsCount); // 6.0.0+
_serverManager.RegisterServer((int)PrepoPortIndex.Manager, ServiceName.Encode("prepo:m"), PrepoMaxSessionsCount);
_serverManager.RegisterServer((int)PrepoPortIndex.User, ServiceName.Encode("prepo:u"), PrepoMaxSessionsCount);
_serverManager.RegisterServer((int)PrepoPortIndex.System, ServiceName.Encode("prepo:s"), PrepoMaxSessionsCount);
_serverManager.RegisterServer((int)PrepoPortIndex.Debug, ServiceName.Encode("prepo:d"), PrepoMaxSessionsCount); // 1.0.0
#pragma warning restore IDE0055
}
public void ServiceRequests()
@@ -46,4 +48,4 @@ namespace Ryujinx.Horizon.Prepo
_serverManager.Dispose();
}
}
}
}

View File

@@ -14,4 +14,4 @@
ipcServer.Shutdown();
}
}
}
}

View File

@@ -6,10 +6,12 @@ namespace Ryujinx.Horizon.Prepo
{
private const int ModuleId = 129;
#pragma warning disable IDE0055 // Disable formatting
public static Result InvalidArgument => new(ModuleId, 1);
public static Result InvalidState => new(ModuleId, 5);
public static Result InvalidBufferSize => new(ModuleId, 9);
public static Result PermissionDenied => new(ModuleId, 90);
public static Result InvalidPid => new(ModuleId, 101);
#pragma warning restore IDE0055
}
}
}

View File

@@ -17,6 +17,7 @@ namespace Ryujinx.Horizon.Prepo
{
return (PrepoPortIndex)portIndex switch
{
#pragma warning disable IDE0055 // Disable formatting
PrepoPortIndex.Admin => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.Admin)),
PrepoPortIndex.Admin2 => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.Admin)),
PrepoPortIndex.Manager => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.Manager)),
@@ -24,7 +25,8 @@ namespace Ryujinx.Horizon.Prepo
PrepoPortIndex.System => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.System)),
PrepoPortIndex.Debug => AcceptImpl(server, new PrepoService(PrepoServicePermissionLevel.Debug)),
_ => throw new ArgumentOutOfRangeException(nameof(portIndex)),
#pragma warning restore IDE0055
};
}
}
}
}

View File

@@ -7,6 +7,6 @@
Manager,
User,
System,
Debug
Debug,
}
}
}

View File

@@ -2,10 +2,10 @@
{
enum PrepoServicePermissionLevel
{
Admin = -1,
User = 1,
System = 2,
Admin = -1,
User = 1,
System = 2,
Manager = 6,
Debug = unchecked((int)0x80000006)
Debug = unchecked((int)0x80000006),
}
}
}