-
Notifications
You must be signed in to change notification settings - Fork 2
Add support for C# 10 implicit global usings #93
Copy link
Copy link
Closed
Labels
Area: EntityRelates to the core data data structure for modeling topic entities.Relates to the core data data structure for modeling topic entities.Priority: 0Priority: 1Severity 0: Nice to haveStatus 5: CompleteTask is considered complete, and ready for deployment.Task is considered complete, and ready for deployment.Type: ImprovementImproves the functionality or interface of an existing feature.Improves the functionality or interface of an existing feature.
Milestone
Metadata
Metadata
Assignees
Labels
Area: EntityRelates to the core data data structure for modeling topic entities.Relates to the core data data structure for modeling topic entities.Priority: 0Priority: 1Severity 0: Nice to haveStatus 5: CompleteTask is considered complete, and ready for deployment.Task is considered complete, and ready for deployment.Type: ImprovementImproves the functionality or interface of an existing feature.Improves the functionality or interface of an existing feature.
C# 10 introduced support for Implicit Global Usings, which automatically add common namespaces based on the target SDK in the
csprojfile. This can reduce the number ofusingstatements needed on each class.Enabling
Implicit global usings can be enabled in the
csprojfile by setting the following property:Limitations
While this is advertised as a C# 10 feature, it's actually dependent on the .NET 6 SDK, due to tooling integrated with
dotnet(and, under the hood,msbuild). Since we have no intention of upgrading the OnTopic library to .NET 6 anytime soon (in order to maintain backward compatibility) this could be a problem. That said, so long as the latest version of the .NET SDK is used to compile the project, this may still be supported. TBD.Workaround
If this is not supported without upgrading the project to .NET 6, we can work around it by instead taking advantage of C# 10's global using statements and explicitly setting up the ones that come with the SDK—as well as any others we want to take advantage of.
Implicit Using Directives
With the
Microsoft.NET.Sdk, we get the following implicit usings:With the
Microsoft.NET.Sdk.Web, we additionally get: