Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show warning when referencing an Item as a Property or viceversa #348

Open
cdmihai opened this issue Nov 13, 2015 · 4 comments
Open

Show warning when referencing an Item as a Property or viceversa #348

cdmihai opened this issue Nov 13, 2015 · 4 comments
Labels
help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. User Experience

Comments

@cdmihai
Copy link
Contributor

cdmihai commented Nov 13, 2015

If you have an item foo but you forget it's an item and you reference it as a property ($(foo)), then MSBuild will just evaluate it to an empty string. This adds to the time it takes to debug the build.

To make debugging easier, MSBuild should emit a warning: "You are referencing the item foo as a property".

@rainersigwald
Copy link
Member

This would potentially save a lot of grief. We may be able to learn from Perl, which has vaguely similar behavior between scalar and array values.

@rainersigwald rainersigwald added the help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. label Nov 17, 2015
@sarajoiner
Copy link
Contributor

For what it's worth, MSBuild already has a related feature, to warn when an uninitialized property is used. (Can be enabled through setting MSBUILDWARNONUNINITIALIZEDPROPERTY=1 or BuildParameters.WarnOnUninitializedProperty = true)

However, when we introduced this feature back in (IIRC) VS 2010, we quickly discovered that all existing targets files used that pattern so frequently (usually when setting up defaults for commonly known properties) that it was, essentially, useless.

So I'd suggest that this also only be available under a flag, at least at first -- I wouldn't be surprised if the existing targets also used this pattern intentionally at times.

@SamB
Copy link
Contributor

SamB commented Dec 3, 2015

@sarajoiner: Couldn't used-uninitialized tracking in MSBUILDWARNONUNINITIALIZEDPROPERTY easily be amended to ignore the use of a property in the Condition for a Property element of the same name? (Just tucking away the "used uninitialized" state for the property while evaluating its condition should work, shouldn't it?)

@Sarabeth-Jaffe-Microsoft Sarabeth-Jaffe-Microsoft added help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. and removed help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. enhancement labels Apr 7, 2017
radical pushed a commit to radical/msbuild that referenced this issue Feb 28, 2020
…0227.2 (dotnet#348)

- Microsoft.Dotnet.Toolset.Internal - 3.1.200-preview.20127.2

Dependency coherency updates

- Microsoft.Net.Compilers - 3.5.0-beta4-20128-01 (parent: Microsoft.Dotnet.Toolset.Internal)
@stan-sz
Copy link
Contributor

stan-sz commented Jan 17, 2024

This is a good idea for #1777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. User Experience
Projects
None yet
Development

No branches or pull requests

6 participants