Regex to find C# async methods with missing "Async" suffix? -


in c#, 1 of conventions asynchronous methods (those marked async keyword) names should end "async" suffix:

public async task mymethod(/* params */) ...         <-- bad, missing "async" suffix public async task mymethodasync(/* params */) ...    <-- good, per convention 

i've been writing lot of async code lately, , i'm concerned may have forgotten put "async" suffix on methods.

is there regex can use find methods marked async not have "async" suffix? if that's possible, can reverse done (ie. find methods do have "async" suffix not marked async keyword)?

i looking paste regex "find in files" dialog in visual studio, if makes difference answer.

i'm guessing tools fxcop, coderush or resharper may warn things this, latter 2 not option given workplace, , i'd rather not have install & configure former if can accomplish using simple regex.

here regex:

(?i)async.*(?<!async)\( 

it looks keyword async , @ "(" without ("?<!") async before it.

edit: better version. thx @andrew

task\s+(\w+(?<!async))\( 

this give methods small written asyncs @ , well. furthermore allows use find , replace.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -