Ideally it'd be excellent to see this PDK support writing more idiomatic .NET Code via source generation.
For example, turning the Getting Started example from:
using System;
using System.Runtime.InteropServices;
using System.Text.Json;
using Extism;
namespace MyPlugin;
public class Functions
{
public static void Main()
{
// Note: a `Main` method is required for the app to compile
}
[UnmanagedCallersOnly(EntryPoint = "greet")]
public static int Greet()
{
var name = Pdk.GetInputString();
var greeting = $"Hello, {name}!";
Pdk.SetOutput(greeting);
return 0;
}
}
to
using Extism;
namespace MyPlugin;
public partial class Functions
{
[WasmExport(Name = "greet")]
public static string Greet(string name)
{
return $"Hello, {name}";
}
}
with something like this being generated under the covers:
namespace MyPlugin;
public partial class Functions
{
public static void Main() { }
[UnmanagedCallersOnly(EntryPoint = "greet")]
public static int <>__Greet0()
{
var name = global::Extism::Pdk.GetInputString();
var output = Functions::Greet(name);
global::Extism::Pdk.SetOutput(output);
return 0;
}
}
Ideally it'd be excellent to see this PDK support writing more idiomatic .NET Code via source generation.
For example, turning the Getting Started example from:
to
with something like this being generated under the covers: