Disasmo icon indicating copy to clipboard operation
Disasmo copied to clipboard

Inserting code at the first left brace past where Roslyn claims the entry point is doesn't seem to be very reliable

Open Zhentar opened this issue 6 years ago • 2 comments

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 avatar Feb 15 '19 05:02 Zhentar

@Zhentar yeah that was a quick solution I am going to remove ;-)

EgorBo avatar Feb 16 '19 20:02 EgorBo

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' 😉

Zhentar avatar Feb 19 '19 04:02 Zhentar

Closing since Disasmo no longer does it

EgorBo avatar Sep 18 '22 01:09 EgorBo