I'm using a C# to VB.NET converter to attempt and convert this code, however there are several errors.
private async Task OnRequestBlockResourceEventHandler(object sender, SessionEventArgs e)
=> await Task.Run(
() =>
{
if (e.HttpClient.Request.RequestUri.ToString().Contains("analytics"))
{
string customBody = string.Empty;
e.Ok(Encoding.UTF8.GetBytes(customBody));
}
});
and the VB.NET code conversion is here:
Private Async Function OnRequestBlockResourceEventHandler(ByVal sender As Object, ByVal e As SessionEventArgs) As Task
Return Await Task.Run(Function()
If e.HttpClient.Request.RequestUri.ToString().Contains("analytics") Then
Dim customBody As String = String.Empty
e.Ok(Encoding.UTF8.GetBytes(customBody))
End If
End Function)
End Function
The error shows this
Comma, ')', or a valid expression continuation expected.
'Return' statements in this Async method cannot return a value since
the return type of the function is 'Task'. Consider changing the
function's return type to 'Task(Of T)'