diff --git a/Directory.Build.props b/Directory.Build.props index 65eb7e5b..a47c07f2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ true - 35.0.0 + 38.0.3 $(WasmtimeVersion)$(WasmtimeDotnetVersion)-dev $(WasmtimeVersion)$(WasmtimeDotnetVersion) diff --git a/examples/Directory.Build.targets b/examples/Directory.Build.targets new file mode 100644 index 00000000..4ccf9c33 --- /dev/null +++ b/examples/Directory.Build.targets @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/examples/hello/hello.csproj b/examples/hello/hello.csproj index 5e5a0f68..297321b3 100644 --- a/examples/hello/hello.csproj +++ b/examples/hello/hello.csproj @@ -1,13 +1,12 @@ - Exe net9.0 enable + true - + - - + \ No newline at end of file diff --git a/src/Externs.cs b/src/Externs.cs index 08b14076..bf61f455 100644 --- a/src/Externs.cs +++ b/src/Externs.cs @@ -7,7 +7,7 @@ namespace Wasmtime [StructLayout(LayoutKind.Sequential)] internal record struct ExternFunc { - static ExternFunc() => Debug.Assert(Marshal.SizeOf(typeof(ExternFunc)) == 16); + static ExternFunc() => Debug.Assert(Marshal.SizeOf() == 16); public ulong store; public IntPtr __private; @@ -16,7 +16,7 @@ internal record struct ExternFunc [StructLayout(LayoutKind.Explicit)] internal record struct ExternTable { - static ExternTable() => Debug.Assert(Marshal.SizeOf(typeof(ExternTable)) == 24); + static ExternTable() => Debug.Assert(Marshal.SizeOf() == 24); // Use explicit offsets because the struct in the C api has extra padding // due to field alignments. The total struct size is 24 bytes. @@ -33,7 +33,7 @@ internal record struct ExternTable [StructLayout(LayoutKind.Explicit)] internal record struct ExternMemory { - static ExternMemory() => Debug.Assert(Marshal.SizeOf(typeof(ExternMemory)) == 24); + static ExternMemory() => Debug.Assert(Marshal.SizeOf() == 24); // Use explicit offsets because the struct in the C api has extra padding // due to field alignments. The total struct size is 24 bytes. @@ -49,7 +49,7 @@ internal record struct ExternMemory [StructLayout(LayoutKind.Sequential)] internal record struct ExternInstance { - static ExternInstance() => Debug.Assert(Marshal.SizeOf(typeof(ExternInstance)) == 16); + static ExternInstance() => Debug.Assert(Marshal.SizeOf() == 16); public ulong store; public nuint __private; @@ -58,7 +58,7 @@ internal record struct ExternInstance [StructLayout(LayoutKind.Sequential)] internal record struct ExternGlobal { - static ExternGlobal() => Debug.Assert(Marshal.SizeOf(typeof(ExternMemory)) == 24); + static ExternGlobal() => Debug.Assert(Marshal.SizeOf() == 24); public ulong store; public uint __private1; @@ -78,7 +78,7 @@ internal enum ExternKind : byte [StructLayout(LayoutKind.Explicit)] internal struct ExternUnion { - static ExternUnion() => Debug.Assert(Marshal.SizeOf(typeof(ExternUnion)) == 24); + static ExternUnion() => Debug.Assert(Marshal.SizeOf() == 24); [FieldOffset(0)] public ExternFunc func; @@ -99,7 +99,7 @@ internal struct ExternUnion [StructLayout(LayoutKind.Sequential)] internal struct Extern : IDisposable { - static Extern() => Debug.Assert(Marshal.SizeOf(typeof(Extern)) == 32); + static Extern() => Debug.Assert(Marshal.SizeOf() == 32); public ExternKind kind; public ExternUnion of; diff --git a/src/Function.FromCallback.cs b/src/Function.FromCallback.cs index c45071c2..3ec3c3a8 100644 --- a/src/Function.FromCallback.cs +++ b/src/Function.FromCallback.cs @@ -9,6 +9,9 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -19,6 +22,9 @@ public partial class Function /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -80,6 +86,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -142,6 +151,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -206,6 +218,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -272,6 +287,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -340,6 +358,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -410,6 +431,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -482,6 +506,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -556,6 +583,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -632,6 +662,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -710,6 +743,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -790,6 +826,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -872,6 +911,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, Action callback) { if (store is null) @@ -956,6 +998,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1019,6 +1065,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1083,6 +1133,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1149,6 +1203,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1217,6 +1275,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1287,6 +1349,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1359,6 +1425,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1433,6 +1503,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1509,6 +1583,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1587,6 +1665,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1667,6 +1749,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1749,6 +1835,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1833,6 +1923,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func callback) { if (store is null) @@ -1919,6 +2013,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -1984,6 +2082,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2050,6 +2152,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2118,6 +2224,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2188,6 +2298,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2260,6 +2374,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2334,6 +2452,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2410,6 +2532,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2488,6 +2614,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2568,6 +2698,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2650,6 +2784,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2734,6 +2872,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2820,6 +2962,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2908,6 +3054,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -2975,6 +3125,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3043,6 +3197,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3113,6 +3271,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3185,6 +3347,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3259,6 +3425,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3335,6 +3505,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3413,6 +3587,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3493,6 +3671,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3575,6 +3757,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3659,6 +3845,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3745,6 +3935,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3833,6 +4027,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3923,6 +4121,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -3992,6 +4194,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4062,6 +4268,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4134,6 +4344,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4208,6 +4422,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4284,6 +4502,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4362,6 +4584,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4442,6 +4668,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4524,6 +4754,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4608,6 +4842,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4694,6 +4932,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4782,6 +5024,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4872,6 +5118,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, Func> callback) { if (store is null) @@ -4964,6 +5214,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5028,6 +5281,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5094,6 +5350,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5162,6 +5421,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5232,6 +5494,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5304,6 +5569,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5378,6 +5646,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5454,6 +5725,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5532,6 +5806,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5612,6 +5889,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5694,6 +5974,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5778,6 +6061,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5864,6 +6150,9 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +#endif public static Function FromCallback(Store store, CallerAction callback) { if (store is null) @@ -5952,6 +6241,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6018,6 +6311,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6086,6 +6383,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6156,6 +6457,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6228,6 +6533,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6302,6 +6611,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6378,6 +6691,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6456,6 +6773,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6536,6 +6857,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6618,6 +6943,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6702,6 +7031,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6788,6 +7121,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6876,6 +7213,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc callback) { if (store is null) @@ -6966,6 +7307,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7034,6 +7379,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7104,6 +7453,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7176,6 +7529,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7250,6 +7607,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7326,6 +7687,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7404,6 +7769,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7484,6 +7853,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7566,6 +7939,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7650,6 +8027,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7736,6 +8117,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7824,6 +8209,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -7914,6 +8303,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8006,6 +8399,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8076,6 +8473,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8148,6 +8549,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8222,6 +8627,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8298,6 +8707,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8376,6 +8789,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8456,6 +8873,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8538,6 +8959,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8622,6 +9047,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8708,6 +9137,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8796,6 +9229,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8886,6 +9323,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -8978,6 +9419,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9072,6 +9517,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9144,6 +9593,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9218,6 +9671,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9294,6 +9751,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9372,6 +9833,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9452,6 +9917,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9534,6 +10003,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9618,6 +10091,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9704,6 +10181,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9792,6 +10273,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9882,6 +10367,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -9974,6 +10463,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) @@ -10068,6 +10561,10 @@ out externFunc /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +#endif public static Function FromCallback(Store store, CallerFunc> callback) { if (store is null) diff --git a/src/Function.FromCallback.tt b/src/Function.FromCallback.tt index 93b86fcd..d57e5402 100644 --- a/src/Function.FromCallback.tt +++ b/src/Function.FromCallback.tt @@ -20,6 +20,9 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -41,6 +44,12 @@ foreach (var (hasCaller, resultCount, parameterCount, methodGenerics, delegateTy /// /// The store to create the function in. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating functions from callbacks may require runtime code generation for parameter and result types.")] +<# if (resultCount > 0) { #> + [RequiresUnreferencedCode("Creating functions with results may require reflection.")] +<# } #> +#endif public static Function FromCallback<#= methodGenerics #>(Store store, <#= delegateType #> callback) { if (store is null) diff --git a/src/Function.Wrap.cs b/src/Function.Wrap.cs index d761560f..c121f88b 100644 --- a/src/Function.Wrap.cs +++ b/src/Function.Wrap.cs @@ -7,6 +7,9 @@ #nullable enable using System; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -18,6 +21,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -64,6 +70,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -112,6 +121,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -162,6 +174,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -214,6 +229,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -268,6 +286,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -324,6 +345,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -382,6 +406,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -442,6 +469,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -504,6 +534,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -568,6 +601,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -634,6 +670,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -702,6 +741,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -772,6 +814,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -844,6 +889,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -918,6 +966,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -994,6 +1045,9 @@ public partial class Function /// Attempt to wrap this function as an Action. Wrapped Action is faster than a normal Invoke call. /// /// A Action to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? WrapAction() { if (store is null || IsNull) @@ -1072,6 +1126,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1121,6 +1179,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1172,6 +1234,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1225,6 +1291,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1280,6 +1350,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1337,6 +1411,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1396,6 +1474,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1457,6 +1539,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1520,6 +1606,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1585,6 +1675,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1652,6 +1746,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1721,6 +1819,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1792,6 +1894,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1865,6 +1971,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -1940,6 +2050,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -2017,6 +2131,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) @@ -2096,6 +2214,10 @@ public partial class Function /// Attempt to wrap this function as a Func. Wrapped Func is faster than a normal Invoke call. /// /// A Func to invoke this function, or null if the type signature is incompatible. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif public Func? WrapFunc() { if (store is null || IsNull) diff --git a/src/Function.Wrap.tt b/src/Function.Wrap.tt index 59459d7a..5450e5f3 100644 --- a/src/Function.Wrap.tt +++ b/src/Function.Wrap.tt @@ -18,6 +18,9 @@ #nullable enable using System; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -39,6 +42,16 @@ foreach (var (_, returnTypeCount, parameterCount, methodGenerics, delegateType, /// Attempt to wrap this function as <#= returnTypeCount > 0 ? "a Func" : "an Action" #>. Wrapped <#= returnTypeCount > 0 ? "Func" : "Action" #> is faster than a normal Invoke call. /// /// A <#= returnTypeCount > 0 ? "Func" : "Action" #> to invoke this function, or null if the type signature is incompatible. +<# if (returnTypeCount > 0) { #> +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] +#endif +<# } else { #> +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif +<# } #> public <#= delegateType #>? Wrap<#= returnTypeCount > 0 ? "Func" : "Action" #><#= methodGenerics #>() { if (store is null || IsNull) diff --git a/src/Function.cs b/src/Function.cs index 947bd986..4a370492 100644 --- a/src/Function.cs +++ b/src/Function.cs @@ -5,6 +5,9 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -101,7 +104,16 @@ out externFunc /// Return type (use a tuple for multiple return types) /// The parameters of the function /// Returns true if the type signature of the function is valid or false if not. - public bool CheckTypeSignature(Type? returnType = null, params Type[] parameters) +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern", + Justification = "The GetResultInnerType method returns a type that maintains the same interface requirements as the input type.")] +#endif + public bool CheckTypeSignature( +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] +#endif + Type? returnType = null, + params Type[] parameters) { // Check if the return type is a recognised result type (i.e. implements IActionResult or IFunctionResult) if (returnType != null && returnType.IsResultType()) @@ -793,4 +805,4 @@ internal static class Native private static readonly Function _null = new Function(); } -} +} \ No newline at end of file diff --git a/src/Instance.cs b/src/Instance.cs index 84631b40..25861d8c 100644 --- a/src/Instance.cs +++ b/src/Instance.cs @@ -2,6 +2,9 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -69,6 +72,9 @@ public Instance(Store store, Module module, params object[] imports) /// /// The name of the exported function. /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? GetAction(string name) { return GetFunction(name) @@ -81,6 +87,9 @@ public Instance(Store store, Module module, params object[] imports) /// The name of the exported function. /// Parameter type /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? GetAction(string name) { return GetFunction(name) @@ -94,6 +103,9 @@ public Instance(Store store, Module module, params object[] imports) /// First parameter type /// Second parameter type /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? GetAction(string name) { return GetFunction(name) @@ -108,6 +120,9 @@ public Instance(Store store, Module module, params object[] imports) /// Second parameter type /// Third parameter type /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? GetAction(string name) { return GetFunction(name) @@ -123,6 +138,9 @@ public Instance(Store store, Module module, params object[] imports) /// Third parameter type /// Fourth parameter type /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? GetAction(string name) { return GetFunction(name) @@ -139,6 +157,9 @@ public Instance(Store store, Module module, params object[] imports) /// Fourth parameter type /// Fifth parameter type /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Wrapping functions may require runtime code generation for parameter types.")] +#endif public Action? GetAction(string name) { return GetFunction(name) @@ -151,6 +172,10 @@ public Instance(Store store, Module module, params object[] imports) /// The name of the exported function. /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -164,6 +189,10 @@ public Instance(Store store, Module module, params object[] imports) /// First parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -178,6 +207,10 @@ public Instance(Store store, Module module, params object[] imports) /// Second parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -193,6 +226,10 @@ public Instance(Store store, Module module, params object[] imports) /// Third parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -209,6 +246,10 @@ public Instance(Store store, Module module, params object[] imports) /// Fourth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -226,6 +267,10 @@ public Instance(Store store, Module module, params object[] imports) /// Fifth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -244,6 +289,10 @@ public Instance(Store store, Module module, params object[] imports) /// Sixth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -263,6 +312,10 @@ public Instance(Store store, Module module, params object[] imports) /// Seventh parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -283,6 +336,10 @@ public Instance(Store store, Module module, params object[] imports) /// Eighth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -304,6 +361,10 @@ public Instance(Store store, Module module, params object[] imports) /// Ninth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -326,6 +387,10 @@ public Instance(Store store, Module module, params object[] imports) /// Tenth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -349,6 +414,10 @@ public Instance(Store store, Module module, params object[] imports) /// Eleventh parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -373,6 +442,10 @@ public Instance(Store store, Module module, params object[] imports) /// Twelfth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -398,6 +471,10 @@ public Instance(Store store, Module module, params object[] imports) /// Thirteenth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -424,6 +501,10 @@ public Instance(Store store, Module module, params object[] imports) /// Fourteenth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -451,6 +532,10 @@ public Instance(Store store, Module module, params object[] imports) /// Fifteenth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -479,6 +564,10 @@ public Instance(Store store, Module module, params object[] imports) /// Sixteenth parameter type /// Return type. Use a tuple for multiple return values /// Returns the function if a function of that name and type was exported or null if not. +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Wrapping functions with return types may require reflection.")] + [RequiresDynamicCode("Wrapping functions with return types may require runtime code generation for tuple types.")] +#endif public Func? GetFunction(string name) { return GetFunction(name) @@ -493,7 +582,12 @@ public Instance(Store store, Module module, params object[] imports) /// The return type of the function. Null if no return type. Tuple of types is multiple returns expected. /// The expected parameters to the function /// Returns the function if a function of that name and type signature was exported or null if not. - public Function? GetFunction(string name, Type? returnType, params Type[] parameterTypes) + public Function? GetFunction(string name, +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] +#endif + Type? returnType, + params Type[] parameterTypes) { var func = GetFunction(name); if (func is null) @@ -728,4 +822,4 @@ private static class Native private readonly Store _store; internal readonly ExternInstance instance; } -} +} \ No newline at end of file diff --git a/src/Linker.DefineFunction.cs b/src/Linker.DefineFunction.cs index 51f12f16..2d64eba0 100644 --- a/src/Linker.DefineFunction.cs +++ b/src/Linker.DefineFunction.cs @@ -10,6 +10,9 @@ using System.Buffers; using System.Runtime.InteropServices; using System.Text; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -22,6 +25,9 @@ public partial class Linker /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -121,6 +127,9 @@ public void DefineFunction(string module, string name, Action callback) /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -221,6 +230,9 @@ public void DefineFunction(string module, string name, Action callback) /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -323,6 +335,9 @@ public void DefineFunction(string module, string name, Action /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -427,6 +442,9 @@ public void DefineFunction(string module, string name, ActionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -533,6 +551,9 @@ public void DefineFunction(string module, string name, ActionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -641,6 +662,9 @@ public void DefineFunction(string module, string name, Actio /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -751,6 +775,9 @@ public void DefineFunction(string module, string name, A /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -863,6 +890,9 @@ public void DefineFunction(string module, string nam /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -977,6 +1007,9 @@ public void DefineFunction(string module, string /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -1093,6 +1126,9 @@ public void DefineFunction(string module, st /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -1211,6 +1247,9 @@ public void DefineFunction(string modul /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -1331,6 +1370,9 @@ public void DefineFunction(string /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, Action callback) { if (module is null) @@ -1453,6 +1495,10 @@ public void DefineFunction(st /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -1554,6 +1600,10 @@ public void DefineFunction(string module, string name, Func ca /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -1656,6 +1706,10 @@ public void DefineFunction(string module, string name, FuncThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -1760,6 +1814,10 @@ public void DefineFunction(string module, string name, FuncThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -1866,6 +1924,10 @@ public void DefineFunction(string module, string name, Func /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -1974,6 +2036,10 @@ public void DefineFunction(string module, string name, /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -2084,6 +2150,10 @@ public void DefineFunction(string module, string na /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -2196,6 +2266,10 @@ public void DefineFunction(string module, strin /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -2310,6 +2384,10 @@ public void DefineFunction(string module, s /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -2426,6 +2504,10 @@ public void DefineFunction(string modul /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -2544,6 +2626,10 @@ public void DefineFunction(string m /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -2664,6 +2750,10 @@ public void DefineFunction(str /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -2786,6 +2876,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func callback) { if (module is null) @@ -2910,6 +3004,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3013,6 +3111,10 @@ public void DefineFunction(string module, string name, Func< /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3117,6 +3219,10 @@ public void DefineFunction(string module, string name, Fu /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3223,6 +3329,10 @@ public void DefineFunction(string module, string nam /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3331,6 +3441,10 @@ public void DefineFunction(string module, string /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3441,6 +3555,10 @@ public void DefineFunction(string module, st /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3553,6 +3671,10 @@ public void DefineFunction(string module /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3667,6 +3789,10 @@ public void DefineFunction(string mo /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3783,6 +3909,10 @@ public void DefineFunction(strin /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -3901,6 +4031,10 @@ public void DefineFunction(s /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4021,6 +4155,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4143,6 +4281,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4267,6 +4409,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4393,6 +4539,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4498,6 +4648,10 @@ public void DefineFunction(string module, string n /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4604,6 +4758,10 @@ public void DefineFunction(string module, strin /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4712,6 +4870,10 @@ public void DefineFunction(string module, /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4822,6 +4984,10 @@ public void DefineFunction(string modu /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -4934,6 +5100,10 @@ public void DefineFunction(string /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -5048,6 +5218,10 @@ public void DefineFunction(str /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -5164,6 +5338,10 @@ public void DefineFunction /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -5282,6 +5460,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -5402,6 +5584,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -5524,6 +5710,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -5648,6 +5838,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -5774,6 +5968,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -5902,6 +6100,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6009,6 +6211,10 @@ public void DefineFunction(string module /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6117,6 +6323,10 @@ public void DefineFunction(string mod /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6227,6 +6437,10 @@ public void DefineFunction(strin /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6339,6 +6553,10 @@ public void DefineFunction(s /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6453,6 +6671,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6569,6 +6791,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6687,6 +6913,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6807,6 +7037,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -6929,6 +7163,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -7053,6 +7291,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -7179,6 +7421,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -7307,6 +7553,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, Func> callback) { if (module is null) @@ -7437,6 +7687,9 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -7536,6 +7789,9 @@ public void DefineFunction(string module, string name, CallerAction callback) /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -7637,6 +7893,9 @@ public void DefineFunction(string module, string name, CallerAction callb /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -7740,6 +7999,9 @@ public void DefineFunction(string module, string name, CallerActionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -7845,6 +8107,9 @@ public void DefineFunction(string module, string name, CallerAction< /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -7952,6 +8217,9 @@ public void DefineFunction(string module, string name, CallerAct /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -8061,6 +8329,9 @@ public void DefineFunction(string module, string name, Calle /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -8172,6 +8443,9 @@ public void DefineFunction(string module, string name, C /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -8285,6 +8559,9 @@ public void DefineFunction(string module, string nam /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -8400,6 +8677,9 @@ public void DefineFunction(string module, string /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -8517,6 +8797,9 @@ public void DefineFunction(string module, st /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -8636,6 +8919,9 @@ public void DefineFunction(string modul /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -8757,6 +9043,9 @@ public void DefineFunction(string /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +#endif public void DefineFunction(string module, string name, CallerAction callback) { if (module is null) @@ -8880,6 +9169,10 @@ public void DefineFunction(st /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -8981,6 +9274,10 @@ public void DefineFunction(string module, string name, CallerFuncThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9084,6 +9381,10 @@ public void DefineFunction(string module, string name, CallerFuncThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9189,6 +9490,10 @@ public void DefineFunction(string module, string name, CallerFu /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9296,6 +9601,10 @@ public void DefineFunction(string module, string name, Call /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9405,6 +9714,10 @@ public void DefineFunction(string module, string name, /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9516,6 +9829,10 @@ public void DefineFunction(string module, string na /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9629,6 +9946,10 @@ public void DefineFunction(string module, strin /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9744,6 +10065,10 @@ public void DefineFunction(string module, s /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9861,6 +10186,10 @@ public void DefineFunction(string modul /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -9980,6 +10309,10 @@ public void DefineFunction(string m /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -10101,6 +10434,10 @@ public void DefineFunction(str /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -10224,6 +10561,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc callback) { if (module is null) @@ -10349,6 +10690,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -10452,6 +10797,10 @@ public void DefineFunction(string module, string name, Calle /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -10557,6 +10906,10 @@ public void DefineFunction(string module, string name, Ca /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -10664,6 +11017,10 @@ public void DefineFunction(string module, string nam /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -10773,6 +11130,10 @@ public void DefineFunction(string module, string /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -10884,6 +11245,10 @@ public void DefineFunction(string module, st /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -10997,6 +11362,10 @@ public void DefineFunction(string module /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -11112,6 +11481,10 @@ public void DefineFunction(string mo /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -11229,6 +11602,10 @@ public void DefineFunction(strin /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -11348,6 +11725,10 @@ public void DefineFunction(s /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -11469,6 +11850,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -11592,6 +11977,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -11717,6 +12106,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -11844,6 +12237,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -11949,6 +12346,10 @@ public void DefineFunction(string module, string n /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12056,6 +12457,10 @@ public void DefineFunction(string module, strin /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12165,6 +12570,10 @@ public void DefineFunction(string module, /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12276,6 +12685,10 @@ public void DefineFunction(string modu /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12389,6 +12802,10 @@ public void DefineFunction(string /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12504,6 +12921,10 @@ public void DefineFunction(str /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12621,6 +13042,10 @@ public void DefineFunction /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12740,6 +13165,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12861,6 +13290,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -12984,6 +13417,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -13109,6 +13546,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -13236,6 +13677,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -13365,6 +13810,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -13472,6 +13921,10 @@ public void DefineFunction(string module /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -13581,6 +14034,10 @@ public void DefineFunction(string mod /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -13692,6 +14149,10 @@ public void DefineFunction(strin /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -13805,6 +14266,10 @@ public void DefineFunction(s /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -13920,6 +14385,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -14037,6 +14506,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -14156,6 +14629,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -14277,6 +14754,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -14400,6 +14881,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -14525,6 +15010,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -14652,6 +15141,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) @@ -14781,6 +15274,10 @@ public void DefineFunctionThe module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +#endif public void DefineFunction(string module, string name, CallerFunc> callback) { if (module is null) diff --git a/src/Linker.DefineFunction.tt b/src/Linker.DefineFunction.tt index 7ccc0456..d7f43155 100644 --- a/src/Linker.DefineFunction.tt +++ b/src/Linker.DefineFunction.tt @@ -21,6 +21,9 @@ using System; using System.Buffers; using System.Runtime.InteropServices; using System.Text; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -44,6 +47,12 @@ foreach (var (hasCaller, resultCount, parameterCount, methodGenerics, delegateTy /// The module name of the function. /// The name of the function. /// The callback for when the function is invoked. +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Defining functions may require runtime code generation for parameter and result types.")] +<# if (resultCount > 0) { #> + [RequiresUnreferencedCode("Defining functions with results may require reflection.")] +<# } #> +#endif public void DefineFunction<#= methodGenerics #>(string module, string name, <#= delegateType #> callback) { if (module is null) diff --git a/src/Memory.cs b/src/Memory.cs index 45189440..488d9755 100644 --- a/src/Memory.cs +++ b/src/Memory.cs @@ -44,11 +44,51 @@ public Memory(Store store, long minimum = 0, long? maximum = null, bool is64Bit Maximum = maximum; Is64Bit = is64Bit; IsShared = false; - - var typeHandle = Native.wasmtime_memorytype_new((ulong)minimum, maximum is not null, (ulong)(maximum ?? 0), is64Bit, IsShared); + + #if WASMTIME_DEV + #if NET5_0_OR_GREATER + byte pageSizeLog2 = (byte)Math.Log2(PageSize); + #else + byte pageSizeLog2 = (byte)(Math.Log(PageSize) / Math.Log(2)); + #endif + var typeError = Native.wasmtime_memorytype_new( + (ulong)minimum, + maximum is not null, + (ulong)(maximum ?? 0), + is64Bit, + IsShared, + pageSizeLog2, + out IntPtr typeHandle); + + if (typeError != IntPtr.Zero) + { + throw WasmtimeException.FromOwnedError(typeError); + } + try { + var memError = Native.wasmtime_memory_new(store.Context.handle, typeHandle, out this.memory); + GC.KeepAlive(store); + + if (memError != IntPtr.Zero) + { + throw WasmtimeException.FromOwnedError(memError); + } + } + finally + { + Native.wasm_memorytype_delete(typeHandle); + } + #else + var typeHandle = Native.wasmtime_memorytype_new( + (ulong)minimum, + maximum is not null, + (ulong)(maximum ?? 0), + is64Bit, + IsShared); + try + { var error = Native.wasmtime_memory_new(store.Context.handle, typeHandle, out this.memory); GC.KeepAlive(store); @@ -61,8 +101,9 @@ public Memory(Store store, long minimum = 0, long? maximum = null, bool is64Bit { Native.wasm_memorytype_delete(typeHandle); } + #endif } - + /// /// The size, in bytes, of a WebAssembly memory page. /// @@ -574,6 +615,7 @@ internal Memory(Store store, ExternMemory memory) } Is64Bit = Native.wasmtime_memorytype_is64(typeHandle); + IsShared = Native.wasmtime_memorytype_isshared(typeHandle); } finally { @@ -601,8 +643,26 @@ internal static class Native [DllImport(Engine.LibraryName)] public static extern IntPtr wasmtime_memory_type(IntPtr context, in ExternMemory memory); +#if WASMTIME_DEV + [DllImport(Engine.LibraryName)] + public static extern IntPtr wasmtime_memorytype_new( + ulong min, + [MarshalAs(UnmanagedType.I1)] bool max_present, + ulong max, + [MarshalAs(UnmanagedType.I1)] bool is_64, + [MarshalAs(UnmanagedType.I1)] bool shared, + byte page_size_log2, + out IntPtr ret); +#else + [DllImport(Engine.LibraryName)] - public static extern IntPtr wasmtime_memorytype_new(ulong min, [MarshalAs(UnmanagedType.I1)] bool max_present, ulong max, [MarshalAs(UnmanagedType.I1)] bool is_64, [MarshalAs(UnmanagedType.I1)] bool shared); + public static extern IntPtr wasmtime_memorytype_new( + ulong min, + [MarshalAs(UnmanagedType.I1)] bool max_present, + ulong max, + [MarshalAs(UnmanagedType.I1)] bool is_64, + [MarshalAs(UnmanagedType.I1)] bool shared); +#endif [DllImport(Engine.LibraryName)] public static extern ulong wasmtime_memorytype_minimum(IntPtr type); @@ -615,6 +675,10 @@ internal static class Native [return: MarshalAs(UnmanagedType.I1)] public static extern bool wasmtime_memorytype_is64(IntPtr type); + [DllImport(Engine.LibraryName)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool wasmtime_memorytype_isshared(IntPtr type); + [DllImport(Engine.LibraryName)] public static extern void wasm_memorytype_delete(IntPtr handle); } diff --git a/src/Result.cs b/src/Result.cs index 1dc2cb15..e039a96f 100644 --- a/src/Result.cs +++ b/src/Result.cs @@ -1,4 +1,7 @@ using System; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -245,7 +248,15 @@ public interface IFunctionResultBuilder internal static class TypeExtensions { - public static Type? TryGetResultInterface(this Type type) +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:DynamicallyAccessedMembers", + Justification = "The interfaces we're looking for (IActionResult and IFunctionResult) are part of the type definition and will be preserved.")] +#endif + public static Type? TryGetResultInterface( +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] +#endif + this Type type) { foreach (var @interface in type.GetInterfaces()) { @@ -264,12 +275,20 @@ internal static class TypeExtensions return null; } - public static bool IsResultType(this Type type) + public static bool IsResultType( +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] +#endif + this Type type) { return type.TryGetResultInterface() != null; } - public static Type? GetResultInnerType(this Type type) + public static Type? GetResultInnerType( +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] +#endif + this Type type) { var result = type.TryGetResultInterface(); if (result == null) @@ -291,4 +310,4 @@ public static bool IsResultType(this Type type) throw new ArgumentException("Type is not a recognised Result type"); } } -} +} \ No newline at end of file diff --git a/src/ReturnTypeFactory.cs b/src/ReturnTypeFactory.cs index 235b9775..7ba27304 100644 --- a/src/ReturnTypeFactory.cs +++ b/src/ReturnTypeFactory.cs @@ -3,6 +3,9 @@ using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -13,6 +16,14 @@ interface IReturnTypeFactory internal static class ReturnTypeFactory { +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating factory instances requires runtime code generation which is not supported with AOT compilation.")] + [RequiresUnreferencedCode("Creating factory instances requires reflection which may break with trimming.")] + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:MakeGenericType", + Justification = "The generic types are constrained by the function signature and will be available at runtime.")] + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:DynamicallyAccessedMembers", + Justification = "The factory types have parameterless constructors by design.")] +#endif public static IReturnTypeFactory Create() { // First, check if the value is a result builder @@ -116,6 +127,10 @@ internal class FunctionResultFactory { private readonly IReturnTypeFactory _valueFactory; +#if NET5_0_OR_GREATER + [RequiresUnreferencedCode("Calls Wasmtime.ReturnTypeFactory.Create()")] + [RequiresDynamicCode("Calls Wasmtime.ReturnTypeFactory.Create()")] +#endif public FunctionResultFactory() { _valueFactory = ReturnTypeFactory.Create(); @@ -141,6 +156,10 @@ internal class NonTupleTypeFactory { private readonly IValueRawConverter converter; +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "NonTupleTypeFactory is instantiated through reflection-based code paths that are already marked with RequiresDynamicCode.")] +#endif public NonTupleTypeFactory() { converter = ValueRaw.Converter(); @@ -163,6 +182,11 @@ internal abstract class BaseTupleFactory { protected TFunc Factory { get; } +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2060:MakeGenericMethod", + Justification = "The ValueTuple.Create method is available for all tuple arities used.")] + [RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")] +#endif protected BaseTupleFactory() { // Get all the generic arguments of TFunc. All of the Parameters, followed by the return type @@ -193,6 +217,10 @@ internal class TupleFactory2 private readonly IValueRawConverter converterA; private readonly IValueRawConverter converterB; +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple factories are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif public TupleFactory2() { converterA = ValueRaw.Converter(); @@ -220,6 +248,10 @@ internal class TupleFactory3 private readonly IValueRawConverter converterB; private readonly IValueRawConverter converterC; +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple factories are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif public TupleFactory3() { converterA = ValueRaw.Converter(); @@ -250,6 +282,10 @@ internal class TupleFactory4 private readonly IValueRawConverter converterC; private readonly IValueRawConverter converterD; +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple factories are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif public TupleFactory4() { converterA = ValueRaw.Converter(); @@ -283,6 +319,10 @@ internal class TupleFactory5 private readonly IValueRawConverter converterD; private readonly IValueRawConverter converterE; +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple factories are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif public TupleFactory5() { converterA = ValueRaw.Converter(); @@ -319,6 +359,10 @@ internal class TupleFactory6 private readonly IValueRawConverter converterE; private readonly IValueRawConverter converterF; +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple factories are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif public TupleFactory6() { converterA = ValueRaw.Converter(); @@ -358,6 +402,10 @@ internal class TupleFactory7 private readonly IValueRawConverter converterF; private readonly IValueRawConverter converterG; +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple factories are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif public TupleFactory7() { converterA = ValueRaw.Converter(); @@ -387,4 +435,4 @@ public override TReturn Create(StoreContext storeContext, Store store, IntPtr tr ); } } -} +} \ No newline at end of file diff --git a/src/Value.cs b/src/Value.cs index eff55005..95254672 100644 --- a/src/Value.cs +++ b/src/Value.cs @@ -217,7 +217,7 @@ internal struct Value { public void Release(Store store) { - Native.wasmtime_val_unroot(store.Context.handle, this); + Native.wasmtime_val_unroot(this); GC.KeepAlive(store); } @@ -470,7 +470,7 @@ public static class Native public delegate void Finalizer(IntPtr data); [DllImport(Engine.LibraryName)] - public static extern void wasmtime_val_unroot(IntPtr context, in Value val); + public static extern void wasmtime_val_unroot(in Value val); [DllImport(Engine.LibraryName)] [return: MarshalAs(UnmanagedType.I1)] @@ -480,7 +480,7 @@ public static class Native public static extern IntPtr wasmtime_externref_data(IntPtr context, in ExternRef externref); [DllImport(Engine.LibraryName)] - public static extern void wasmtime_externref_unroot(IntPtr context, in ExternRef externref); + public static extern void wasmtime_externref_unroot(in ExternRef externref); [DllImport(Engine.LibraryName)] public static extern void wasmtime_externref_from_raw(IntPtr context, uint raw, out ExternRef @out); @@ -531,6 +531,8 @@ internal struct AnyRef private uint __private1; private uint __private2; + + private IntPtr __private3; } [StructLayout(LayoutKind.Sequential)] @@ -541,5 +543,7 @@ internal struct ExternRef private uint __private1; private uint __private2; + + private IntPtr __private3; } -} +} \ No newline at end of file diff --git a/src/ValueRaw.cs b/src/ValueRaw.cs index 180adc34..3b7db52c 100644 --- a/src/ValueRaw.cs +++ b/src/ValueRaw.cs @@ -1,6 +1,9 @@ using System; using System.Reflection; using System.Runtime.InteropServices; +#if NET5_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif namespace Wasmtime { @@ -31,6 +34,11 @@ internal unsafe struct ValueRaw [FieldOffset(0)] public IntPtr funcref; +#if NET5_0_OR_GREATER + [RequiresDynamicCode("Creating converter instances for tuple types requires runtime code generation which is not supported with AOT compilation.")] + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL3050:RequiresDynamicCode", + Justification = "Tuple converters require MakeGenericType which is annotated with RequiresDynamicCode.")] +#endif public static IValueRawConverter Converter() { // Ensure we are on a little endian system. For big endian, we would need @@ -273,7 +281,7 @@ private GenericValueRawConverter() } finally { - Value.Native.wasmtime_externref_unroot(storeContext.handle, externref); + Value.Native.wasmtime_externref_unroot(externref); } } @@ -323,7 +331,7 @@ public void Box(StoreContext storeContext, Store store, ref ValueRaw valueRaw, T { // We still must unroot the old externref afterwards because // wasmtime_externref_to_raw doesn't transfer ownership. - Value.Native.wasmtime_externref_unroot(storeContext.handle, externref); + Value.Native.wasmtime_externref_unroot(externref); } } @@ -336,8 +344,18 @@ internal class Tuple2ValueRawConverter { public static readonly Tuple2ValueRawConverter Instance = new(); - private readonly IValueRawConverter Converter1 = ValueRaw.Converter(); - private readonly IValueRawConverter Converter2 = ValueRaw.Converter(); + private readonly IValueRawConverter Converter1; + private readonly IValueRawConverter Converter2; + +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple converters are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif + public Tuple2ValueRawConverter() + { + Converter1 = ValueRaw.Converter(); + Converter2 = ValueRaw.Converter(); + } public (T1, T2) Unbox(StoreContext storeContext, Store store, in ValueRaw valueRaw) { @@ -365,9 +383,20 @@ internal class Tuple3ValueRawConverter { public static Tuple3ValueRawConverter Instance = new(); - private readonly IValueRawConverter Converter1 = ValueRaw.Converter(); - private readonly IValueRawConverter Converter2 = ValueRaw.Converter(); - private readonly IValueRawConverter Converter3 = ValueRaw.Converter(); + private readonly IValueRawConverter Converter1; + private readonly IValueRawConverter Converter2; + private readonly IValueRawConverter Converter3; + +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple converters are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif + public Tuple3ValueRawConverter() + { + Converter1 = ValueRaw.Converter(); + Converter2 = ValueRaw.Converter(); + Converter3 = ValueRaw.Converter(); + } public (T1, T2, T3) Unbox(StoreContext storeContext, Store store, in ValueRaw valueRaw) { @@ -397,10 +426,22 @@ internal class Tuple4ValueRawConverter { public static Tuple4ValueRawConverter Instance = new(); - private readonly IValueRawConverter Converter1 = ValueRaw.Converter(); - private readonly IValueRawConverter Converter2 = ValueRaw.Converter(); - private readonly IValueRawConverter Converter3 = ValueRaw.Converter(); - private readonly IValueRawConverter Converter4 = ValueRaw.Converter(); + private readonly IValueRawConverter Converter1; + private readonly IValueRawConverter Converter2; + private readonly IValueRawConverter Converter3; + private readonly IValueRawConverter Converter4; + +#if NET5_0_OR_GREATER + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", + Justification = "Tuple converters are only instantiated through reflection which is already marked with RequiresDynamicCode.")] +#endif + public Tuple4ValueRawConverter() + { + Converter1 = ValueRaw.Converter(); + Converter2 = ValueRaw.Converter(); + Converter3 = ValueRaw.Converter(); + Converter4 = ValueRaw.Converter(); + } public (T1, T2, T3, T4) Unbox(StoreContext storeContext, Store store, in ValueRaw valueRaw) { @@ -426,4 +467,4 @@ public void Box(StoreContext storeContext, Store store, ref ValueRaw valueRaw, ( } } } -} +} \ No newline at end of file diff --git a/src/Wasmtime.csproj b/src/Wasmtime.csproj index 28db8861..b65519cc 100644 --- a/src/Wasmtime.csproj +++ b/src/Wasmtime.csproj @@ -20,6 +20,7 @@ https://github.com/bytecodealliance/wasmtime-dotnet true true + true Update Wasmtime to $(WasmtimeVersion). A .NET API for Wasmtime, a standalone WebAssembly runtime webassembly, .net, wasm, wasmtime @@ -37,6 +38,10 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu true + + $(DefineConstants);WASMTIME_DEV + + @@ -45,6 +50,8 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu + + @@ -107,6 +114,7 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu linux-x64 tar.xz libwasmtime.so + libwasmtime.a @@ -116,6 +124,7 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu linux-arm64 tar.xz libwasmtime.so + libwasmtime.a @@ -125,6 +134,7 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu osx-x64 tar.xz libwasmtime.dylib + libwasmtime.a @@ -134,6 +144,7 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu osx-arm64 tar.xz libwasmtime.dylib + libwasmtime.a @@ -143,6 +154,7 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu win-x64 zip wasmtime.dll + wasmtime.lib @@ -152,6 +164,7 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu win-arm64 zip wasmtime.dll + wasmtime.lib @@ -183,10 +196,14 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu runtimes/%(Wasmtime.RID)/native/%(Wasmtime.LibraryFilename) + + runtimes/%(Wasmtime.RID)/native/%(Wasmtime.StaticLibraryFilename) + - + PreserveNewest @@ -195,4 +212,4 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu - + \ No newline at end of file diff --git a/src/build/wasmtime.targets b/src/build/wasmtime.targets new file mode 100644 index 00000000..40c37efe --- /dev/null +++ b/src/build/wasmtime.targets @@ -0,0 +1,69 @@ + + + $(MSBuildThisFileDirectory)..\runtimes + $(MSBuildThisFileDirectory)..\obj + false + + + + + + + + + + + + + + + + + + + + + + + + + + + <_SourceItemsToCopyToOutputDirectory + Remove="@(_SourceItemsToCopyToOutputDirectory->'%(Identity)')" + Condition="'%(Filename)%(Extension)' == 'libwasmtime.so' Or + '%(Filename)%(Extension)' == 'libwasmtime.dylib' Or + '%(Filename)%(Extension)' == 'libwasmtime.a' Or + '%(Filename)%(Extension)' == 'wasmtime.dll' Or + '%(Filename)%(Extension)' == 'wasmtime.lib'" /> + + + + + + + + + + \ No newline at end of file diff --git a/src/buildTransitive/wasmtime.targets b/src/buildTransitive/wasmtime.targets new file mode 100644 index 00000000..d6c2d737 --- /dev/null +++ b/src/buildTransitive/wasmtime.targets @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/Wasmtime.Tests.csproj b/tests/Wasmtime.Tests.csproj index a13c361c..523f59d5 100644 --- a/tests/Wasmtime.Tests.csproj +++ b/tests/Wasmtime.Tests.csproj @@ -16,6 +16,12 @@ + + + PreserveNewest + + + @@ -30,4 +36,4 @@ true - + \ No newline at end of file diff --git a/tests/xunit.runner.json b/tests/xunit.runner.json new file mode 100644 index 00000000..185353ff --- /dev/null +++ b/tests/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", + "parallelizeTestCollections": false, + "maxParallelThreads": 1 +} \ No newline at end of file