Add a few `#if`s to fix errors when targeting `net461`

This commit is contained in:
James Groom 2024-05-07 00:47:16 +10:00 committed by GitHub
parent 7f574eec25
commit b8f2437e8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View File

@ -82,7 +82,12 @@ namespace BizHawk.BizInvoke
private static CustomAttributeBuilder GetAttributeBuilder(object o)
{
// anything more clever we can do here?
#if NETSTANDARD2_1_OR_GREATER || NET471_OR_GREATER || NETCOREAPP2_0_OR_GREATER
if (o is OutAttribute or InAttribute or IsReadOnlyAttribute)
#else
if (o is OutAttribute or InAttribute
|| o.GetType().FullName == "System.Runtime.CompilerServices.IsReadOnlyAttribute") // I think without this, you'd still only hit the below runtime assertion when this project targets e.g. netstandard2.0 but a core targets e.g. net8.0, so unlikely --yoshi
#endif
{
return new(o.GetType().GetConstructor(Type.EmptyTypes)!, Array.Empty<object>());
}

View File

@ -19,7 +19,12 @@ namespace BizHawk.Client.EmuHawk
{
private const CallingConvention cc = CallingConvention.Cdecl;
private const UnmanagedType STR_MARSHAL_HINT = UnmanagedType.LPUTF8Str;
private const UnmanagedType STR_MARSHAL_HINT
#if NETSTANDARD2_1_OR_GREATER || NET47_OR_GREATER || NETCOREAPP1_1_OR_GREATER
= UnmanagedType.LPUTF8Str;
#else
= UnmanagedType.LPStr; // presumably this will produce mojibake for non-ASCII text but is otherwise safe? CPP confirmed it was the right one so I'm trusting him --yoshi
#endif
public enum rc_error_t : int
{

View File

@ -28,7 +28,12 @@ namespace BizHawk.Client.EmuHawk.ForDebugging
public DebugVSystemMenuItem(string sysID, params string[] extraSysIDs)
{
SysIDs = new[] { sysID }.Concat(extraSysIDs).ToHashSet();
SysIDs = new[] { sysID }.Concat(extraSysIDs)
#if NET472_OR_GREATER || NETCOREAPP2_0_OR_GREATER
.ToHashSet();
#else // Meziantou.Polyfill covers `IEnumerable<>.ToHashSet` but we're not using that at time of writing --yoshi
.ToArray();
#endif
Text = sysID;
}
}