msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

[Built-in analyzer] Item is updated inside a target

Open ladipro opened this issue 3 months ago • 4 comments

Background

This issue tracks one of the BuildCheck analyzers we would like to ship in-box with MSBuild.

Goal

Implement an analyzer with the following rule: No item is attempted to be updated using the Update attribute inside a target.

Notes

While the Update attribute can be added to items inside a target, it is ignored and the transformation is applied to all items of the given type. Implementing this analyzer will likely require introducing TaskParameterMessageKind.UpdateItem to communicate the attempted operation to the analyzer.

ladipro avatar Mar 18 '24 12:03 ladipro

This is a mitigation for #2835.

this functionality is not supported inside targets and the engine silently does nothing

Nit: the problem isn't that the engine does nothing, it's that it ignores the Update attribute, applying the transformation to all items of that type instead of a filtered list.

rainersigwald avatar Mar 18 '24 14:03 rainersigwald

I have updated the description, thank you!

ladipro avatar Mar 18 '24 14:03 ladipro

Related to:

  • #2835
  • #3538

If the engine instead was updated to honor the attribute, this analysis would not be needed. However, it sounds like that isn't an option.

sharwell avatar Mar 20 '24 22:03 sharwell

This is not related to #3538--that's about the update mechanism that has existed ~forever, rather than the Update attribute.

Indeed, honoring the attribute would be a breaking change 😢

rainersigwald avatar Apr 01 '24 18:04 rainersigwald