[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,9 +10,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
{
public const int AutoReceiveStatic = byte.MaxValue;
public HipcMetadata Meta;
public HipcMetadata Meta;
public HipcMessageData Data;
public ulong Pid;
public ulong Pid;
public HipcMessage(Span<byte> data)
{
@@ -22,8 +22,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
data = data[Unsafe.SizeOf<Header>()..];
int receiveStaticsCount = 0;
ulong pid = 0;
int receiveStaticsCount = 0;
ulong pid = 0;
if (header.ReceiveStaticMode != 0)
{
@@ -42,75 +42,75 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
if (header.HasSpecialHeader)
{
specialHeader = MemoryMarshal.Cast<byte, SpecialHeader>(data)[0];
data = data[Unsafe.SizeOf<SpecialHeader>()..];
data = data[Unsafe.SizeOf<SpecialHeader>()..];
if (specialHeader.SendPid)
{
pid = MemoryMarshal.Cast<byte, ulong>(data)[0];
pid = MemoryMarshal.Cast<byte, ulong>(data)[0];
data = data[sizeof(ulong)..];
}
}
Meta = new HipcMetadata()
Meta = new HipcMetadata
{
Type = (int)header.Type,
SendStaticsCount = header.SendStaticsCount,
SendBuffersCount = header.SendBuffersCount,
ReceiveBuffersCount = header.ReceiveBuffersCount,
Type = (int)header.Type,
SendStaticsCount = header.SendStaticsCount,
SendBuffersCount = header.SendBuffersCount,
ReceiveBuffersCount = header.ReceiveBuffersCount,
ExchangeBuffersCount = header.ExchangeBuffersCount,
DataWordsCount = header.DataWordsCount,
ReceiveStaticsCount = receiveStaticsCount,
SendPid = specialHeader.SendPid,
CopyHandlesCount = specialHeader.CopyHandlesCount,
MoveHandlesCount = specialHeader.MoveHandlesCount
DataWordsCount = header.DataWordsCount,
ReceiveStaticsCount = receiveStaticsCount,
SendPid = specialHeader.SendPid,
CopyHandlesCount = specialHeader.CopyHandlesCount,
MoveHandlesCount = specialHeader.MoveHandlesCount,
};
Data = CreateMessageData(Meta, data, initialLength);
Pid = pid;
Pid = pid;
}
public static HipcMessageData WriteResponse(
Span<byte> destination,
int sendStaticCount,
int dataWordsCount,
int copyHandlesCount,
int moveHandlesCount)
int sendStaticCount,
int dataWordsCount,
int copyHandlesCount,
int moveHandlesCount)
{
return WriteMessage(destination, new HipcMetadata()
return WriteMessage(destination, new HipcMetadata
{
SendStaticsCount = sendStaticCount,
DataWordsCount = dataWordsCount,
DataWordsCount = dataWordsCount,
CopyHandlesCount = copyHandlesCount,
MoveHandlesCount = moveHandlesCount
MoveHandlesCount = moveHandlesCount,
});
}
public static HipcMessageData WriteMessage(Span<byte> destination, HipcMetadata meta)
{
int initialLength = destination.Length;
int initialLength = destination.Length;
bool hasSpecialHeader = meta.SendPid || meta.CopyHandlesCount != 0 || meta.MoveHandlesCount != 0;
MemoryMarshal.Cast<byte, Header>(destination)[0] = new Header()
MemoryMarshal.Cast<byte, Header>(destination)[0] = new Header
{
Type = (CommandType)meta.Type,
SendStaticsCount = meta.SendStaticsCount,
SendBuffersCount = meta.SendBuffersCount,
ReceiveBuffersCount = meta.ReceiveBuffersCount,
Type = (CommandType)meta.Type,
SendStaticsCount = meta.SendStaticsCount,
SendBuffersCount = meta.SendBuffersCount,
ReceiveBuffersCount = meta.ReceiveBuffersCount,
ExchangeBuffersCount = meta.ExchangeBuffersCount,
DataWordsCount = meta.DataWordsCount,
ReceiveStaticMode = meta.ReceiveStaticsCount != 0 ? (meta.ReceiveStaticsCount != AutoReceiveStatic ? meta.ReceiveStaticsCount + 2 : 2) : 0,
HasSpecialHeader = hasSpecialHeader
DataWordsCount = meta.DataWordsCount,
ReceiveStaticMode = meta.ReceiveStaticsCount != 0 ? (meta.ReceiveStaticsCount != AutoReceiveStatic ? meta.ReceiveStaticsCount + 2 : 2) : 0,
HasSpecialHeader = hasSpecialHeader,
};
destination = destination[Unsafe.SizeOf<Header>()..];
if (hasSpecialHeader)
{
MemoryMarshal.Cast<byte, SpecialHeader>(destination)[0] = new SpecialHeader()
MemoryMarshal.Cast<byte, SpecialHeader>(destination)[0] = new SpecialHeader
{
SendPid = meta.SendPid,
SendPid = meta.SendPid,
CopyHandlesCount = meta.CopyHandlesCount,
MoveHandlesCount = meta.MoveHandlesCount
MoveHandlesCount = meta.MoveHandlesCount,
};
destination = destination[Unsafe.SizeOf<SpecialHeader>()..];
@@ -184,9 +184,9 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
if (meta.DataWordsCount != 0)
{
int dataOffset = initialLength - data.Length;
int dataOffset = initialLength - data.Length;
int dataOffsetAligned = BitUtils.AlignUp(dataOffset, 0x10);
int padding = (dataOffsetAligned - dataOffset) / sizeof(uint);
int padding = (dataOffsetAligned - dataOffset) / sizeof(uint);
dataWords = MemoryMarshal.Cast<byte, uint>(data)[padding..meta.DataWordsCount];
@@ -202,16 +202,16 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc
receiveList = MemoryMarshal.Cast<byte, HipcReceiveListEntry>(data)[..receiveListSize];
}
return new HipcMessageData()
return new HipcMessageData
{
SendStatics = sendStatics,
SendBuffers = sendBuffers,
ReceiveBuffers = receiveBuffers,
SendStatics = sendStatics,
SendBuffers = sendBuffers,
ReceiveBuffers = receiveBuffers,
ExchangeBuffers = exchangeBuffers,
DataWords = dataWords,
ReceiveList = receiveList,
CopyHandles = copyHandles,
MoveHandles = moveHandles
DataWords = dataWords,
ReceiveList = receiveList,
CopyHandles = copyHandles,
MoveHandles = moveHandles,
};
}
}