Skip to content

Instantly share code, notes, and snippets.

@sgaliamov
Created May 2, 2021 15:31
Show Gist options
  • Save sgaliamov/f6dcfe7088951c5782fdec3a75c74b76 to your computer and use it in GitHub Desktop.
Save sgaliamov/f6dcfe7088951c5782fdec3a75c74b76 to your computer and use it in GitHub Desktop.
using static CustomExtensions.Functions;
...
var foo = new DynamicMethod("Foo", typeof(int), new[] { typeof(int) })
.GetILGenerator()
.UseIlluminator(
enableTraceLogger: true, // enable tracing (optional)
Ret(If(Ceq(Ldarg_0(), Ldc_I4_2()), // condition
Ldc_I4_1(), // then
Add(Ldarg_0(), Ldc_I4_3())))) // else
.CreateDelegate<Func<int, int>>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment