Consider add a new language "C# Program with Namespace"?
Somethings we create a ASP.NET Core MVC demo using LINQPad, but the controller need to be in namespace(instead of in class), this way, code would be a little messy here:
Is that possible to add a "C# Program with Namespace" way, to make the code much simpler(maybe like this):
void Main()
{
WebHost
.CreateDefaultBuilder()
.UseStartup<Startup>()
.UseUrls("https://localhost:55555")
.Build()
.Start();
}
class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app)
{
app.UseMvcWithDefaultRoute();
}
}
}
namespace Controllers
{
public class HomeController : Controller
{
public string Index()
{
return "Hello World";
}
}
}
class EOF {
namespace App
{
class EntryPoint : UserQuery
{
static void Main()
{
WebHost
.CreateDefaultBuilder()
.UseStartup<Startup>()
.UseUrls("https://localhost:55555")
.Build()
.Start();
}
}
public class HomeController : Controller
{
public string Index()
{
return "Hello World";
}
}
class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app)
{
app.UseMvcWithDefaultRoute();
}
}
}
Comments
Note that there's no new language option. The 'C# Program' mode now lets you include namespaces as well as types.
You can also (optionally) keep the main method outside of the namespace declarations, if you need to access a data context: