This PR makes the call from JS into .NET be able to support async methods (return Task or Task<T>)
This PR has a fair bit of things moving around because of the async and the fact that I wanted to make the code flow the same on all the platforms. The code was getting a bit nested, so I broke things out into methods.
This pull request includes several changes to improve the handling of asynchronous operations and simplify the codebase for HybridWebView. The most important changes include the addition of new methods for handling asynchronous tasks, refactoring existing methods to use these new async methods, and updating the test cases accordingly.
Description of Change
This PR makes the call from JS into .NET be able to support async methods (return
Task
orTask<T>
)This PR has a fair bit of things moving around because of the async and the fact that I wanted to make the code flow the same on all the platforms. The code was getting a bit nested, so I broke things out into methods.
Issues Fixed
Fixes https://github.com/dotnet/maui/issues/25968
This pull request includes several changes to improve the handling of asynchronous operations and simplify the codebase for
HybridWebView
. The most important changes include the addition of new methods for handling asynchronous tasks, refactoring existing methods to use these new async methods, and updating the test cases accordingly.Asynchronous Handling Improvements:
src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.cs
: RefactoredInvokeDotNet
method toInvokeDotNetAsync
and added support for async invocation of .NET methods from JavaScript.src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.Windows.cs
: AddedGetResponseStreamAsync
method to handle async web resource requests and updatedOnWebResourceRequested
method to use this new async method. [1] [2]src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.iOS.cs
: UpdatedStartUrlSchemeTask
method to handle async responses and addedGetResponseBytesAsync
method for asynchronous byte retrieval. [1] [2]Test Case Updates:
src/Controls/tests/DeviceTests/Elements/HybridWebView/HybridWebViewTests.cs
: Added new test methods to handle async invocations and updated existing test methods to use the newNewComplexResult
property. [1] [2]src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/invokedotnettests.html
: Simplified the test HTML file by removing specific cases and using a default case for invoking .NET methods. [1] [2]Codebase Simplification:
src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.Windows.cs
: Removed unnecessaryGetHeaderString
method and cleaned up theOnWebResourceRequested
method.src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.iOS.cs
: Simplified the response handling in theStartUrlSchemeTask
method.