首页 > 解决方案 > Visual Studio 代码分析器给出无意义的警告

问题描述

在 Dependencies>Analyzers 下的解决方案资源管理器中,我列出了 Microsoft.AspNetCore.Anayzers 和三个问题。

但是,第一个和最后一个没有任何意义,因为我的 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 文件夹。看起来解决方案资源管理器的分析器部分完全损坏,因为它抱怨不存在的代码。

有没有办法重置分析仪,或者我在这里遗漏了一些明显的东西?

标签: visual-studio-2019

解决方案


推荐阅读