Indicate if a property is defined in the project file or not
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:
- Update
IUIPropertyValuein CPS to include aValueDefinedInContextboolean property. - Update the back end in dotnet/project-system as follows:
- If the .csproj itself contains a definition of the property, set
ValueDefinedInContextto "true". - If not, set
ValueDefinedInContextto "false".
- If the .csproj itself contains a definition of the property, set
- Update the UI as follows:
- If
ValueDefinedInContextis true, then the unevaluated value is shown as editable text (that is, the current behavior) - If not, then the unevaluated value is shown only as watermark text which disappears once the user starts entering their own text.
- If
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.
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.
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.
This value will also determine whether the reset property value command is enabled or not
PR tracked in https://devdiv.visualstudio.com/DevDiv/_git/CPS/pullrequest/394961