Conversation
…nvert DefineConstants input to semicolon-separated list before saving
drewnoakes
left a comment
There was a problem hiding this comment.
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).
...Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Debug/KeyValuePairListEncoding.cs
Outdated
Show resolved
Hide resolved
...Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Debug/KeyValuePairListEncoding.cs
Outdated
Show resolved
Hide resolved
...perties/InterceptedProjectProperties/BuildPropertyPage/DefineConstantsCSharpValueProvider.cs
Outdated
Show resolved
Hide resolved
| [InlineData("key1=value1;key2=value2;key3=value3", new[] { "key1", "value1", "key2", "value2", "key3", "value3" })] | ||
| [InlineData("key1;key2=value2", new[] { "key1", "", "key2", "value2" })] | ||
| [InlineData("key1;key2;key3=value3", new[] { "key1", "", "key2", "", "key3", "value3" })] | ||
| [InlineData("key1;;;key3;;", new[] { "key1", "", "key3", "" })] |
There was a problem hiding this comment.
Would be good to cover some more inputs:
""" ""="";"
If there are invalid inputs, a test that ensures that Parse throws would be good. For example, "==", or null.
There was a problem hiding this comment.
I added test cases on those inputs except null, as the method accepts a non-nullable input string. But I wouldn't necessarily agree that there are invalid inputs possible here, since == should parse to an empty key, value =.
There was a problem hiding this comment.
Thanks for adding more tests.
since == should parse to an empty key, value =
I'm less confident about that than you. I feel like == should be an invalid and ambiguous input that throws. If values are expected to contain delimiters, then they should be escaped.
There was a problem hiding this comment.
I feel like == should be an invalid and ambiguous input that throws.
I'm not entirely in agreement; the difference between = and the other delimiters is that = has no meaning other than as part of a value after already encountering an =
There was a problem hiding this comment.
I mean that it's ambiguous whether the name or value is =. Values also cannot contain commas without escaping.
What happens if the Format method is given names/values that contain = or ,? My guess is that these values would not round-trip correctly.
For robustness, we should either throw on invalid inputs, or implement escaping so that these values are handled correctly.
There was a problem hiding this comment.
What happens if you enter strings in the UI containing = and ,?
There was a problem hiding this comment.
Good points. I switched back to escaping the =
...jectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Properties/KeyValuePairListEncodingTests.cs
Show resolved
Hide resolved
… in the property value directly
|
@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 |
that's right! VB uses this syntax: In the project properties UI, we have a different control for VB: @adamint are these changes that you are proposing only for the C# control? |
...Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Debug/KeyValuePairListEncoding.cs
Show resolved
Hide resolved
yes the vb property has a different control and property interceptor! this is only for c# |
...perties/InterceptedProjectProperties/BuildPropertyPage/DefineConstantsCSharpValueProvider.cs
Outdated
Show resolved
Hide resolved
...perties/InterceptedProjectProperties/BuildPropertyPage/DefineConstantsCSharpValueProvider.cs
Outdated
Show resolved
Hide resolved
...perties/InterceptedProjectProperties/BuildPropertyPage/DefineConstantsCSharpValueProvider.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/ConfiguredProjectFactory.cs
this is a blast from the past! |



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