dotnet / dotnet/project-system

Up-to-Date Check can skip a build that should run and fail.

Open
#7,859 4 comments 0 reactions 1 assignee Claimed by @drewnoakes View on GitHub
Feature-Up-to-date Triage-Investigate
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

## Visual Studio Version

Version 17.2.0 Preview 1.0 [32121.159.main]

## Summary

We can get into a situation where running a regular build on a project will lead to an apparent success (because the Fast Up-to-Date Check skips it) when it should actually fail with an error.

## Steps to Reproduce

1. Create a new C# Console application targeting .NET 6.0.
2. Add the following to Program.cs:
```
var dictionary = new Dictionary();

dictionary.Keys.Contains("hello world");
```
3. In Solution Explorer, expand Dependencies | Analyzers | Microsoft.CodeAnalysis.CSharp.NetAnalyzers.
4. Right click on "CA1841: Prefer Dictionary.Contains methods" and set the severity to "Error".
5. Run the application with Ctrl+F5. The build will succeed and the application will run because we're skipping the analyzers, even though the analyzer would produce an error.
6. Close the window opened by the app.
7. Right-click on the project in Solution Explorer and select "Build".

## Expected Behavior

The project will build, and the build will fail due to the CA1841 errors created by the analyzer.

## Actual Behavior

The Fast Up-to-Date Check skips the build of the project, and it appears to succeed.

## User Impact

Build appears to succeed where it should fail.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.