project-system icon indicating copy to clipboard operation
project-system copied to clipboard

Indicate if a property is defined in the project file or not

Open tmeschter opened this issue 4 years ago • 4 comments

Summary

This grew out of the investigation of #6931.

For string properties, we show the unevaluated value largely so the user can understand how the property is currently defined. We also use it as the basis for edits that will go into the project file, and (as we see in #6931) the existing definition is not necessarily a good candidate for that.

It would help if the UI could distinguish between "this is the value in your project file" and "this is the default you get if it is not defined in your project file". To do that, I propose the following changes:

  1. Update IUIPropertyValue in CPS to include a ValueDefinedInContext boolean property.
  2. Update the back end in dotnet/project-system as follows:
    1. If the .csproj itself contains a definition of the property, set ValueDefinedInContext to "true".
    2. If not, set ValueDefinedInContext to "false".
  3. Update the UI as follows:
    1. If ValueDefinedInContext is true, then the unevaluated value is shown as editable text (that is, the current behavior)
    2. If not, then the unevaluated value is shown only as watermark text which disappears once the user starts entering their own text.

User Impact

This will help the user understand when the unevaluated value is coming from the project file or some other import, and to a lesser extent will nudge them away from creating problematic recursive definitions such as we see in #6931.

tmeschter avatar Dec 16 '21 20:12 tmeschter

I agree it could be useful to know this information in the UI but am not sure that always hiding the unevaluated value for externally assigned properties is good for all property types. One counter example would be the packaging properties which reuse common properties quite broadly, which is useful to understand.

We could add metadata to our string properties to control when we hide externally assigned unevaluated values.

drewnoakes avatar Dec 16 '21 21:12 drewnoakes

In the proposal we would always show the unevaluated value, as we do now. But if it isn't defined in the project we would show it as a watermark rather than editable text. I've updated the proposal to clarify.

tmeschter avatar Dec 16 '21 22:12 tmeschter

This value will also determine whether the reset property value command is enabled or not

adamint avatar Apr 21 '22 00:04 adamint

PR tracked in https://devdiv.visualstudio.com/DevDiv/_git/CPS/pullrequest/394961

adamint avatar Apr 22 '22 18:04 adamint