I'm using MVC 5, and I have helper extension methods to generate links and other urls based on Expression<Action<TController>>
s that invoke controller actions. These expressions obviously aren't invoked in generating the view. They are only used for metadata.
Given this excerpt from my razor view,
@this.Form((AccountController c) => c.Register(null))
the compiler generates a warning:
Warning 1 Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
This warning doesn't seem appropriate because it could only apply if that lambda were invoked, which I know never happens.
Is there a way to suppress this? If not, I will probably make the action non-async.
await
in the body? – Kirk Wollawait
in the body, but I can just stop doing that. – recursive@this.Form(async (AccountController c) => await c.Register(null))
, or add an overload that takesExpression<Func<Task>>
? – Stephen ClearyExpression<Func<Task>>
would be tough, because I am ultimately usingMicrosoft.Web.Mvc.BuildUrlFromExpression
, which requiresExpression<Action<TController>>
. – recursive