Skip to content

Added ConfigureAwait statements where needed

Created by: Soyvolon

Summary

Appends .ConfigureAwait(false) when needed

Changes

  • Updates any awaited call with a .ConfigureAwait(false) statement if it was previously missing it.

Notes

I used this regex expression to sweep the document for any line that has await first and does not include .ConfigureAwait(false): ^.*?await((?!ConfigureAwait\(false\)|Task.Yield\(\);).)*$ (case sensitive, or you will pick up false positives).

Then, for a final look I use this python script:

split = test_data.splitlines()

for line in split:
  if "Task.Yield" in line or "CONTRIBUTING" in line or not line.endswith(';'):
    continue
  words = line.split(" ")
  awaitCounter = 0
  configCounter = 0
  for word in words:
    if word.endswith("await"):
      awaitCounter += 1
    if "ConfigureAwait(false)" in word:
      configCounter += 1
  if awaitCounter > configCounter:
    print(line)

Where test data is the result of searching await in the entire solution (see this pastebin) to get any miss matches for the amount of await and ConfigureAwait statements and doubled checked those lines.

Merge request reports

Loading