[Ryujinx.Common] Address dotnet-format issues (#5358)

* 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 IDE0059 warnings

* Address or silence dotnet format IDE1006 warnings

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA2211 warnings

* Silence CA1806 and CA1834 issues

* Fix formatting for switch expressions

* 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

* Format if-blocks correctly

* 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

* Add comments to disabled warnings

* Remove a few unused parameters

* Replace MmeShadowScratch with Array256<uint>

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

* Run dotnet format after rebase

* Address IDE0251 warnings

* 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

* Second dotnet format pass

* Fix build issues

* Fix StructArrayHelpers.cs

* Apply suggestions from code review

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

* Fix return statements

* Fix naming rule violations

* Update src/Ryujinx.Common/Utilities/StreamUtils.cs

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

* Add trailing commas

* Address review feedback

* Address review feedback

* Rename remaining type parameters to TKey and TValue

* Fix manual formatting for logging levels

* Fix spacing before comments

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
TSRBerry 2023-06-28 18:41:38 +02:00 committed by GitHub
parent 0a75b73fa4
commit fc20d9b925
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 965 additions and 969 deletions

View file

@ -11,6 +11,6 @@ namespace Ryujinx.Common.Configuration
SmaaLow,
SmaaMedium,
SmaaHigh,
SmaaUltra
SmaaUltra,
}
}
}

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Common.Configuration
{
UserProfile,
Portable,
Custom
Custom,
}
public static LaunchMode Mode { get; private set; }
@ -34,7 +34,7 @@ namespace Ryujinx.Common.Configuration
private const string DefaultModsDir = "mods";
public static string CustomModsPath { get; set; }
public static string CustomSdModsPath {get; set; }
public static string CustomSdModsPath { get; set; }
public static string CustomNandPath { get; set; } // TODO: Actually implement this into VFS
public static string CustomSdCardPath { get; set; } // TODO: Actually implement this into VFS
@ -151,7 +151,7 @@ namespace Ryujinx.Common.Configuration
}
}
public static string GetModsPath() => CustomModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultModsDir)).FullName;
public static string GetModsPath() => CustomModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultModsDir)).FullName;
public static string GetSdModsPath() => CustomSdModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultSdcardDir, "atmosphere")).FullName;
}
}
}

View file

@ -11,7 +11,7 @@ namespace Ryujinx.Common.Configuration
Fixed16x10,
Fixed21x9,
Fixed32x9,
Stretched
Stretched,
}
public static class AspectRatioExtensions
@ -25,12 +25,14 @@ namespace Ryujinx.Common.Configuration
{
return aspectRatio switch
{
#pragma warning disable IDE0055 // Disable formatting
AspectRatio.Fixed4x3 => 4.0f,
AspectRatio.Fixed16x9 => 16.0f,
AspectRatio.Fixed16x10 => 16.0f,
AspectRatio.Fixed21x9 => 21.0f,
AspectRatio.Fixed32x9 => 32.0f,
_ => 16.0f
_ => 16.0f,
#pragma warning restore IDE0055
};
}
@ -38,12 +40,14 @@ namespace Ryujinx.Common.Configuration
{
return aspectRatio switch
{
#pragma warning disable IDE0055 // Disable formatting
AspectRatio.Fixed4x3 => 3.0f,
AspectRatio.Fixed16x9 => 9.0f,
AspectRatio.Fixed16x10 => 10.0f,
AspectRatio.Fixed21x9 => 9.0f,
AspectRatio.Fixed32x9 => 9.0f,
_ => 9.0f
_ => 9.0f,
#pragma warning restore IDE0055
};
}
@ -51,13 +55,15 @@ namespace Ryujinx.Common.Configuration
{
return aspectRatio switch
{
#pragma warning disable IDE0055 // Disable formatting
AspectRatio.Fixed4x3 => "4:3",
AspectRatio.Fixed16x9 => "16:9",
AspectRatio.Fixed16x10 => "16:10",
AspectRatio.Fixed21x9 => "21:9",
AspectRatio.Fixed32x9 => "32:9",
_ => "Stretched"
_ => "Stretched",
#pragma warning restore IDE0055
};
}
}
}
}

View file

@ -10,4 +10,4 @@ namespace Ryujinx.Common.Configuration
[JsonPropertyName("dlc_nca_list")]
public List<DownloadableContentNca> DownloadableContentNcaList { get; set; }
}
}
}

View file

@ -8,4 +8,4 @@ namespace Ryujinx.Common.Configuration
public partial class DownloadableContentJsonSerializerContext : JsonSerializerContext
{
}
}
}

View file

@ -7,8 +7,8 @@ namespace Ryujinx.Common.Configuration
[JsonPropertyName("path")]
public string FullPath { get; set; }
[JsonPropertyName("title_id")]
public ulong TitleId { get; set; }
public ulong TitleId { get; set; }
[JsonPropertyName("is_enabled")]
public bool Enabled { get; set; }
public bool Enabled { get; set; }
}
}
}

View file

@ -53,6 +53,6 @@ namespace Ryujinx.Common.Configuration.Hid.Controller
SingleLeftTrigger1,
SingleRightTrigger1,
Count
Count,
}
}
}

View file

@ -4,7 +4,7 @@ using System.Text.Json.Serialization;
namespace Ryujinx.Common.Configuration.Hid.Controller
{
public class GenericControllerInputConfig<Button, Stick> : GenericInputConfigurationCommon<Button> where Button : unmanaged where Stick : unmanaged
public class GenericControllerInputConfig<TButton, TStick> : GenericInputConfigurationCommon<TButton> where TButton : unmanaged where TStick : unmanaged
{
[JsonIgnore]
private float _deadzoneLeft;
@ -16,12 +16,12 @@ namespace Ryujinx.Common.Configuration.Hid.Controller
/// <summary>
/// Left JoyCon Controller Stick Bindings
/// </summary>
public JoyconConfigControllerStick<Button, Stick> LeftJoyconStick { get; set; }
public JoyconConfigControllerStick<TButton, TStick> LeftJoyconStick { get; set; }
/// <summary>
/// Right JoyCon Controller Stick Bindings
/// </summary>
public JoyconConfigControllerStick<Button, Stick> RightJoyconStick { get; set; }
public JoyconConfigControllerStick<TButton, TStick> RightJoyconStick { get; set; }
/// <summary>
/// Controller Left Analog Stick Deadzone

View file

@ -1,11 +1,11 @@
namespace Ryujinx.Common.Configuration.Hid.Controller
{
public class JoyconConfigControllerStick<Button, Stick> where Button: unmanaged where Stick: unmanaged
public class JoyconConfigControllerStick<TButton, TStick> where TButton : unmanaged where TStick : unmanaged
{
public Stick Joystick { get; set; }
public TStick Joystick { get; set; }
public bool InvertStickX { get; set; }
public bool InvertStickY { get; set; }
public bool Rotate90CW { get; set; }
public Button StickButton { get; set; }
public TButton StickButton { get; set; }
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
{
class JsonMotionConfigControllerConverter : JsonConverter<MotionConfigController>
{
private static readonly MotionConfigJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static readonly MotionConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static MotionInputBackendType GetMotionInputBackendType(ref Utf8JsonReader reader)
{
@ -55,8 +55,8 @@ namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
return motionBackendType switch
{
MotionInputBackendType.GamepadDriver => JsonSerializer.Deserialize(ref reader, SerializerContext.StandardMotionConfigController),
MotionInputBackendType.CemuHook => JsonSerializer.Deserialize(ref reader, SerializerContext.CemuHookMotionConfigController),
MotionInputBackendType.GamepadDriver => JsonSerializer.Deserialize(ref reader, _serializerContext.StandardMotionConfigController),
MotionInputBackendType.CemuHook => JsonSerializer.Deserialize(ref reader, _serializerContext.CemuHookMotionConfigController),
_ => throw new InvalidOperationException($"Unknown backend type {motionBackendType}"),
};
}
@ -66,10 +66,10 @@ namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
switch (value.MotionBackend)
{
case MotionInputBackendType.GamepadDriver:
JsonSerializer.Serialize(writer, value as StandardMotionConfigController, SerializerContext.StandardMotionConfigController);
JsonSerializer.Serialize(writer, value as StandardMotionConfigController, _serializerContext.StandardMotionConfigController);
break;
case MotionInputBackendType.CemuHook:
JsonSerializer.Serialize(writer, value as CemuHookMotionConfigController, SerializerContext.CemuHookMotionConfigController);
JsonSerializer.Serialize(writer, value as CemuHookMotionConfigController, _serializerContext.CemuHookMotionConfigController);
break;
default:
throw new ArgumentException($"Unknown motion backend type {value.MotionBackend}");

View file

@ -9,4 +9,4 @@ namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
public partial class MotionConfigJsonSerializerContext : JsonSerializerContext
{
}
}
}

View file

@ -10,6 +10,6 @@ namespace Ryujinx.Common.Configuration.Hid.Controller
Left,
Right,
Count
Count,
}
}
}

View file

@ -10,14 +10,14 @@ namespace Ryujinx.Common.Configuration.Hid
public enum ControllerType
{
None,
ProController = 1 << 0,
Handheld = 1 << 1,
JoyconPair = 1 << 2,
JoyconLeft = 1 << 3,
JoyconRight = 1 << 4,
Invalid = 1 << 5,
Pokeball = 1 << 6,
ProController = 1 << 0,
Handheld = 1 << 1,
JoyconPair = 1 << 2,
JoyconLeft = 1 << 3,
JoyconRight = 1 << 4,
Invalid = 1 << 5,
Pokeball = 1 << 6,
SystemExternal = 1 << 29,
System = 1 << 30
System = 1 << 30,
}
}
}

View file

@ -1,15 +1,15 @@
namespace Ryujinx.Common.Configuration.Hid
{
public class GenericInputConfigurationCommon<Button> : InputConfig where Button : unmanaged
public class GenericInputConfigurationCommon<TButton> : InputConfig where TButton : unmanaged
{
/// <summary>
/// Left JoyCon Controller Bindings
/// </summary>
public LeftJoyconCommonConfig<Button> LeftJoycon { get; set; }
public LeftJoyconCommonConfig<TButton> LeftJoycon { get; set; }
/// <summary>
/// Right JoyCon Controller Bindings
/// </summary>
public RightJoyconCommonConfig<Button> RightJoycon { get; set; }
public RightJoyconCommonConfig<TButton> RightJoycon { get; set; }
}
}

View file

@ -30,7 +30,7 @@ namespace Ryujinx.Common.Configuration.Hid
/// Player's Index for the controller
/// </summary>
public PlayerIndex PlayerIndex { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
@ -38,4 +38,4 @@ namespace Ryujinx.Common.Configuration.Hid
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

View file

@ -11,4 +11,4 @@ namespace Ryujinx.Common.Configuration.Hid
public partial class InputConfigJsonSerializerContext : JsonSerializerContext
{
}
}
}

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Common.Configuration.Hid
{
public class JsonInputConfigConverter : JsonConverter<InputConfig>
{
private static readonly InputConfigJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static InputBackendType GetInputBackendType(ref Utf8JsonReader reader)
{
@ -57,8 +57,8 @@ namespace Ryujinx.Common.Configuration.Hid
return backendType switch
{
InputBackendType.WindowKeyboard => JsonSerializer.Deserialize(ref reader, SerializerContext.StandardKeyboardInputConfig),
InputBackendType.GamepadSDL2 => JsonSerializer.Deserialize(ref reader, SerializerContext.StandardControllerInputConfig),
InputBackendType.WindowKeyboard => JsonSerializer.Deserialize(ref reader, _serializerContext.StandardKeyboardInputConfig),
InputBackendType.GamepadSDL2 => JsonSerializer.Deserialize(ref reader, _serializerContext.StandardControllerInputConfig),
_ => throw new InvalidOperationException($"Unknown backend type {backendType}"),
};
}
@ -68,10 +68,10 @@ namespace Ryujinx.Common.Configuration.Hid
switch (value.Backend)
{
case InputBackendType.WindowKeyboard:
JsonSerializer.Serialize(writer, value as StandardKeyboardInputConfig, SerializerContext.StandardKeyboardInputConfig);
JsonSerializer.Serialize(writer, value as StandardKeyboardInputConfig, _serializerContext.StandardKeyboardInputConfig);
break;
case InputBackendType.GamepadSDL2:
JsonSerializer.Serialize(writer, value as StandardControllerInputConfig, SerializerContext.StandardControllerInputConfig);
JsonSerializer.Serialize(writer, value as StandardControllerInputConfig, _serializerContext.StandardControllerInputConfig);
break;
default:
throw new ArgumentException($"Unknown backend type {value.Backend}");

View file

@ -138,6 +138,6 @@ namespace Ryujinx.Common.Configuration.Hid
BackSlash,
Unbound,
Count
Count,
}
}
}

View file

@ -1,15 +1,15 @@
namespace Ryujinx.Common.Configuration.Hid.Keyboard
{
public class GenericKeyboardInputConfig<Key> : GenericInputConfigurationCommon<Key> where Key : unmanaged
public class GenericKeyboardInputConfig<TKey> : GenericInputConfigurationCommon<TKey> where TKey : unmanaged
{
/// <summary>
/// Left JoyCon Controller Stick Bindings
/// </summary>
public JoyconConfigKeyboardStick<Key> LeftJoyconStick { get; set; }
public JoyconConfigKeyboardStick<TKey> LeftJoyconStick { get; set; }
/// <summary>
/// Right JoyCon Controller Stick Bindings
/// </summary>
public JoyconConfigKeyboardStick<Key> RightJoyconStick { get; set; }
public JoyconConfigKeyboardStick<TKey> RightJoyconStick { get; set; }
}
}

View file

@ -1,11 +1,11 @@
namespace Ryujinx.Common.Configuration.Hid.Keyboard
{
public class JoyconConfigKeyboardStick<Key> where Key: unmanaged
public class JoyconConfigKeyboardStick<TKey> where TKey : unmanaged
{
public Key StickUp { get; set; }
public Key StickDown { get; set; }
public Key StickLeft { get; set; }
public Key StickRight { get; set; }
public Key StickButton { get; set; }
public TKey StickUp { get; set; }
public TKey StickDown { get; set; }
public TKey StickLeft { get; set; }
public TKey StickRight { get; set; }
public TKey StickButton { get; set; }
}
}

View file

@ -14,4 +14,4 @@
public Key VolumeUp { get; set; }
public Key VolumeDown { get; set; }
}
}
}

View file

@ -1,15 +1,15 @@
namespace Ryujinx.Common.Configuration.Hid
{
public class LeftJoyconCommonConfig<Button>
public class LeftJoyconCommonConfig<TButton>
{
public Button ButtonMinus { get; set; }
public Button ButtonL { get; set; }
public Button ButtonZl { get; set; }
public Button ButtonSl { get; set; }
public Button ButtonSr { get; set; }
public Button DpadUp { get; set; }
public Button DpadDown { get; set; }
public Button DpadLeft { get; set; }
public Button DpadRight { get; set; }
public TButton ButtonMinus { get; set; }
public TButton ButtonL { get; set; }
public TButton ButtonZl { get; set; }
public TButton ButtonSl { get; set; }
public TButton ButtonSr { get; set; }
public TButton DpadUp { get; set; }
public TButton DpadDown { get; set; }
public TButton DpadLeft { get; set; }
public TButton DpadRight { get; set; }
}
}

View file

@ -7,16 +7,16 @@ namespace Ryujinx.Common.Configuration.Hid
[JsonConverter(typeof(TypedStringEnumConverter<PlayerIndex>))]
public enum PlayerIndex
{
Player1 = 0,
Player2 = 1,
Player3 = 2,
Player4 = 3,
Player5 = 4,
Player6 = 5,
Player7 = 6,
Player8 = 7,
Player1 = 0,
Player2 = 1,
Player3 = 2,
Player4 = 3,
Player5 = 4,
Player6 = 5,
Player7 = 6,
Player8 = 7,
Handheld = 8,
Unknown = 9,
Auto = 10 // Shouldn't be used directly
Unknown = 9,
Auto = 10, // Shouldn't be used directly
}
}
}

View file

@ -1,15 +1,15 @@
namespace Ryujinx.Common.Configuration.Hid
{
public class RightJoyconCommonConfig<Button>
public class RightJoyconCommonConfig<TButton>
{
public Button ButtonPlus { get; set; }
public Button ButtonR { get; set; }
public Button ButtonZr { get; set; }
public Button ButtonSl { get; set; }
public Button ButtonSr { get; set; }
public Button ButtonX { get; set; }
public Button ButtonB { get; set; }
public Button ButtonY { get; set; }
public Button ButtonA { get; set; }
public TButton ButtonPlus { get; set; }
public TButton ButtonR { get; set; }
public TButton ButtonZr { get; set; }
public TButton ButtonSl { get; set; }
public TButton ButtonSr { get; set; }
public TButton ButtonX { get; set; }
public TButton ButtonB { get; set; }
public TButton ButtonY { get; set; }
public TButton ButtonA { get; set; }
}
}
}

View file

@ -4,6 +4,6 @@ namespace Ryujinx.Common.Configuration
{
Never,
OnIdle,
Always
Always,
}
}
}

View file

@ -8,6 +8,6 @@ namespace Ryujinx.Common.Configuration
{
Bilinear,
Nearest,
Fsr
Fsr,
}
}
}

View file

@ -4,7 +4,7 @@ namespace Ryujinx.Common.Configuration
{
public struct TitleUpdateMetadata
{
public string Selected { get; set; }
public List<string> Paths { get; set; }
public string Selected { get; set; }
public List<string> Paths { get; set; }
}
}
}

View file

@ -7,4 +7,4 @@ namespace Ryujinx.Common.Configuration
public partial class TitleUpdateMetadataJsonSerializerContext : JsonSerializerContext
{
}
}
}