admin管理员组文章数量:1315357
Our team is developing a WPF project in Visual Studio 2022, it utilizes Entity Framework Core and Microsoft Dependency Injection. Whenever somebody implements a new class accessing our database context, they will have the issue that ToListAsync()
, AnyAsync()
, FirstOrDefaultAsync()
and so on aren't known, because those are extension methods in the namespace Microsoft.EntityFrameworkCore
. When we use the shortcut CTRL+., we would expect to be able to add the missing using entry.
using Microsoft.EntityFrameworkCore;
But in our project we also use DevExpress and since it comes first alphabetically, this using sneaks in every now and then.
using DevExpress.Xpo;
We don't use DevExpress.Xpo
at all, it's just included inside of DevExpress.Wpf.Core.Extensions
which on the other hand is included inside of DevExpress.Wpf
which we use.
Every now and then, it still sneaks in when we try to add missing usings for our database operations. It's not always just us fetting to select the second entry instead of just hitting Enter, sometimes IntelliSense takes some time loading more suggestions and resets to the topmost item last second when it's done.
The same keeps happening when we try to resolve services from our IServiceProvider
.
We would need Microsoft.Extensions.DependencyInjection
for GetService()
or GetRequiredService()
which also exists inside of DevExpress.Mvvm.POCO
. This namespace is implemented inside of DevExpress.Mvvm
which we use.
Instead of
using Microsoft.Extensions.DependencyInjection;
this one sneaks in.
using DevExpress.Mvvm.POCO;
Both namespaces lead to strange runtime exceptions when testing and can become very time consuming when not instantly identified. I am now looking for a way to either remove those from the suggestion list, even when available inside of the project or at least prioritize the suggested namespaces.
Is there some option or plugin that could help me with that?
Our team is developing a WPF project in Visual Studio 2022, it utilizes Entity Framework Core and Microsoft Dependency Injection. Whenever somebody implements a new class accessing our database context, they will have the issue that ToListAsync()
, AnyAsync()
, FirstOrDefaultAsync()
and so on aren't known, because those are extension methods in the namespace Microsoft.EntityFrameworkCore
. When we use the shortcut CTRL+., we would expect to be able to add the missing using entry.
using Microsoft.EntityFrameworkCore;
But in our project we also use DevExpress and since it comes first alphabetically, this using sneaks in every now and then.
using DevExpress.Xpo;
We don't use DevExpress.Xpo
at all, it's just included inside of DevExpress.Wpf.Core.Extensions
which on the other hand is included inside of DevExpress.Wpf
which we use.
Every now and then, it still sneaks in when we try to add missing usings for our database operations. It's not always just us fetting to select the second entry instead of just hitting Enter, sometimes IntelliSense takes some time loading more suggestions and resets to the topmost item last second when it's done.
The same keeps happening when we try to resolve services from our IServiceProvider
.
We would need Microsoft.Extensions.DependencyInjection
for GetService()
or GetRequiredService()
which also exists inside of DevExpress.Mvvm.POCO
. This namespace is implemented inside of DevExpress.Mvvm
which we use.
Instead of
using Microsoft.Extensions.DependencyInjection;
this one sneaks in.
using DevExpress.Mvvm.POCO;
Both namespaces lead to strange runtime exceptions when testing and can become very time consuming when not instantly identified. I am now looking for a way to either remove those from the suggestion list, even when available inside of the project or at least prioritize the suggested namespaces.
Is there some option or plugin that could help me with that?
Share Improve this question edited Jan 31 at 8:24 Clemens 128k13 gold badges159 silver badges286 bronze badges asked Jan 30 at 9:36 E4estE4est 951 silver badge10 bronze badges 2- usually you can chose which of the suggested options you want to apply. So if a name was found in two different namespaces, you should be able to chose between them. – MakePeaceGreatAgain Commented Jan 30 at 9:40
- 2 did you consider global usings? stackoverflow/questions/75170808/… – ASh Commented Jan 30 at 9:40
2 Answers
Reset to default 1You can configure IntelliSense to show or hide items from unimported namespaces.
Go to Tools > Options > Text Editor > C# > IntelliSense
and look for the option Show items from unimported namespaces
. Disabling this might help reduce the unwanted suggestions.
If you are using C# 10, you can import the correct namespace once and for all:
global using Microsoft.EntityFrameworkCore;
global using Microsoft.Extensions.DependencyInjection;
This will make the namespace available in entire project. If you have multiple projects, you'd have to repeat it once in each project.
本文标签: cVisual Studio Preventblacklist or reorder namespace suggestionsStack Overflow
版权声明:本文标题:c# - Visual Studio: Prevent, blacklist or reorder namespace suggestions - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741975679a2408106.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论