From aa7eb8751621d3bb35fd633422f5828cfae76fe4 Mon Sep 17 00:00:00 2001 From: Muhammad Azeez Date: Mon, 20 Nov 2023 14:36:35 +0300 Subject: [PATCH] fix: fail the build with a descriptive error message when the users tries to export functions with parameters --- src/Extism.Pdk.MSBuild/FFIGenerator.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Extism.Pdk.MSBuild/FFIGenerator.cs b/src/Extism.Pdk.MSBuild/FFIGenerator.cs index 9674df1..426ebbd 100644 --- a/src/Extism.Pdk.MSBuild/FFIGenerator.cs +++ b/src/Extism.Pdk.MSBuild/FFIGenerator.cs @@ -149,6 +149,12 @@ void extism_print_exception(MonoObject* exc) foreach (var method in exportedMethods) { + if (method.Parameters.Count > 0) + { + var parameterNames = string.Join(",", method.Parameters.Select(p => $"{p.ParameterType.Name} {p.Name}")); + _logError($"Extism doesn't support exporting functions that have parameters: {method.DeclaringType.FullName}.{method.Name}({parameterNames})"); + } + var assemblyFileName = method.Module.Assembly.Name.Name + ".dll"; var attribute = method.CustomAttributes.First(a => a.AttributeType.Name == "UnmanagedCallersOnlyAttribute");