Skip to content

Add default global usings to Microsoft.NET.Sdk.Web #32451

Closed
dotnet/sdk
#18459
@halter73

Description

@halter73

This is one of the bullet points from #30580. A long list of mostly the same using statements at the top of every ASP.NET Core is intimidating and ultimately unhelpful noise for the most point.

We should consider a set of name spaces that will be imported by default into all cs file in net6.0 projects targeting Microsoft.NET.Sdk.Web.

Here's a strawman proposal for the possible default namespaces to use:

[Edit: updated list as of 6/23]

global using global::System;
global using global::System.Collections.Generic;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Net.Http.Json;
global using global::System.Threading.Tasks;
global using global::Microsoft.AspNetCore.Builder;
global using global::Microsoft.AspNetCore.Hosting;
global using global::Microsoft.AspNetCore.Http;
global using global::Microsoft.AspNetCore.Mvc;
global using global::Microsoft.AspNetCore.Routing;
global using global::Microsoft.Extensions.Configuration;
global using global::Microsoft.Extensions.DependencyInjection;
global using global::Microsoft.Extensions.Hosting;
global using global::Microsoft.Extensions.Logging; 

It's kinda crazy seeing .cs files without usings but I like it a lot.

We of course do need to be careful not to overdo this and introduce a bunch of conflicts or make intellisense too confusing. It's possible the strawman proposal is already a bit much, but I need to play with it more to get a good feeling for how convenient and/or annoying it is.

Metadata

Metadata

Assignees

Labels

area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-hosting

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions