Suppose I implement an interface where there are two methods: Create
and CreateAsync
. The Async method in my case is not really async, and it uses the syncronous Create
method to return the created object:
public Task<GrandeurDTO> CreateAsync()
{
var dto = Create();
return Task.FromResult(dto);
}
public GrandeurDTO Create()
{
var bo = new Grandeur();
var dto = _mapper.Map<GrandeurDTO>(bo);
return dto;
}
How should I remove the warning
This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(CS1998)
knowing I can't rename the method in Create
(I already have one; cause if not the question is similar to
CodePudding user response:
I believe this is just a case of a tired Visual Studio and 1) a recompile or 2) VS restart will fix the issue.