Fody/NullGuard

Async method result rewriting doesn't work in VS 2015 (Roslyn 1.0) compiler

ulrichb opened this issue · 1 comments

At the moment NullGuard assumes that the compiler-generated async state machine types are structs. See MethodProcessor.InjectMethodReturnGuardAsync().

With Roslyn 1.0 this isn't valid anymore. Roslyn generates classes instead of structs if optimization is disabled (i.e. by default in Debug builds) to support "Edit and Continue". See AsyncRewriter and CompilationOptions.EnableEditAndContinue.

Note: I confirmed with a local NullGuard build that removing the VariableType.IsValueType check in InjectMethodReturnGuardAsync fixes this issue.

Want to submit your fix as a PR?