VS 2022 17.1.3 空新 class
VS 2022 17.1.3 Empty new class
添加新的 class 时,它只使用名称空间创建它,而不使用它。
我之前在VS19中没有这样的问题。我该如何解决?
我尝试重新安装 vs
As said, Try to add new controller class
it would add using
block, but
for new class
it won't, because, your class doesn't use any
additional refereces which need to add initially, in Visual studio
lastest release for adding new class it won't add any using block
since it doesn't has any reference to add.
注意: 如果您在 dotnet core 3.1
之前尝试它,您会发现它会添加 using
块。如下:
Since dotnet 5 and 6
compiler automatically adds a set of using directives
based on the project type. You can get more information on official document here
"When Adding Class which required class reference"
如果您添加其他 self define class
,例如 middleware class
或 startup
class,它将根据需要添加 using directives
。请参阅下面的屏幕截图:
So hope you get the difference already. It’s not an issue, it’s a new
features in latest dotnet release
to redeem repetitive using
directive monotonously.
添加新的 class 时,它只使用名称空间创建它,而不使用它。
我之前在VS19中没有这样的问题。我该如何解决?
我尝试重新安装 vs
As said, Try to add
new controller class
it would addusing
block, but fornew class
it won't, because, your class doesn't use any additional refereces which need to add initially, inVisual studio
lastest release for adding new class it won't add anyusing block
since it doesn't has any reference to add.
注意: 如果您在 dotnet core 3.1
之前尝试它,您会发现它会添加 using
块。如下:
Since
dotnet 5 and 6
compiler automatically adds a set ofusing directives
based on the project type. You canget more information on official document here
"When Adding Class which required class reference"
如果您添加其他 self define class
,例如 middleware class
或 startup
class,它将根据需要添加 using directives
。请参阅下面的屏幕截图:
So hope you get the difference already. It’s not an issue, it’s a new features in
latest dotnet release
to redeem repetitive using directive monotonously.