static unsafe void Main(string[] args) { Span <byte> s; //var x = File.OpenWrite("b.dll"); //AheadOfTimeActivator.WriteImplementation<TestClass>(x); //var y = File.OpenWrite("a.dll"); //AheadOfTimeActivator.WriteImplementation<TestClass2>(y); //x.Flush(); //y.Flush(); //var user32 = LibraryActivator.CreateInstance<TestClass>("user32.dll"); //user32.MessageBox(IntPtr.Zero, "SuperInvoke".ToCharArray(), "Hello from SuperInvoke!".ToCharArray(), 0); if (AotTest) { var libBuilder = new LibraryBuilder(); var opts = BuilderOptions.GetDefault(typeof(TestClass2)); libBuilder.Add(opts); #if NET47 var bytes = libBuilder.BuildBytes(); File.WriteAllBytes("c.dll", bytes); #else libBuilder.Build(); #endif } var lib = LibraryActivator.CreateInstance <TestClass2>("user32"); var a = Marshal.StringToHGlobalAnsi("Test 1"); var b = Marshal.StringToHGlobalAnsi("Hello from SuperInvoke!"); lib.MessageBox(default, (char *)a, (char *)b, 0);
public static void Main(string[] args) { var builder = new LibraryBuilder(); builder.Add(BuilderOptions.GetDefault(typeof(GL))); File.WriteAllBytes("il.dll", builder.BuildBytes()); Process.Start ( @"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\ildasm.exe", "/out=\"il.il\" \"il.dll\"" )?.WaitForExit(); }