mhutch / MonoDevelop.MSBuildEditor

Improved MSBuild editing support
Other
211 stars 24 forks source link

Allow negative literals in conditions #223

Closed ItEndsWithTens closed 2 months ago

ItEndsWithTens commented 2 months ago

Hi, excellent project you've got here! I can't thank you enough, it's proving exceptionally useful, but I've run into a small bug I thought I should try to fix: conditions with negative numeric literals show an error despite working in MSBuild.

I'm using the IndexOf property function to find a character in a string, and then store its index in a property. When the character in question can't be found said function returns -1, and I check for that in a PropertyGroup condition later on:

<PropertyGroup Condition="$(MyPotentiallyNegativeProperty) > -1">
    <Foo>bar</Foo>
</PropertyGroup>

As of commit 8abab26ab34aa87b996164c07b7a223d7e4500bf this extension puts an error squiggle under the hyphen, reporting that it expects a right parenthesis, but the comparison works as expected in MSBuild.

Please excuse me if I've overstepped my bounds, but the changes required turned out to be rather simple, as far as I can tell, so I felt a pull request was justified. I'm not hugely confident that my addition of test cases to TestParseNoError is the best way to test for this, but after all the goal is ultimately to get those examples to parse without error. The new test cases fail before my changes but succeed afterwards, and all other tests continue to pass as well.

By all means let me know if I need to change anything, and thank you again for all your hard work!

mhutch commented 2 months ago

This pull request is great, thank you for the contribution and the kind comments 😄