We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It seems that #29 has more ramifications with respect to entry-point Main.
Main
If Main is in a class in a namespace:
public static void Print(MethodBase method) => Console.WriteLine($"{method.DeclaringType.FullName}::{method.Name}"); namespace MyApp1 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } }
It gets called:
MyApp1.Program::Main
If there are two Main:
public static void Print(MethodBase method) => Console.WriteLine($"{method.DeclaringType.FullName}::{method.Name}"); namespace MyApp1 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } } namespace MyApp2 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } }
then the latter of the two is called:
MyApp2.Program::Main
If there is also a Main at root, however:
public static void Print(MethodBase method) => Console.WriteLine($"{method.DeclaringType.FullName}::{method.Name}"); public static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); namespace MyApp1 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } } namespace MyApp2 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } }
then it is called instead:
UserQuery::Main
If there is a Main in a class without a namespace:
public static void Print(MethodBase method) => Console.WriteLine($"{method.DeclaringType.FullName}::{method.Name}"); static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } namespace MyApp1 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } } namespace MyApp2 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } }
then it is called and trumps the other two:
UserQuery+Program::Main
Finally, a Main outside a class and a namespace:
public static void Print(MethodBase method) => Console.WriteLine($"{method.DeclaringType.FullName}::{method.Name}"); public static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } namespace MyApp1 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } } namespace MyApp2 { static class Program { static void Main(string[] args) => Print(MethodBase.GetCurrentMethod()); } }
then it trumps all:
/cc @albahari
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It seems that #29 has more ramifications with respect to entry-point
Main
.If
Main
is in a class in a namespace:It gets called:
If there are two
Main
:then the latter of the two is called:
If there is also a
Main
at root, however:then it is called instead:
If there is a
Main
in a class without a namespace:then it is called and trumps the other two:
Finally, a
Main
outside a class and a namespace:then it trumps all:
/cc @albahari
The text was updated successfully, but these errors were encountered: