Skip to content

Commit

Permalink
fix: fail the build with a descriptive error message when the users t…
Browse files Browse the repository at this point in the history
…ries to export functions with parameters
  • Loading branch information
mhmd-azeez committed Nov 20, 2023
1 parent ef3f034 commit aa7eb87
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Extism.Pdk.MSBuild/FFIGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit aa7eb87

Please sign in to comment.