GithubHelp home page GithubHelp logo

areisler / visual-studio-intellisense-errors Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 51 KB

Contains a repro of a Visual Studio IntelliSense problem showing build warnings as errors

License: Apache License 2.0

C# 100.00%

visual-studio-intellisense-errors's Introduction

visual-studio-intellisense-errors

Contains a repro for a problem where Roslyn analyzer warnings are wrongly shown as errors in Visual Studio IntelliSense design-time-build.

Problem summary

This repo contains a code sample showing a problem in Visual Studio IntelliSense behavior. The sample contains a class library, which builds just fine when running through the compiler, but Visual Studio displays IntelliSense errors in the Error Windows and in the code with underlined squiggles.

Detailed repro steps

Execute the steps

Start Visual Studio 2019/2022 and execute the following steps:

  1. Clone this repo
  2. Open the src\RoslynIntellisenseErrorsRepro.sln solution
  3. Build the solution
  4. Close and reopen the solution
  5. Open the \src\VisualStudioIntellisenseErrors\FxCopRules\CA1062\Violation.cs file
  6. Open the Visual Studio ErrorList
  7. Change the issue filter to show Build + IntelliSense

Important: It is required to reopen Visual Studio after the repo was cloned and the solution build for the first time (including first package restore)

Observe the problem

Once the IntelliSense has completed its initialization the ErrorList will show one detected issue for the rule CA1062 as Error

despite the ruleset configuration sets its severity to Warning and the project property TreatWarningsAsErrors configured as <TreatWarningsAsErrors>false</TreatWarningsAsErrors>:

image.png

Steps to create the sample app from scratch

General preparation steps:

  1. Install .NET Framework 4.8 SDK
  2. Use a latest version of the Visual Studio 2019/2022 (for version details see separate section below)
  3. Create a new project using the Windows Class Library (.NET Framework) template
  4. Add Analyzer package Microsoft.CodeAnalysis.NetAnalyzers, 6.0.0 (nuget.org)
  5. Create a new ruleset file configured with e.g. rule CA1062 set to Warning (see default.ruleset). The configuration of all the other rules from the same NuGet Analyzer package does not matter for the purpose of this repro.
  6. Add code which violates against the CA1062 rule (see Violation.cs).

Special preparation steps required to reveal the problem:

  1. Create build\default.props containing the following properties:
  <PropertyGroup>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>
  1. Add the following properties to the project file:
  <Import Project="..\..\build\default.props" />
  <PropertyGroup>
    <CodeAnalysisRuleSet>..\default.ruleset</CodeAnalysisRuleSet>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
  </PropertyGroup>

Tested with Visual Studio versions


Microsoft Visual Studio Enterprise 2019
Version 16.11.7
VisualStudio.16.Release/16.11.7+31911.196
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Enterprise


Microsoft Visual Studio Enterprise 2022
Version 17.0.2
VisualStudio.17.Release/17.0.2+31919.166
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Enterprise

visual-studio-intellisense-errors's People

Contributors

areisler avatar

Stargazers

 avatar

Watchers

 avatar  avatar

visual-studio-intellisense-errors's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.