Skip to content

Commit

Permalink
Prefer generic overload when type is known
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-carvalho committed Dec 22, 2024
1 parent 5913ced commit 343eced
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public FormatCapabilities(Vk api, PhysicalDevice physicalDevice)
_api = api;
_physicalDevice = physicalDevice;

int totalFormats = Enum.GetNames(typeof(Format)).Length;
int totalFormats = Enum.GetNames<Format>().Length;

_bufferTable = new FormatFeatureFlags[totalFormats];
_optimalTable = new FormatFeatureFlags[totalFormats];
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.Graphics.Vulkan/FormatTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static class FormatTable

static FormatTable()
{
_table = new VkFormat[Enum.GetNames(typeof(Format)).Length];
_table = new VkFormat[Enum.GetNames<Format>().Length];
_reverseMap = new Dictionary<VkFormat, Format>();

#pragma warning disable IDE0055 // Disable formatting
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.Graphics.Vulkan/Queries/Counters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public Counters(VulkanRenderer gd, Device device, PipelineFull pipeline)
{
_pipeline = pipeline;

int count = Enum.GetNames(typeof(CounterType)).Length;
int count = Enum.GetNames<CounterType>().Length;

_counterQueues = new CounterQueue[count];

Expand Down
12 changes: 6 additions & 6 deletions src/Ryujinx.HLE/HOS/Services/IpcService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ abstract class IpcService

public IpcService(ServerBase server = null)
{
CmifCommands = typeof(IpcService).Assembly.GetTypes()
CmifCommands = GetType().Assembly.GetTypes()
.Where(type => type == GetType())
.SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
.SelectMany(methodInfo => methodInfo.GetCustomAttributes(typeof(CommandCmifAttribute))
.Select(command => (((CommandCmifAttribute)command).Id, methodInfo)))
.SelectMany(methodInfo => methodInfo.GetCustomAttributes<CommandCmifAttribute>()
.Select(command => (command.Id, methodInfo)))
.ToDictionary(command => command.Id, command => command.methodInfo);

TipcCommands = typeof(IpcService).Assembly.GetTypes()
TipcCommands = GetType().Assembly.GetTypes()
.Where(type => type == GetType())
.SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
.SelectMany(methodInfo => methodInfo.GetCustomAttributes(typeof(CommandTipcAttribute))
.Select(command => (((CommandTipcAttribute)command).Id, methodInfo)))
.SelectMany(methodInfo => methodInfo.GetCustomAttributes<CommandTipcAttribute>()
.Select(command => (command.Id, methodInfo)))
.ToDictionary(command => command.Id, command => command.methodInfo);

Server = server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private ResultCode ScanImpl(ServiceCtx context, bool isPrivate = false)

private ResultCode ScanInternal(IVirtualMemoryManager memory, ushort channel, ScanFilter scanFilter, ulong bufferPosition, ulong bufferSize, out ulong counter)
{
ulong networkInfoSize = (ulong)Marshal.SizeOf(typeof(NetworkInfo));
ulong networkInfoSize = (ulong)Marshal.SizeOf<NetworkInfo>();
ulong maxGames = bufferSize / networkInfoSize;

MemoryHelper.FillWithZeros(memory, bufferPosition, (int)bufferSize);
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public ResultCode GetService(ServiceCtx context)
{
if (_services.TryGetValue(name, out Type type))
{
ServiceAttribute serviceAttribute = (ServiceAttribute)type.GetCustomAttributes(typeof(ServiceAttribute)).First(service => ((ServiceAttribute)service).Name == name);
ServiceAttribute serviceAttribute = type.GetCustomAttributes<ServiceAttribute>().First(service => service.Name == name);

IpcService service = GetServiceInstance(type, context, serviceAttribute.Parameter);

Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ public PlayerIndex PlayerId
{
if (IsModified)
{

_playerIdChoose = value;
return;
}

IsModified = false;
_playerId = value;

if (!Enum.IsDefined(typeof(PlayerIndex), _playerId))
if (!Enum.IsDefined<PlayerIndex>(_playerId))
{
_playerId = PlayerIndex.Player1;

Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx/UI/Views/Main/MainStatusBarView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void DockedStatus_PointerReleased(object sender, PointerReleasedEventArg
private void AspectRatioStatus_OnClick(object sender, RoutedEventArgs e)
{
AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value;
ConfigurationState.Instance.Graphics.AspectRatio.Value = (int)aspectRatio + 1 > Enum.GetNames(typeof(AspectRatio)).Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
ConfigurationState.Instance.Graphics.AspectRatio.Value = (int)aspectRatio + 1 > Enum.GetNames<AspectRatio>().Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
}

private void Refresh_OnClick(object sender, RoutedEventArgs e) => Window.LoadApplications();
Expand Down

0 comments on commit 343eced

Please sign in to comment.