Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark entry point with .entrypoint directive #9

Closed
MSDN-WhiteKnight opened this issue Feb 9, 2020 · 0 comments
Closed

Mark entry point with .entrypoint directive #9

MSDN-WhiteKnight opened this issue Feb 9, 2020 · 0 comments
Assignees
Labels
good first issue Good for newcomers
Milestone

Comments

@MSDN-WhiteKnight
Copy link
Owner

MSDN-WhiteKnight commented Feb 9, 2020

When outputting signature of entry point method as CIL assembler code, it should be marked with .entrypoint directive.

Example code:

using System;
using System.Reflection;
using CilBytecodeParser;

class Program
{    
    public static void Main(string[] args)
    {
        Console.WriteLine(CilAnalysis.MethodToText(MethodBase.GetCurrentMethod()));
        Console.ReadKey();
    }    
}

Current output:

.method public hidebysig static void Main(
    string[] args
) cil managed {
 .maxstack 8

          nop
          call       class [mscorlib]System.Reflection.MethodBase [mscorlib]System.Reflection.MethodBase::GetCurrentMethod()
          call       string [CilBytecodeParser]CilBytecodeParser.CilAnalysis::MethodToText(class [mscorlib]System.Reflection.MethodBase)
          call       void [mscorlib]System.Console::WriteLine(string)
          nop
          call       valuetype [mscorlib]System.ConsoleKeyInfo [mscorlib]System.Console::ReadKey()
          pop
          ret
}

Expected output:

.method public hidebysig static void Main(
    string[] args
) cil managed {
 .entrypoint
 .maxstack 8

          nop
          call       class [mscorlib]System.Reflection.MethodBase [mscorlib]System.Reflection.MethodBase::GetCurrentMethod()
          call       string [CilBytecodeParser]CilBytecodeParser.CilAnalysis::MethodToText(class [mscorlib]System.Reflection.MethodBase)
          call       void [mscorlib]System.Console::WriteLine(string)
          nop
          call       valuetype [mscorlib]System.ConsoleKeyInfo [mscorlib]System.Console::ReadKey()
          pop
          ret
}

The Assembly.EntryPoint property can be used to determine what method is an entry point in the given assembly.

Relevant ECMA-335 Specification section: II.15.4.1.2 The .entrypoint directive.

@MSDN-WhiteKnight MSDN-WhiteKnight self-assigned this Jan 6, 2022
@MSDN-WhiteKnight MSDN-WhiteKnight added this to the 2.4 milestone Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant