visual-studio-2019 - Visual Studio 代码分析器给出无意义的警告
问题描述
在 Dependencies>Analyzers 下的解决方案资源管理器中,我列出了 Microsoft.AspNetCore.Anayzers 和三个问题。
- ASP0000:不要在“ConfigureServices”中调用“IServiceCollection.BuildServiceProvider”
- ASP0001:授权中间件配置错误
- MVC1005:无法将 UseMvc 与端点路由一起使用
但是,第一个和最后一个没有任何意义,因为我的 Startup.cs 中不存在这些问题。这些消息没有指定它们所引用的文件或行号。
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Deliberately blank to see if the message goes away. It does not.
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
//pattern: "{controller=Home}/{action=Index}/{id?}");
pattern: "{action=Index}",
defaults: new { controller = "Home" });
});
}
}
我重新启动了 Visual Studio,清理了解决方案,完成了分析代码和清理>在解决方案上运行代码分析,以管理员身份运行 VS,删除了 .vs 文件夹,删除了 obj 文件夹。看起来解决方案资源管理器的分析器部分完全损坏,因为它抱怨不存在的代码。
有没有办法重置分析仪,或者我在这里遗漏了一些明显的东西?
解决方案
推荐阅读
- bluetooth - 为什么 Fido 在网络蓝牙中被阻止而不是 USB
- ios - 为 UIButton 启用自动调整大小会禁用图像背景
- arduino - Arduino 草图会重复一条指令,即使它没有太多
- angular - Angular html不会将数据传递给组件
- arrays - 如何在反应中推送 JSON 对象数组中的项目?
- numpy - 运行 Kmeans 时如何解决“异常:数据必须是一维”错误
- c++ - 如何使用鼠标滚轮修复放大和缩小?
- c++ - 我们可以将非类纯右值 const 转换为 xvalue 吗?
- ruby-on-rails - 如何修复在我邪恶的向导第一步中没有发生的“验证”
- ios - 带委托的初始化:没有更多上下文的表达式类型不明确