public bool TryFindContent(IPublishedRequestBuilder contentRequest)
which was fine in Umbraco 9, to:
public Task<bool> TryFindContent(IPublishedRequestBuilder contentRequest)
as per the example. Now I am getting the error in Visual studio which is preventing compiling the website build:
with return false, Visual Studio says:
Cannot implicitly convert type 'bool' to 'system.threading.tasks.task bool'
I tried adding async:
public async Task<bool> TryFindContent(IPublishedRequestBuilder contentRequest)
Then I have the message:
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(...) to do CPU-bound work on a background thread
Then it gives options to remove async (so were back to square one)
Does anyone have ideas of the solution to this please. Do the documentation team need to be informed?
IContentFinder error - Cannot implicitly convert type 'bool' to 'system.threading.tasks.task bool'
Hi, I have upgraded to Umbraco 10, and it seems the only issue I have encountered so far is down to the IContentFinder. I followed the example here, for our Umbraco 9 build: https://our.umbraco.com/documentation/reference/routing/request-pipeline/icontentfinder Now that we have upgraded to Umbraco 10, I have changed:
which was fine in Umbraco 9, to:
as per the example. Now I am getting the error in Visual studio which is preventing compiling the website build:
with return false, Visual Studio says:
Cannot implicitly convert type 'bool' to 'system.threading.tasks.task bool'
I tried adding async:
Then I have the message:
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(...) to do CPU-bound work on a background thread
Then it gives options to remove async (so were back to square one)
Does anyone have ideas of the solution to this please. Do the documentation team need to be informed?
Kind regards,
Pete
Yeah, I think the documentation is wrong. I haven't tried this, but I think the issue is:
Without the "async", the return type of "TryFindContent" is
Task<bool>
, not bool.So when returning values, the example in the documentation should change things like this:
to things like this:
is working on a reply...