Skip to content

Validate C# DefineConstants input - #9612

Open
adamint wants to merge 9 commits into
mainfrom
dev/adamint/fix-define-constants-validation
Open

adamint wants to merge 9 commits into
mainfrom
dev/adamint/fix-define-constants-validation

Conversation

@adamint

@adamint adamint commented Dec 5, 2024 •

Copy link
Copy Markdown
Member

As can be seen in this bug, you can add arbitrary semicolons in the DefineConstants control and these will be saved. This PR

  1. Adds tests for KeyValuePairListEncoding
  2. Allows for different separators
  3. Since the CPS controls hands the property interceptor a comma-separated list of values, but each individual value may itself contain a semicolon-separated list of constants, the property interceptor is changed to first convert the comma-separated list to a semicolon-separated list, then parse it again and trim semicolons from each value
Microsoft Reviewers: Open in CodeFlow

…nvert DefineConstants input to semicolon-separated list before saving
@adamint
adamint requested a review from a team as a code owner December 5, 2024 08:59

@drewnoakes drewnoakes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC VB handles these properties differently to C#, so we should make sure to test both languages. @melytc do you recall the details? I think VB allows you to have values (i.e. A=1) for define constants, rather than just names (i.e. A).

@adamint

adamint commented Dec 7, 2024 •

Copy link
Copy Markdown
Member Author

@drewnoakes I've updated this now and paired with CPS changes to bring this control to a state I feel happy with.

Specifically, the additional change I made here, other than adding more tests, is to in OnGetUnevaluatedPropertyValueAsync also return values that have been removed (ie, in Constant1;Constant2, we will individually show the values Constant1 and Constant2 in the control, but not Constant1;Constant2, so we want to remove that value). I've made two gifs to show the before and after of the control. You can see how messed-up the state can get in the before gif.

before:
defineconstants-before

after:
defineconstants-after

@adamint
adamint requested a review from drewnoakes December 7, 2024 06:26
@melytc melytc added the Feature-Project-Properties-Designer The new project property pages which replace the legacy AppDesigner label Dec 11, 2024
@melytc

melytc commented Dec 11, 2024

Copy link
Copy Markdown
Contributor

IIRC VB handles these properties differently to C#, so we should make sure to test both languages. @melytc do you recall the details? I think VB allows you to have values (i.e. A=1) for define constants, rather than just names (i.e. A).

that's right! VB uses this syntax: symbol1 = value1, symbol2 = value2.

In the project properties UI, we have a different control for VB:
image

@adamint are these changes that you are proposing only for the C# control?

@adamint

adamint commented Dec 11, 2024

Copy link
Copy Markdown
Member Author

@adamint are these changes that you are proposing only for the C# control?

yes the vb property has a different control and property interceptor! this is only for c#

Adam Ratzman added 3 commits December 12, 2024 12:11
# Conflicts:
#	tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/ConfiguredProjectFactory.cs
@adamint
adamint requested a review from drewnoakes December 12, 2024 17:19
@haileymck

Copy link
Copy Markdown
Member

@adamint are these changes that you are proposing only for the C# control?

yes the vb property has a different control and property interceptor! this is only for c#

this is a blast from the past!

@adamint
adamint requested a review from drewnoakes December 27, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature-Project-Properties-Designer The new project property pages which replace the legacy AppDesigner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants