[Ryujinx.HLE] Address dotnet-format issues (#5380)

* 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 or silence dotnet format IDE1006 warnings

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA2208 warnings

* Address or silence dotnet format CA1806 and a few CA1854 warnings

* Address dotnet format CA2211 warnings

* Address dotnet format CA1822 warnings

* Address or silence dotnet format CA1069 warnings

* Make dotnet format succeed in style mode

* Address or silence dotnet format CA2211 warnings

* Address review comments

* Address dotnet format CA2208 warnings properly

* Make ProcessResult readonly

* 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

* Add previously silenced warnings back

I have no clue how these disappeared

* Revert formatting changes for while and for-loops

* Format if-blocks correctly

* Run dotnet format style after rebase

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Run dotnet format analyzers after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Disable 'prefer switch expression' rule

* Add comments to disabled warnings

* Fix a few disabled warnings

* Fix naming rule violation, Convert shader properties to auto-property and convert values to const

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

* Start working on disabled warnings

* Fix and silence a few dotnet-format warnings again

* Run dotnet format after rebase

* Use using declaration instead of block syntax

* Address IDE0251 warnings

* Address a few disabled IDE0060 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

* Fix naming rule violations

* Fix typo

* Add trailing commas, use targeted new and use array initializer

* Fix build issues

* Fix remaining build issues

* Remove SuppressMessage for CA1069 where possible

* Address dotnet format issues

* Address formatting issues

Co-authored-by: Ac_K <acoustik666@gmail.com>

* Add GetHashCode implementation for RenderingSurfaceInfo

* Explicitly silence CA1822 for every affected method in Syscall

* Address formatting issues in Demangler.cs

* Address review feedback

Co-authored-by: Ac_K <acoustik666@gmail.com>

* Revert marking service methods as static

* Next dotnet format pass

* Address review feedback

---------

Co-authored-by: Ac_K <acoustik666@gmail.com>
This commit is contained in:
TSRBerry
2023-07-16 19:31:14 +02:00
committed by GitHub
parent fec8291c17
commit 326749498b
1015 changed files with 8173 additions and 7615 deletions

View File

@@ -25,13 +25,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv
[Service("nvdrv:t")]
class INvDrvServices : IpcService
{
private static readonly List<string> _deviceFileDebugRegistry = new List<string>()
private static readonly List<string> _deviceFileDebugRegistry = new()
{
"/dev/nvhost-dbg-gpu",
"/dev/nvhost-prof-gpu"
"/dev/nvhost-prof-gpu",
};
private static readonly Dictionary<string, Type> _deviceFileRegistry = new Dictionary<string, Type>()
private static readonly Dictionary<string, Type> _deviceFileRegistry = new()
{
{ "/dev/nvmap", typeof(NvMapDeviceFile) },
{ "/dev/nvhost-ctrl", typeof(NvHostCtrlDeviceFile) },
@@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
{ "/dev/nvhost-prof-gpu", typeof(NvHostProfGpuDeviceFile) },
};
public static IdDictionary DeviceFileIdRegistry = new IdDictionary();
public static IdDictionary DeviceFileIdRegistry = new();
private IVirtualMemoryManager _clientMemory;
private ulong _owner;
@@ -55,7 +55,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
private bool _transferMemInitialized = false;
// TODO: This should call set:sys::GetDebugModeFlag
private bool _debugModeEnabled = false;
private readonly bool _debugModeEnabled = false;
public INvDrvServices(ServiceCtx context) : base(context.Device.System.NvDrvServer)
{
@@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (_deviceFileRegistry.TryGetValue(path, out Type deviceFileClass))
{
ConstructorInfo constructor = deviceFileClass.GetConstructor(new Type[] { typeof(ServiceCtx), typeof(IVirtualMemoryManager), typeof(ulong) });
ConstructorInfo constructor = deviceFileClass.GetConstructor(new[] { typeof(ServiceCtx), typeof(IVirtualMemoryManager), typeof(ulong) });
NvDeviceFile deviceFile = (NvDeviceFile)constructor.Invoke(new object[] { context, _clientMemory, _owner });
@@ -91,13 +91,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv
private NvResult GetIoctlArgument(ServiceCtx context, NvIoctl ioctlCommand, out Span<byte> arguments)
{
(ulong inputDataPosition, ulong inputDataSize) = context.Request.GetBufferType0x21(0);
(ulong inputDataPosition, ulong inputDataSize) = context.Request.GetBufferType0x21(0);
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong outputDataPosition, ulong outputDataSize) = context.Request.GetBufferType0x22(0);
#pragma warning restore IDE0059
NvIoctl.Direction ioctlDirection = ioctlCommand.DirectionValue;
uint ioctlSize = ioctlCommand.Size;
uint ioctlSize = ioctlCommand.Size;
bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0;
bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0;
bool isWrite = (ioctlDirection & NvIoctl.Direction.Write) != 0;
if ((isWrite && ioctlSize > outputDataSize) || (isRead && ioctlSize > inputDataSize))
@@ -186,53 +188,29 @@ namespace Ryujinx.HLE.HOS.Services.Nv
return NvResult.Success;
}
private static NvResult ConvertInternalErrorCode(NvInternalResult errorCode)
private NvResult ConvertInternalErrorCode(NvInternalResult errorCode)
{
switch (errorCode)
return errorCode switch
{
case NvInternalResult.Success:
return NvResult.Success;
case NvInternalResult.Unknown0x72:
return NvResult.AlreadyAllocated;
case NvInternalResult.TimedOut:
case NvInternalResult.TryAgain:
case NvInternalResult.Interrupted:
return NvResult.Timeout;
case NvInternalResult.InvalidAddress:
return NvResult.InvalidAddress;
case NvInternalResult.NotSupported:
case NvInternalResult.Unknown0x18:
return NvResult.NotSupported;
case NvInternalResult.InvalidState:
return NvResult.InvalidState;
case NvInternalResult.ReadOnlyAttribute:
return NvResult.ReadOnlyAttribute;
case NvInternalResult.NoSpaceLeft:
case NvInternalResult.FileTooBig:
return NvResult.InvalidSize;
case NvInternalResult.FileTableOverflow:
case NvInternalResult.BadFileNumber:
return NvResult.FileOperationFailed;
case NvInternalResult.InvalidInput:
return NvResult.InvalidValue;
case NvInternalResult.NotADirectory:
return NvResult.DirectoryOperationFailed;
case NvInternalResult.Busy:
return NvResult.Busy;
case NvInternalResult.BadAddress:
return NvResult.InvalidAddress;
case NvInternalResult.AccessDenied:
case NvInternalResult.OperationNotPermitted:
return NvResult.AccessDenied;
case NvInternalResult.OutOfMemory:
return NvResult.InsufficientMemory;
case NvInternalResult.DeviceNotFound:
return NvResult.ModuleNotPresent;
case NvInternalResult.IoError:
return NvResult.ResourceError;
default:
return NvResult.IoctlFailed;
}
NvInternalResult.Success => NvResult.Success,
NvInternalResult.Unknown0x72 => NvResult.AlreadyAllocated,
NvInternalResult.TimedOut or NvInternalResult.TryAgain or NvInternalResult.Interrupted => NvResult.Timeout,
NvInternalResult.InvalidAddress => NvResult.InvalidAddress,
NvInternalResult.NotSupported or NvInternalResult.Unknown0x18 => NvResult.NotSupported,
NvInternalResult.InvalidState => NvResult.InvalidState,
NvInternalResult.ReadOnlyAttribute => NvResult.ReadOnlyAttribute,
NvInternalResult.NoSpaceLeft or NvInternalResult.FileTooBig => NvResult.InvalidSize,
NvInternalResult.FileTableOverflow or NvInternalResult.BadFileNumber => NvResult.FileOperationFailed,
NvInternalResult.InvalidInput => NvResult.InvalidValue,
NvInternalResult.NotADirectory => NvResult.DirectoryOperationFailed,
NvInternalResult.Busy => NvResult.Busy,
NvInternalResult.BadAddress => NvResult.InvalidAddress,
NvInternalResult.AccessDenied or NvInternalResult.OperationNotPermitted => NvResult.AccessDenied,
NvInternalResult.OutOfMemory => NvResult.InsufficientMemory,
NvInternalResult.DeviceNotFound => NvResult.ModuleNotPresent,
NvInternalResult.IoError => NvResult.ResourceError,
_ => NvResult.IoctlFailed,
};
}
[CommandCmif(0)]
@@ -240,7 +218,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
public ResultCode Open(ServiceCtx context)
{
NvResult errorCode = EnsureInitialized();
int fd = -1;
int fd = -1;
if (errorCode == NvResult.Success)
{
@@ -266,7 +244,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
int fd = context.RequestData.ReadInt32();
int fd = context.RequestData.ReadInt32();
NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>();
errorCode = GetIoctlArgument(context, ioctlCommand, out Span<byte> arguments);
@@ -328,8 +306,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv
// Initialize(u32 transfer_memory_size, handle<copy, process> current_process, handle<copy, transfer_memory> transfer_memory) -> u32 error_code
public ResultCode Initialize(ServiceCtx context)
{
long transferMemSize = context.RequestData.ReadInt64();
int transferMemHandle = context.Request.HandleDesc.ToCopy[1];
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long transferMemSize = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
int transferMemHandle = context.Request.HandleDesc.ToCopy[1];
// TODO: When transfer memory will be implemented, this could be removed.
_transferMemInitialized = true;
@@ -357,7 +337,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
int fd = context.RequestData.ReadInt32();
int fd = context.RequestData.ReadInt32();
uint eventId = context.RequestData.ReadUInt32();
errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile);
@@ -393,9 +373,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
int fd = context.RequestData.ReadInt32();
uint argument = context.RequestData.ReadUInt32();
int sharedMemoryHandle = context.Request.HandleDesc.ToCopy[0];
int fd = context.RequestData.ReadInt32();
uint argument = context.RequestData.ReadUInt32();
int sharedMemoryHandle = context.Request.HandleDesc.ToCopy[0];
errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile);
@@ -418,12 +398,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (_transferMemInitialized)
{
// TODO: Populate values when more RE will be done.
NvStatus nvStatus = new NvStatus
NvStatus nvStatus = new()
{
MemoryValue1 = 0, // GetMemStats(transfer_memory + 0x60, 3)
MemoryValue2 = 0, // GetMemStats(transfer_memory + 0x60, 5)
MemoryValue3 = 0, // transfer_memory + 0x78
MemoryValue4 = 0 // transfer_memory + 0x80
MemoryValue4 = 0, // transfer_memory + 0x80
};
context.ResponseData.WriteStruct(nvStatus);
@@ -450,7 +430,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv
// SetClientPID(u64, pid) -> u32 error_code
public ResultCode SetClientPid(ServiceCtx context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long pid = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
context.ResponseData.Write(0);
@@ -481,7 +463,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
int fd = context.RequestData.ReadInt32();
int fd = context.RequestData.ReadInt32();
NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>();
(ulong inlineInBufferPosition, ulong inlineInBufferSize) = context.Request.GetBufferType0x21(1);
@@ -492,7 +474,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
context.Memory.Read(inlineInBufferPosition, temp);
Span<byte> inlineInBuffer = new Span<byte>(temp);
Span<byte> inlineInBuffer = new(temp);
if (errorCode == NvResult.Success)
{
@@ -530,7 +512,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
int fd = context.RequestData.ReadInt32();
int fd = context.RequestData.ReadInt32();
NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>();
(ulong inlineOutBufferPosition, ulong inlineOutBufferSize) = context.Request.GetBufferType0x22(1);
@@ -541,7 +523,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
context.Memory.Read(inlineOutBufferPosition, temp);
Span<byte> inlineOutBuffer = new Span<byte>(temp);
Span<byte> inlineOutBuffer = new(temp);
if (errorCode == NvResult.Success)
{
@@ -595,4 +577,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv
DeviceFileIdRegistry.Clear();
}
}
}
}