Consider add a new language "C# Program with Namespace"?

edited March 14
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:

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 {
Is that possible to add a "C# Program with Namespace" way, to make the code much simpler(maybe like this):

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

  • I will look into this, but it's quite a lot of work. And it would make working with data contexts messy and complicated.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!