dotnet / dotnet/msbuild

Warning for properties defined in project but never read

Open
#4,431 3 comments 0 reactions 0 assignees View on GitHub
Area: Debuggability Feature: Warning Waves triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

Since MSBuild allows defining any property, it's very common to define the wrong property accidentally--either via typo, or by guessing a wrong name. When this happens, it's rarely clear what has gone wrong.

If there was a warning that fired when a project defined a property that was never read, that could help. Ideally it would also do some sort of edit-distance based "did you mean X, Y, or Z?" like many command line applications do.

This probably should apply only to the project file itself. It's reasonable for `Directory.Build.props` and friends to define properties for all projects that are consumed by only some of them.

Evidently cmake has this: https://twitter.com/johnregehr/status/1134108018738524167

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how properties are defined and read in an MSBuild project file; the issue does not name implementation files or tests. Compare the requested behavior with the stated Directory.Build.props exception and the linked CMake example. Done means unused properties in the project file produce a warning, with a considered edit-distance suggestion where appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.