Inserting code at the first left brace past where Roslyn claims the entry point is doesn't seem to be very reliable
I've been trying to get 'where Roslyn tells Disasmo the entrypoint is' to match up with 'where the entry point actually is' with a disappointingly low success rate....
class Program
{/*disasmo{*/System.Linq.Enumerable.ToList(System.Linq.Enumerable.Where(typeof(TestHarness.IndexOfTesting.InvertedIndexOfAdder).GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic), w => w.DeclaringType == typeof(TestHarness.IndexOfTesting.InvertedIndexOfAdder))).ForEach(m => System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(m.MethodHandle));System.Console.WriteLine(" ");System.Console.ReadLine();System.Environment.Exit(0);/*}disasmo*/
static void Main(string[] args)
{
class Program
{
static void Main(string[] args)
{
//for (int i = 0; i < 1000; i++)
//{/*disasmo{*/System.Linq.Enumerable.ToList(System.Linq.Enumerable.Where(typeof(TestHarness.IndexOfTesting.InvertedIndexOfAdder).GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic), w => w.DeclaringType == typeof(TestHarness.IndexOfTesting.InvertedIndexOfAdder))).ForEach(m => System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(m.MethodHandle));System.Console.WriteLine(" ");System.Console.ReadLine();System.Environment.Exit(0);/*}disasmo*/
Perhaps Mono.Cecil to add a module initializer, or hijacking the entrypoint to a different file, might be more reliable?
@Zhentar yeah that was a quick solution I am going to remove ;-)
No worries, I've written enough terrible hack prototypes to know it when I see one 😁 I report this partly as 'this is the particular hack that broke for me' and partly as a way of saying 'I like what your code does do enough to care about what it doesn't do' 😉
Closing since Disasmo no longer does it