[Breaking change]: Windows Forms SDK support for implicit namespaces in C# projects #25438
Closed
1 of 2 tasks
Labels
breaking-change
Indicates a .NET Core breaking change
🏁 Release: .NET 6
Issues and PRs for the .NET 6 release
source incompatible
Source code may encounter a breaking change in behavior when targeting the new version.
Description
Related to #25066
Windows Forms SDK has enabled global usings in .NET 6.0 RC1 in line with the rest of .NET SDK with all guards and requirements outlined in #25066.
Implicit namespace will be enabled by default for C# projects targeting the
net6.0
TFM or higher and usingMicrosoft.NET.Sdk
,Microsoft.NET.Sdk.Web
orMicrosoft.NET.Sdk.Worker
SDK. A generated file containing the default namespaces will be included in the set of files passed to the compiler. Projects using a C# version less than 10 need to explicitly disable this feature.There are three ways to control the namespaces that are included in the project:
<DisableImplicitNamespaceImports>
totrue
or<DisableImplicitNamespaceImports_DotNet>
totrue
in the project file. Refer to SDK support for implicit namespaces in C# projects #25066.<DisableImplicitNamespaceImports_WindowsForms>
totrue
in the project file.<Import>
item group in the project file. For example:These are the implicit namespaces added to projects using by the Windows Forms SDKs:
Version
.NET 6 RC1
Previous behavior
No implicit namespaces are added for applicable C# projects.
New behavior
Implicit namespaces are added via global usings in a generated file in the obj directory. See how to control the list of included implicit namespaces above.
Type of breaking change
Reason for change
These changes in the SDK are made to reduce the amount of boilerplate
using
statements that appear at the top of most C# projects.Recommended action
This feature will be enabled by default and for most users, no action will need to be taken. However, the introduction of this mechanism can cause type name conflicts with the namespaces listed above. In those cases, action need to be take to modify the list of implicit namespaces.
Feature area
C#, Windows Forms
Affected APIs
None.
The text was updated successfully, but these errors were encountered: