Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[browser][wasm] Implement JavaScript managed object reference counting (
dotnet#37417) * Add Browser specific files to the project * Browser specific file modification to not include Quic support * Add Browser specific support files for Http Handler code * Add Interop code for JavaScript support * Remove unused reference * Add Http handler bindings implementation - This still needs to have the code implement nullable * Nullable support * Add browser files back after upstream merge conflict * Use attribute Link syntax for Common files to bring in sync with existing format * Address Missing license header * Code formatting and removal of comment code. * Address PR comments. * Address commit comments * Add blank line between License and first line of code. Address comments * Replace SocketsHttpHandler build for Browser. - Throws `PlatformNotSupportedException` for properties and methods of the HttpMessageHandler abstract implementation. * Cleanup SendAsync code when doing the call out to JavaScript Fetch. - Addresses commit comments. * Refactor BrowserHttpHandler code. * Cleanup * Remove null check as it should be checked in outer classes * Cleanup var usage to use explicit type. Address commit comments - For all of these vars, please replace them with the actual type, except when the type is obvious from a new or explicit cast on the right-hand side. * Move `.ConfigureAwait(true)` to `.ConfigureAwait(false)` - Address review comments * Change accessor of Runtime javascript interop methods. * Change accessor of Runtime javascript interop methods. * Address review comments for unused code * Cleanup leftover debug WriteLines * Remove the AllowNull attributes as per review comments. * Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs Co-Authored-By: Marek Safar <[email protected]> * throw different exception type as per review comment * use char[] array instead and return new string(array). - Address review comments * Initial addition of Browser Interop library * use char[] array instead and return new string(array). - Address review comments * Add project references so the Interop.JavaScript project builds * Coding Style update * Split the runtime methods into two modules. - .Api contains the methods that are only used internally from JavaScript bindings code. * Move System.Runtime.Interop.JavaScript to \src\libraries - Address review comments * Change preprocessor to upper case TARGETS_BROWSER - Address review comments * Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Api.cs Co-authored-by: Marek Safar <[email protected]> * Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Api.cs Co-authored-by: Marek Safar <[email protected]> * Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Api.cs Co-authored-by: Marek Safar <[email protected]> * Rename from .Api to .Bridge to address review comments * Modify .csproj files to reflect .Bridge.cs change. * Remove unnecessary constant * Add docs * Update Bridge link * Collapse code as per review comment. * Address review comments on `Task.ConfigureAwait(continueOnCapturedContext: true)`. - Added comment in source code. * Address review comment about using PropertyInfo reflection. - GetMethod("get_Result") is less expensive to use. * Coding Style - Address review comments * Part of code style and object documentation to partially address review comments. * Update src/libraries/Common/src/Interop/Browser/Interop.JavaScript.JSObject.cs Co-authored-by: Stephen Toub <[email protected]> * Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Bridge.cs Co-authored-by: Stephen Toub <[email protected]> * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Add class docs and code style updates - Address review comments * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Fix badly formed XML * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Remove unnecessary Property implementations. * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Update code style involving the use of `var` * Modify the underlying sockets field name. - address review comments. * Style and address review comments * Remove reliance on ConnectHelper.cs code as it is not supported on Browser - This removes the reliance on the QUIC support. * Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Bridge.cs Co-authored-by: Stephen Toub <[email protected]> * Remove null check for httpresponse.Content as it is always assigned to. - Address review comments * Address review comments * Remove methods that will not be implemented right now, * Add properties back to fix build error - error : MembersMustExist : Member 'public System.Boolean System.Net.Http.SocketsHttpHandler.XXXXXXXXXXXX.get()' does not exist in the implementation but it does exist in the contract. * Remove tcs TaskCompletionSource to address review comments * code style change * Remove disposing of _abortCts here as it causes runtime errors as being disposed of too early * Address review comment for GetType() * Rename library as per discussions * Add lock around the _boundObjects and _rawToJS access. - Address concurrency review comments * Address review comments for disposing of CancellationTokenSource * Address new HttpContent overloads in .NET 5 that take CancellationToken * Add project and test structure for JavaScript InteropServices * Remove previous modification as it is no longer needed. * Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs Co-authored-by: Stephen Toub <[email protected]> * Remove custom message passed to the PNSE .ctor * Update `mono` to dotnet or .NET * Address review comment for internal sealed class * Address extra message text * Move these source modules to System.Runtime.InteropServices.JavaScript * Add interop source modules to System.Runtime.InteropServices.JavaScript project * Remove placeholder source * Reference System.Runtime.InteropServices.JavaScript project * Address review comments Unsafe.SizeOf * Finish move of sources to InteropServices.JavaScript * Remove ActiveIssue to address review comments * Add core implementations * Add core object implementation for Map * Remove unused targetframework * Fix PNSE in HttpClientHandler .ctor - When creating an instance of the browser webassembly `System.Net.Http.BrowserHttpHandler` the following error is thrown. ``` System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Net.Http.BrowserHttpHandler.get_SslOptions() at System.Net.Http.HttpClientHandler.ThrowForModifiedManagedSslOptionsIfStarted() at System.Net.Http.HttpClientHandler.set_ClientCertificateOptions(ClientCertificateOption value) at System.Net.Http.HttpClientHandler..ctor() at System.Net.Http.HttpClient..ctor() ``` * Remove extra parameters to `PlatformNotSupportedException` * Fix tests due to underlying field name changing and reflection being used to obtain the socket field * Initial commit of reference counting code. * Update code formatting * Update solution formatting * [browser][wasm] Add support for marshaling the AnyRef SafeHandle - When calling into the bindings from managed code the` JSObject` reference handle is incremented. - After execution of the call the `JSObject` reference is decremented. - Special processing for the `GlobalObject` where the object is set with `ownsHandle` = false so that it is not released. - Release reference counts on javascript exceptions. * Code cleanup and formatting. * Clean up * Fix delegate code and address review comments * Code clean up and change accessor on AnyRefHandle * Move outside block * Remove unused method * Remove nullable type from dictionary * Remove comments * Marking methods with Linker-friendly reflection by using DynamicDependency attribute * address redundant using * Address lock review comment * Address review comments * remove nullable code * Address review comments * Add Debug.Assert to address review comment * Address assert comments and code formatting Co-authored-by: Marek Safar <[email protected]> Co-authored-by: Stephen Toub <[email protected]>
- Loading branch information