Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Initial addition of Browser WebAssembly support #35573

Merged
merged 114 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
d17e863
Add Browser specific files to the project
kjpou1 Apr 28, 2020
aafa4b0
Browser specific file modification to not include Quic support
kjpou1 Apr 28, 2020
7d52436
Add Browser specific support files for Http Handler code
kjpou1 Apr 28, 2020
242ade6
Add Interop code for JavaScript support
kjpou1 Apr 28, 2020
2ca93d8
Remove unused reference
kjpou1 Apr 28, 2020
ab0e0de
Add Http handler bindings implementation
kjpou1 Apr 28, 2020
bc39563
Nullable support
kjpou1 Apr 28, 2020
b60ee5b
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 Apr 28, 2020
92f74c4
Add browser files back after upstream merge conflict
kjpou1 Apr 28, 2020
a9248de
Use attribute Link syntax for Common files to bring in sync with exis…
kjpou1 Apr 28, 2020
dc82e45
Address Missing license header
kjpou1 Apr 29, 2020
cc70c9f
Code formatting and removal of comment code.
kjpou1 Apr 29, 2020
c96a6f1
Address PR comments.
kjpou1 Apr 29, 2020
bb9ff24
Address commit comments
kjpou1 Apr 29, 2020
2f7ace0
Add blank line between License and first line of code. Address comments
kjpou1 Apr 29, 2020
ced6437
Replace SocketsHttpHandler build for Browser.
kjpou1 Apr 29, 2020
5c89333
Cleanup SendAsync code when doing the call out to JavaScript Fetch.
kjpou1 Apr 29, 2020
4eb5dd1
Refactor BrowserHttpHandler code.
kjpou1 Apr 29, 2020
d5360b6
Cleanup
kjpou1 Apr 29, 2020
d1b537d
Remove null check as it should be checked in outer classes
kjpou1 Apr 29, 2020
39947b1
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 Apr 29, 2020
2d8e124
Cleanup var usage to use explicit type. Address commit comments
kjpou1 Apr 30, 2020
d443cfd
Move `.ConfigureAwait(true)` to `.ConfigureAwait(false)`
kjpou1 Apr 30, 2020
0d63762
Change accessor of Runtime javascript interop methods.
kjpou1 Apr 30, 2020
a91637c
Change accessor of Runtime javascript interop methods.
kjpou1 Apr 30, 2020
cdbbf0f
Address review comments for unused code
kjpou1 Apr 30, 2020
5814d1d
Cleanup leftover debug WriteLines
kjpou1 Apr 30, 2020
146b6d7
Remove the AllowNull attributes as per review comments.
kjpou1 Apr 30, 2020
1f510f4
Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs
kjpou1 Apr 30, 2020
90b83f6
throw different exception type as per review comment
kjpou1 Apr 30, 2020
da394d6
use char[] array instead and return new string(array).
kjpou1 Apr 30, 2020
95af576
Initial addition of Browser Interop library
kjpou1 Apr 30, 2020
ada3198
use char[] array instead and return new string(array).
kjpou1 Apr 30, 2020
daa02cc
Add project references so the Interop.JavaScript project builds
kjpou1 May 4, 2020
8395f8f
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 4, 2020
d45f9a9
Coding Style update
kjpou1 May 4, 2020
c1190d2
Split the runtime methods into two modules.
kjpou1 May 4, 2020
93100b5
Move System.Runtime.Interop.JavaScript to \src\libraries
kjpou1 May 4, 2020
5845ee3
Change preprocessor to upper case TARGETS_BROWSER
kjpou1 May 4, 2020
3c75797
Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Api.cs
kjpou1 May 4, 2020
c7c80bc
Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Api.cs
kjpou1 May 4, 2020
568211e
Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Api.cs
kjpou1 May 4, 2020
282efa0
Rename from .Api to .Bridge to address review comments
kjpou1 May 5, 2020
b09e224
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 5, 2020
fa165aa
Modify .csproj files to reflect .Bridge.cs change.
kjpou1 May 5, 2020
b57fef9
Remove unnecessary constant
kjpou1 May 5, 2020
a4753c0
Add docs
kjpou1 May 6, 2020
ee9c8d9
Update Bridge link
kjpou1 May 6, 2020
1eb5d23
Collapse code as per review comment.
kjpou1 May 6, 2020
49193b8
Address review comments on `Task.ConfigureAwait(continueOnCapturedCon…
kjpou1 May 6, 2020
6ce0e8d
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 6, 2020
1a655e5
Address review comment about using PropertyInfo reflection.
kjpou1 May 6, 2020
4636867
Coding Style - Address review comments
kjpou1 May 7, 2020
35380b5
Part of code style and object documentation to partially address revi…
kjpou1 May 7, 2020
233c3b3
Update src/libraries/Common/src/Interop/Browser/Interop.JavaScript.JS…
kjpou1 May 8, 2020
5e0ebf2
Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Bridg…
kjpou1 May 8, 2020
117c9ef
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 8, 2020
8604280
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 8, 2020
65c1f22
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 8, 2020
3d6ce31
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 8, 2020
de114a5
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 8, 2020
9244cb4
Add class docs and code style updates
kjpou1 May 8, 2020
fb95c39
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 8, 2020
22f5ea2
Fix badly formed XML
kjpou1 May 8, 2020
37a2b42
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 8, 2020
b20d6b5
Remove unnecessary Property implementations.
kjpou1 May 8, 2020
fc302f3
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 8, 2020
3a93043
Update code style involving the use of `var`
kjpou1 May 8, 2020
4818f60
Modify the underlying sockets field name.
kjpou1 May 8, 2020
521e772
Style and address review comments
kjpou1 May 8, 2020
688f5a7
Remove reliance on ConnectHelper.cs code as it is not supported on Br…
kjpou1 May 8, 2020
ea27792
Update src/libraries/Common/src/Interop/Browser/Interop.Runtime.Bridg…
kjpou1 May 8, 2020
04c53ae
Remove null check for httpresponse.Content as it is always assigned to.
kjpou1 May 8, 2020
ca9e2db
Address review comments
kjpou1 May 8, 2020
6e1542f
Remove methods that will not be implemented right now,
kjpou1 May 8, 2020
ea7f1c3
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 11, 2020
7e39ffb
Add properties back to fix build error
kjpou1 May 11, 2020
703e504
Remove tcs TaskCompletionSource to address review comments
kjpou1 May 11, 2020
6414529
code style change
kjpou1 May 11, 2020
a74d985
Remove disposing of _abortCts here as it causes runtime errors as bei…
kjpou1 May 11, 2020
4baf426
Address review comment for GetType()
kjpou1 May 11, 2020
ea61992
Rename library as per discussions
kjpou1 May 12, 2020
004ab2d
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 12, 2020
0ae1bf7
Add lock around the _boundObjects and _rawToJS access.
kjpou1 May 12, 2020
63b4e1e
Address review comments for disposing of CancellationTokenSource
kjpou1 May 15, 2020
e8ea3a9
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 18, 2020
648e61c
Address new HttpContent overloads in .NET 5 that take CancellationToken
kjpou1 May 18, 2020
dd05832
Add project and test structure for JavaScript InteropServices
kjpou1 May 19, 2020
796692b
Remove previous modification as it is no longer needed.
kjpou1 May 20, 2020
626d6c9
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 20, 2020
df1be16
Update src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpH…
kjpou1 May 20, 2020
e206e4b
Remove custom message passed to the PNSE .ctor
kjpou1 May 20, 2020
704bf8a
Update `mono` to dotnet or .NET
kjpou1 May 20, 2020
33222ea
Address review comment for internal sealed class
kjpou1 May 20, 2020
79e3287
Address extra message text
kjpou1 May 20, 2020
fbb6e6f
Move these source modules to System.Runtime.InteropServices.JavaScript
kjpou1 May 20, 2020
6614009
Add interop source modules to System.Runtime.InteropServices.JavaScri…
kjpou1 May 20, 2020
bdc38c4
Remove placeholder source
kjpou1 May 20, 2020
fcb9802
Reference System.Runtime.InteropServices.JavaScript project
kjpou1 May 20, 2020
b8abce1
Address review comments Unsafe.SizeOf
kjpou1 May 20, 2020
a712114
Finish move of sources to InteropServices.JavaScript
kjpou1 May 25, 2020
0185c17
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 25, 2020
e46ab9f
Remove ActiveIssue to address review comments
kjpou1 May 25, 2020
80b2132
Add core implementations
kjpou1 May 25, 2020
af5d902
Add core object implementation for Map
kjpou1 May 25, 2020
f2fb363
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 25, 2020
e5de014
Remove unused targetframework
kjpou1 May 26, 2020
530afe4
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 26, 2020
c72e64c
Fix PNSE in HttpClientHandler .ctor
kjpou1 May 26, 2020
5f17ee1
Remove extra parameters to `PlatformNotSupportedException`
kjpou1 May 26, 2020
d9c6dc4
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 27, 2020
0bd5966
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 27, 2020
25db30b
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 May 28, 2020
1468104
Fix tests due to underlying field name changing and reflection being …
kjpou1 May 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;

using JSObject = System.Runtime.InteropServices.JavaScript.JSObject;
using JSException = System.Runtime.InteropServices.JavaScript.JSException;

internal static partial class Interop
{
internal static partial class Runtime
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern string InvokeJS(string str, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object CompileFunction(string str, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object InvokeJSWithArgs(int jsObjHandle, string method, object?[] parms, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object GetObjectProperty(int jsObjHandle, string propertyName, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object SetObjectProperty(int jsObjHandle, string propertyName, object value, bool createIfNotExists, bool hasOwnProperty, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object GetByIndex(int jsObjHandle, int index, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object SetByIndex(int jsObjHandle, int index, object? value, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object GetGlobalObject(string? globalName, out int exceptionalResult);

[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object ReleaseHandle(int jsObjHandle, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object ReleaseObject(int jsObjHandle, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object NewObjectJS(int jsObjHandle, object[] parms, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object BindCoreObject(int jsObjHandle, int gcHandle, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object BindHostObject(int jsObjHandle, int gcHandle, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object New(string className, object[] parms, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object TypedArrayToArray(int jsObjHandle, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object TypedArrayCopyTo(int jsObjHandle, int arrayPtr, int begin, int end, int bytesPerElement, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object TypedArrayFrom(int arrayPtr, int begin, int end, int bytesPerElement, int type, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object TypedArrayCopyFrom(int jsObjHandle, int arrayPtr, int begin, int end, int bytesPerElement, out int exceptionalResult);

// / <summary>
// / Execute the provided string in the JavaScript context
// / </summary>
// / <returns>The js.</returns>
// / <param name="str">String.</param>
public static string InvokeJS(string str)
{
string res = InvokeJS(str, out int exception);
if (exception != 0)
throw new JSException(res);
return res;
}

public static System.Runtime.InteropServices.JavaScript.Function? CompileFunction(string snippet)
{
object res = CompileFunction(snippet, out int exception);
if (exception != 0)
throw new JSException((string)res);
return res as System.Runtime.InteropServices.JavaScript.Function;
}

public static int New<T>(params object[] parms)
{
object res = New(typeof(T).Name, parms, out int exception);
if (exception != 0)
throw new JSException((string)res);
return (int)res;
}

public static int New(string hostClassName, params object[] parms)
{
object res = New(hostClassName, parms, out int exception);
if (exception != 0)
throw new JSException((string)res);
return (int)res;
}

public static JSObject? NewJSObject(JSObject? jsFuncPtr = null, params object[] parms)
{
object res = NewObjectJS(jsFuncPtr?.JSHandle ?? 0, parms, out int exception);
if (exception != 0)
throw new JSException((string)res);
return res as JSObject;
}
public static object GetGlobalObject(string? str = null)
{
int exception;
object globalHandle = Runtime.GetGlobalObject(str, out exception);

if (exception != 0)
throw new JSException($"Error obtaining a handle to global {str}");

return globalHandle;
}

}
}
2 changes: 1 addition & 1 deletion src/libraries/Common/tests/System/Net/Http/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static void EnableUnencryptedHttp2IfNecessary(HttpClientHandler handler)
return;
}

FieldInfo socketsHttpHandlerField = typeof(HttpClientHandler).GetField("_socketsHttpHandler", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo socketsHttpHandlerField = typeof(HttpClientHandler).GetField("_underlyingHandler", BindingFlags.NonPublic | BindingFlags.Instance);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that _underlyingHandler could be something other than a SocketsHttpHandler, this set of checks will probably need to be updated to validate that the instance retrieved from the field actually is a SocketsHttpHandler and bailing if it's not. That could be left for later, but if we start running the System.Net.Http tests against the webassembly implementation, this will likely cause problems (then again, I expect a ton of tests wouldn't pass, anyway).

if (socketsHttpHandlerField == null)
{
// Not using .NET Core implementation, i.e. could be .NET Framework.
Expand Down
Loading