From 7d5442404823cdf5a2dafce66be6b6b90d3e0a44 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Fri, 27 Dec 2024 21:31:46 -0600 Subject: [PATCH] misc: Use selector fields --- .../NSHelper.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.cs b/src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.cs index 52c192a90..dc2495d07 100644 --- a/src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.cs +++ b/src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.cs @@ -1,19 +1,23 @@ using SharpMetal.Foundation; using SharpMetal.ObjectiveCCore; using System.Runtime.Versioning; +// ReSharper disable InconsistentNaming namespace Ryujinx.Graphics.Metal.SharpMetalExtensions { [SupportedOSPlatform("macOS")] public static class NSHelper { + private static readonly Selector sel_getCStringMaxLengthEncoding = "getCString:maxLength:encoding:"; + private static readonly Selector sel_stringWithUTF8String = "stringWithUTF8String:"; + public static unsafe string ToDotNetString(this NSString source) { char[] sourceBuffer = new char[source.Length]; fixed (char* pSourceBuffer = sourceBuffer) { ObjectiveC.bool_objc_msgSend(source, - "getCString:maxLength:encoding:", + sel_getCStringMaxLengthEncoding, pSourceBuffer, source.MaximumLengthOfBytes(NSStringEncoding.UTF16) + 1, (ulong)NSStringEncoding.UTF16); @@ -23,6 +27,6 @@ namespace Ryujinx.Graphics.Metal.SharpMetalExtensions } public static NSString ToNSString(this string source) - => new(ObjectiveC.IntPtr_objc_msgSend(new ObjectiveCClass("NSString"), "stringWithUTF8String:", source)); + => new(ObjectiveC.IntPtr_objc_msgSend(new ObjectiveCClass(nameof(NSString)), sel_stringWithUTF8String, source)); } }