I have a specific pattern that I want to search for in Visual Studio.
Basically, I want to search for lines that contains await, but are missing ConfigureAwait at the end of the statement.
I have some patterns that works in regex-testers such as regex101.com, but I can't get these patterns to work in Visual Studio search. For example, the pattern (?s)^(.)*(await)((?!ConfigureAwait).)*(.)?(;).
What I am doing wrong?
Edit - I want to find lines in my project such as
await DoSomeCoolThings(x, y); (i.e. missing the ConfigureAwait(...).)
but I don't want to get a match for lines such as:
await DoSomeCoolThings(x, y).ConfigureAwait(false);
If the order of await and ConfigureAwait does not matter, then you can use
(?=.*\bawait\b)(?!.*\bConfigureAwait\b)
otherwise, if you consider that ConfigureAwait should come after await, you can use
(?=.*\bawait\b(?!.*\bConfigureAwait\b))
Efficient Solution
(?=\bawait\b(?!.*\bConfigureAwait\b))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With