kevin-montrose/Cesil

Check conventions with Roslyn analyzers

kevin-montrose opened this issue · 1 comments

There are a couple conventions in Cesil that should be checked by analyzers, rather than either a) not being checked or b) checked in tests with janky reflection.

They are (at time of writing):

  • AsyncTestHelper.IsCompletedSuccessfully() is used instead of (Value)Task(<T>).IsCompletedSuccessfully
  • AwaitHelper.ConfigureCancellableAwait() is called for all awaitables prior to them being await'ed
  • BindingFlagsConstants is used instead of BindingFlags
  • Every use of the null forgiving operators (ie. suffix-!) is annotated with an explanation
  • Members on Throw are called instead of a throw statement or throw expression
  • Members on Types are used instead of a typeof() expression
  • Non-public types don't have public members

There may be others to add in the future, but this is a good start.

It's possible to provide an analyzer as a project, so the path forward here is creating a Cesil.Analyzers project and referencing it from the main Cesil project.

Addressed by #20.