Add a message when MSBuild task or target skip due to condition evalu…#769
Conversation
|
I've been wanting to fix this in #389 |
|
looks very cool! |
|
Only had to wait four years.
…On Tue, Apr 2, 2024 at 2:21 PM Kirill Osenkov ***@***.***> wrote:
looks very cool!
—
Reply to this email directly, view it on GitHub
<#769 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEXI5GPDYXVS66LA2452JH3Y3MOPBAVCNFSM6AAAAABFUBWOG6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZTGEZDCMRRGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
| public static Regex CreateRegex(string text, int replacePlaceholders = 0, RegexOptions options = RegexOptions.Compiled | RegexOptions.Singleline, bool capture = false) | ||
| { | ||
| text = Regex.Escape(text); | ||
| text = "^" + Regex.Escape(text) + "$"; |
There was a problem hiding this comment.
I think we should check if these two symbols are already present. Also not sure if it's always safe to add these? I hope so?
There was a problem hiding this comment.
Added check. Though I think the Escape would invalidate it.
| return; | ||
| } | ||
|
|
||
| Match matches; |
There was a problem hiding this comment.
Should this logic perhaps go into BuildControl.xaml.cs -> DisplayText() on line 2371?
Also maybe extract method so that this logic is a separate method.
There was a problem hiding this comment.
On the other hand perhaps keep it here, maybe in the future we can do smart highlighting to highlight substrings using the textEditor
There was a problem hiding this comment.
still, I'd extract this logic to a separate method
There was a problem hiding this comment.
Moved to a separate function. I wanted to add Outlining to help visualize the position, but it might be too visually busy. Maybe in the future, it could have toggle button.
| public static Regex CreateRegex(string text, int replacePlaceholders = 0, RegexOptions options = RegexOptions.Compiled | RegexOptions.Singleline, bool capture = false) | ||
| { | ||
| text = Regex.Escape(text); | ||
| if (text.StartsWith("^") || !text.EndsWith("$")) |
There was a problem hiding this comment.
I don't quite understand this condition. Can you double-check?
I'd write this as:
text = Regex.Escape(text);
if (!text.StartsWith("^") && !text.EndsWith("$"))
{
text = $"^{text}$";
}There was a problem hiding this comment.
I haven't followed the conversation here, but I thought I'd point out that text.StartsWith("^") will always be false if text is an escaped regex.
There was a problem hiding this comment.
I am pretty sure that add ^$ is always safe, but I can't prove it, so I will just condition on the capture bool to limit the scope.
Add a message explaining why the Condition evaluated to false. This parses evaluate the condition from the build message and prints which statement in the condition is false.