[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

@@ -27,4 +27,4 @@ namespace Ryujinx.HLE.HOS.Services.Nifm
return ResultCode.Success;
}
}
}
}

View File

@@ -2,14 +2,14 @@ namespace Ryujinx.HLE.HOS.Services.Nifm
{
enum ResultCode
{
ModuleId = 110,
ModuleId = 110,
ErrorCodeShift = 9,
Success = 0,
Unknown112 = (112 << ErrorCodeShift) | ModuleId, // IRequest::GetResult
Unknown180 = (180 << ErrorCodeShift) | ModuleId, // IRequest::GetAppletInfo
Unknown112 = (112 << ErrorCodeShift) | ModuleId, // IRequest::GetResult
Unknown180 = (180 << ErrorCodeShift) | ModuleId, // IRequest::GetAppletInfo
NoInternetConnection = (300 << ErrorCodeShift) | ModuleId,
ObjectIsNull = (350 << ErrorCodeShift) | ModuleId
ObjectIsNull = (350 << ErrorCodeShift) | ModuleId,
}
}
}

View File

@@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService
{
static class GeneralServiceManager
{
private static List<GeneralServiceDetail> _generalServices = new List<GeneralServiceDetail>();
private static readonly List<GeneralServiceDetail> _generalServices = new();
public static int Count
{
@@ -27,4 +27,4 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService
return _generalServices.First(item => item.ClientId == clientId);
}
}
}
}

View File

@@ -2,7 +2,7 @@
{
class GeneralServiceDetail
{
public int ClientId;
public int ClientId;
public bool IsAnyInternetRequestAccepted;
}
}
}

View File

@@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
{
class IGeneralService : DisposableIpcService
{
private GeneralServiceDetail _generalServiceDetail;
private readonly GeneralServiceDetail _generalServiceDetail;
private IPInterfaceProperties _targetPropertiesCache = null;
private UnicastIPAddressInformation _targetAddressInfoCache = null;
@@ -21,11 +21,11 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
{
_generalServiceDetail = new GeneralServiceDetail
{
ClientId = GeneralServiceManager.Count,
IsAnyInternetRequestAccepted = true // NOTE: Why not accept any internet request?
ClientId = GeneralServiceManager.Count,
IsAnyInternetRequestAccepted = true, // NOTE: Why not accept any internet request?
};
NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(LocalInterfaceCacheHandler);
NetworkChange.NetworkAddressChanged += LocalInterfaceCacheHandler;
GeneralServiceManager.Add(_generalServiceDetail);
}
@@ -76,13 +76,13 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize((uint)Unsafe.SizeOf<NetworkProfileData>());
NetworkProfileData networkProfile = new NetworkProfileData
NetworkProfileData networkProfile = new()
{
Uuid = UInt128Utils.CreateRandom()
Uuid = UInt128Utils.CreateRandom(),
};
networkProfile.IpSettingData.IpAddressSetting = new IpAddressSetting(interfaceProperties, unicastAddress);
networkProfile.IpSettingData.DnsSetting = new DnsSetting(interfaceProperties);
networkProfile.IpSettingData.DnsSetting = new DnsSetting(interfaceProperties);
"RyujinxNetwork"u8.CopyTo(networkProfile.Name.AsSpan());
@@ -137,11 +137,11 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
return ResultCode.NoInternetConnection;
}
InternetConnectionStatus internetConnectionStatus = new InternetConnectionStatus
InternetConnectionStatus internetConnectionStatus = new()
{
Type = InternetConnectionType.WiFi,
Type = InternetConnectionType.WiFi,
WifiStrength = 3,
State = InternetConnectionState.Connected,
State = InternetConnectionState.Connected,
};
context.ResponseData.WriteStruct(internetConnectionStatus);
@@ -154,7 +154,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
public ResultCode IsAnyInternetRequestAccepted(ServiceCtx context)
{
ulong position = context.Request.PtrBuff[0].Position;
ulong size = context.Request.PtrBuff[0].Size;
#pragma warning disable IDE0059 // Remove unnecessary value assignment
ulong size = context.Request.PtrBuff[0].Size;
#pragma warning restore IDE0059
int clientId = context.Memory.Read<int>(position);
@@ -184,9 +186,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
private void LocalInterfaceCacheHandler(object sender, EventArgs e)
{
Logger.Info?.Print(LogClass.ServiceNifm, $"NetworkAddress changed, invalidating cached data.");
Logger.Info?.Print(LogClass.ServiceNifm, "NetworkAddress changed, invalidating cached data.");
_targetPropertiesCache = null;
_targetPropertiesCache = null;
_targetAddressInfoCache = null;
}
@@ -200,4 +202,4 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
}
}
}
}
}

View File

@@ -12,16 +12,18 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
{
Error = 1,
OnHold = 2,
Available = 3
Available = 3,
}
private KEvent _event0;
private KEvent _event1;
private readonly KEvent _event0;
private readonly KEvent _event1;
private int _event0Handle;
private int _event1Handle;
private uint _version;
#pragma warning disable IDE0052 // Remove unread private member
private readonly uint _version;
#pragma warning restore IDE0052
public IRequest(Horizon system, uint version)
{
@@ -116,7 +118,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
// GetAppletInfo(u32) -> (u32, u32, u32, buffer<bytes, 6>)
public ResultCode GetAppletInfo(ServiceCtx context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
uint themeColor = context.RequestData.ReadUInt32();
#pragma warning restore IDE0059
Logger.Stub?.PrintStub(LogClass.ServiceNifm);
@@ -139,4 +143,4 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
return ResultCode.Success;
}
}
}
}

View File

@@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
struct DnsSetting
{
[MarshalAs(UnmanagedType.U1)]
public bool IsDynamicDnsEnabled;
public bool IsDynamicDnsEnabled;
public IpV4Address PrimaryDns;
public IpV4Address SecondaryDns;
@@ -18,14 +18,14 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
if (interfaceProperties.DnsAddresses.Count == 0)
{
PrimaryDns = new IpV4Address();
PrimaryDns = new IpV4Address();
SecondaryDns = new IpV4Address();
}
else
{
PrimaryDns = new IpV4Address(interfaceProperties.DnsAddresses[0]);
PrimaryDns = new IpV4Address(interfaceProperties.DnsAddresses[0]);
SecondaryDns = new IpV4Address(interfaceProperties.DnsAddresses[interfaceProperties.DnsAddresses.Count > 1 ? 1 : 0]);
}
}
}
}
}

View File

@@ -6,6 +6,6 @@
ConnectingType1 = 1,
ConnectingType2 = 2,
ConnectingType3 = 3,
Connected = 4,
Connected = 4,
}
}

View File

@@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
[StructLayout(LayoutKind.Sequential)]
struct InternetConnectionStatus
{
public InternetConnectionType Type;
public byte WifiStrength;
public InternetConnectionType Type;
public byte WifiStrength;
public InternetConnectionState State;
}
}

View File

@@ -2,8 +2,8 @@
{
enum InternetConnectionType : byte
{
Invalid = 0,
WiFi = 1,
Invalid = 0,
WiFi = 1,
Ethernet = 2,
}
}

View File

@@ -8,17 +8,17 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
struct IpAddressSetting
{
[MarshalAs(UnmanagedType.U1)]
public bool IsDhcpEnabled;
public bool IsDhcpEnabled;
public IpV4Address Address;
public IpV4Address IPv4Mask;
public IpV4Address GatewayAddress;
public IpAddressSetting(IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastIPAddressInformation)
{
IsDhcpEnabled = OperatingSystem.IsMacOS() || interfaceProperties.DhcpServerAddresses.Count != 0;
Address = new IpV4Address(unicastIPAddressInformation.Address);
IPv4Mask = new IpV4Address(unicastIPAddressInformation.IPv4Mask);
IsDhcpEnabled = OperatingSystem.IsMacOS() || interfaceProperties.DhcpServerAddresses.Count != 0;
Address = new IpV4Address(unicastIPAddressInformation.Address);
IPv4Mask = new IpV4Address(unicastIPAddressInformation.IPv4Mask);
GatewayAddress = (interfaceProperties.GatewayAddresses.Count == 0) ? new IpV4Address() : new IpV4Address(interfaceProperties.GatewayAddresses[0].Address);
}
}
}
}

View File

@@ -6,8 +6,8 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
struct IpSettingData
{
public IpAddressSetting IpAddressSetting;
public DnsSetting DnsSetting;
public ProxySetting ProxySetting;
public short Mtu;
public DnsSetting DnsSetting;
public ProxySetting ProxySetting;
public short Mtu;
}
}
}

View File

@@ -7,11 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x17C)]
struct NetworkProfileData
{
public IpSettingData IpSettingData;
public UInt128 Uuid;
public Array64<byte> Name;
public Array4<byte> Unknown;
public IpSettingData IpSettingData;
public UInt128 Uuid;
public Array64<byte> Name;
public Array4<byte> Unknown;
public WirelessSettingData WirelessSettingData;
public byte Padding;
public byte Padding;
}
}
}

View File

@@ -9,19 +9,19 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
public struct ProxySetting
{
[MarshalAs(UnmanagedType.I1)]
public bool Enabled;
private byte _padding;
public short Port;
private NameStruct _name;
public bool Enabled;
private readonly byte _padding;
public short Port;
private NameStruct _name;
[MarshalAs(UnmanagedType.I1)]
public bool AutoAuthEnabled;
public Array32<byte> User;
public Array32<byte> Pass;
private byte _padding2;
public bool AutoAuthEnabled;
public Array32<byte> User;
public Array32<byte> Pass;
private readonly byte _padding2;
[StructLayout(LayoutKind.Sequential, Size = 0x64)]
private struct NameStruct { }
public Span<byte> Name => SpanHelpers.AsSpan<NameStruct, byte>(ref _name);
}
}
}

View File

@@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x65)]
struct WirelessSettingData
{
public byte SsidLength;
public byte SsidLength;
public Array32<byte> Ssid;
public Array3<byte> Unknown;
public Array3<byte> Unknown;
public Array64<byte> Passphrase1;
public byte Passphrase2;
public byte Passphrase2;
}
}
}