diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj b/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj index b3567e0d4dfa85..c1e48494c32e1e 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj +++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj @@ -1,13 +1,20 @@ - - $(NetCoreAppToolCurrent) - $(NoWarn),CA1050,CA1850 + $(NetCoreAppToolCurrent);$(NetFrameworkToolCurrent) + enable + + $(NoWarn),CA1050,CS8604,CS8602 + $(NoWarn),CA1050,CA1850 false true true + + + + + @@ -31,17 +38,25 @@ - + + - - + + + + + + - + diff --git a/src/tasks/WasmAppBuilder/coreclr/PInvokeTableGenerator.cs b/src/tasks/WasmAppBuilder/coreclr/PInvokeTableGenerator.cs index 41d13a98405c64..b3d9c43f6cbd51 100644 --- a/src/tasks/WasmAppBuilder/coreclr/PInvokeTableGenerator.cs +++ b/src/tasks/WasmAppBuilder/coreclr/PInvokeTableGenerator.cs @@ -267,7 +267,7 @@ private static string PickCTypeNameForUnknownType(Type t) if (!t.IsValueType) return "void *"; // Pass pointers and function pointers by-value - else if (t.IsPointer || t.IsFunctionPointer) + else if (t.IsPointer || IsFunctionPointer(t)) return "void *"; else if (t.IsPrimitive) throw new NotImplementedException("No native type mapping for type " + t); @@ -504,6 +504,12 @@ private string ThunkMapEntryLine(PInvokeCallback cb, LogAdapter Log) private static readonly Dictionary _blittableCache = new(); + public static bool IsFunctionPointer(Type type) + { + object? bIsFunctionPointer = type.GetType().GetProperty("IsFunctionPointer")?.GetValue(type); + return (bIsFunctionPointer is bool b) && b; + } + public static bool IsBlittable(Type type, LogAdapter log) { // We maintain a cache of results in order to only produce log messages the first time @@ -523,7 +529,7 @@ static bool IsBlittableUncached(Type type, LogAdapter log) if (type.IsPrimitive || type.IsByRef || type.IsPointer || type.IsEnum) return true; - if (type.IsFunctionPointer) + if (IsFunctionPointer(type)) return true; // HACK: SkiaSharp has pinvokes that rely on this diff --git a/src/tasks/WasmAppBuilder/coreclr/SignatureMapper.cs b/src/tasks/WasmAppBuilder/coreclr/SignatureMapper.cs index 69085ff5b17c5b..a5a5bcb2d4993f 100644 --- a/src/tasks/WasmAppBuilder/coreclr/SignatureMapper.cs +++ b/src/tasks/WasmAppBuilder/coreclr/SignatureMapper.cs @@ -63,7 +63,7 @@ internal static class SignatureMapper } else if (t.IsPointer) c = 'i'; - else if (t.IsFunctionPointer) + else if (PInvokeTableGenerator.IsFunctionPointer(t)) c = 'i'; else if (t.IsValueType) {