Skip to content
This repository was archived by the owner on Feb 25, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions Blazor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Analyzers.Test", "test\Microsoft.AspNetCore.Blazor.Analyzers.Test\Microsoft.AspNetCore.Blazor.Analyzers.Test.csproj", "{CF3B5990-7A05-4993-AACA-D2C8D7AFF6E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.JSInterop", "src\Microsoft.JSInterop\Microsoft.JSInterop.csproj", "{C866B19D-AFFF-45B7-8DAB-71805F39D516}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.JSInterop.Test", "test\Microsoft.JSInterop.Test\Microsoft.JSInterop.Test.csproj", "{BA1CE1FD-89D8-423F-A21B-6B212674EB39}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.WebAssembly.Interop", "src\mono\Mono.WebAssembly.Interop\Mono.WebAssembly.Interop.csproj", "{C56873E6-8F49-476E-AF51-B5D187832CF5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -338,6 +344,30 @@ Global
{CF3B5990-7A05-4993-AACA-D2C8D7AFF6E6}.Release|Any CPU.Build.0 = Release|Any CPU
{CF3B5990-7A05-4993-AACA-D2C8D7AFF6E6}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{CF3B5990-7A05-4993-AACA-D2C8D7AFF6E6}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{C866B19D-AFFF-45B7-8DAB-71805F39D516}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C866B19D-AFFF-45B7-8DAB-71805F39D516}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C866B19D-AFFF-45B7-8DAB-71805F39D516}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{C866B19D-AFFF-45B7-8DAB-71805F39D516}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{C866B19D-AFFF-45B7-8DAB-71805F39D516}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C866B19D-AFFF-45B7-8DAB-71805F39D516}.Release|Any CPU.Build.0 = Release|Any CPU
{C866B19D-AFFF-45B7-8DAB-71805F39D516}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{C866B19D-AFFF-45B7-8DAB-71805F39D516}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{BA1CE1FD-89D8-423F-A21B-6B212674EB39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA1CE1FD-89D8-423F-A21B-6B212674EB39}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA1CE1FD-89D8-423F-A21B-6B212674EB39}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{BA1CE1FD-89D8-423F-A21B-6B212674EB39}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{BA1CE1FD-89D8-423F-A21B-6B212674EB39}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA1CE1FD-89D8-423F-A21B-6B212674EB39}.Release|Any CPU.Build.0 = Release|Any CPU
{BA1CE1FD-89D8-423F-A21B-6B212674EB39}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{BA1CE1FD-89D8-423F-A21B-6B212674EB39}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{C56873E6-8F49-476E-AF51-B5D187832CF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C56873E6-8F49-476E-AF51-B5D187832CF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C56873E6-8F49-476E-AF51-B5D187832CF5}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{C56873E6-8F49-476E-AF51-B5D187832CF5}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{C56873E6-8F49-476E-AF51-B5D187832CF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C56873E6-8F49-476E-AF51-B5D187832CF5}.Release|Any CPU.Build.0 = Release|Any CPU
{C56873E6-8F49-476E-AF51-B5D187832CF5}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{C56873E6-8F49-476E-AF51-B5D187832CF5}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -380,6 +410,9 @@ Global
{3A457B14-D91B-4FFF-A81A-8F350BDB911F} = {E8EBA72C-D555-43AE-BC98-F0B2D05F6A07}
{6DDD6A29-0A3E-417F-976C-5FE3FDA74055} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
{CF3B5990-7A05-4993-AACA-D2C8D7AFF6E6} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
{C866B19D-AFFF-45B7-8DAB-71805F39D516} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
{BA1CE1FD-89D8-423F-A21B-6B212674EB39} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
{C56873E6-8F49-476E-AF51-B5D187832CF5} = {7B5CAAB1-A3EB-44F7-87E3-A13ED89FC17D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}
Expand Down
41 changes: 15 additions & 26 deletions samples/MonoSanity/wwwroot/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title>Mono sanity check</title>
Expand Down Expand Up @@ -139,32 +139,21 @@
throw new Error('This is a JavaScript exception.');
}

// Normally, applications would use the higher-level APIs for registering invocable
// functions, and for invoking them with automatic argument/result marshalling.
// But since this project is trying to test low-level Mono runtime capabilities,
// we implement our own marshalling here.
window.Blazor = {
platform: {
monoGetRegisteredFunction: function (name) { return blazorRegisteredFunctions[name]; }
}
};
var blazorRegisteredFunctions = {
evaluateJsExpression: function (dotNetStringExpression) {
var result = eval(dotnetStringToJavaScriptString(dotNetStringExpression));
return result === null || result === undefined
? result // Pass through null/undefined so we can verify this is handled upstream
: javaScriptStringToDotNetString(result.toString());
},

divideNumbersUnmarshalled: function (a, b) {
// In this example, neither the arguments nor return value are boxed
// -- we expect to receive and return numbers directly
if (b === 0) {
throw new Error('Division by zero');
}
return a / b;
function evaluateJsExpression(dotNetStringExpression) {
var result = eval(dotnetStringToJavaScriptString(dotNetStringExpression));
return result === null || result === undefined
? result // Pass through null/undefined so we can verify this is handled upstream
: javaScriptStringToDotNetString(result.toString());
}

function divideNumbersUnmarshalled(a, b) {
// In this example, neither the arguments nor return value are boxed
// -- we expect to receive and return numbers directly
if (b === 0) {
throw new Error('Division by zero');
}
};
return a / b;
}
</script>
</body>
</html>
14 changes: 12 additions & 2 deletions samples/MonoSanity/wwwroot/loader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
(function () {
(function () {
// Implement just enough of the DotNet.* API surface for unmarshalled interop calls to work
// in the cases used in this project
window.DotNet = {
jsCallDispatcher: {
findJSFunction: function (identifier) {
return window[identifier];
}
}
};

window.initMono = function initMono(loadAssemblyUrls, onReadyCallback) {
window.Browser = {
init: function () { },
Expand Down Expand Up @@ -158,4 +168,4 @@
return filename.replace(/\.dll$/, '');
}

})();
})();
9 changes: 4 additions & 5 deletions samples/MonoSanityClient/Examples.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Mono.WebAssembly.Interop;
using System;
using System.Runtime.InteropServices;
using System.Text;
using WebAssembly;

namespace MonoSanityClient
{
Expand Down Expand Up @@ -32,8 +32,7 @@ public static void TriggerException(string message)

public static string EvaluateJavaScript(string expression)
{
// For tests that call this method, we'll exercise the 'BlazorInvokeJSArray' code path
var result = Runtime.BlazorInvokeJSArray<string>(out var exceptionMessage, "evaluateJsExpression", expression, null, null);
var result = InternalCalls.InvokeJSUnmarshalled<string, string, object, object>(out var exceptionMessage, "evaluateJsExpression", expression, null, null);
if (exceptionMessage != null)
{
return $".NET got exception: {exceptionMessage}";
Expand All @@ -46,7 +45,7 @@ public static string CallJsNoBoxing(int numberA, int numberB)
{
// For tests that call this method, we'll exercise the 'BlazorInvokeJS' code path
// since that doesn't box the params
var result = Runtime.BlazorInvokeJS<int, int, object, int>(out var exceptionMessage, "divideNumbersUnmarshalled", numberA, numberB, null);
var result = InternalCalls.InvokeJSUnmarshalled<int, int, object, int>(out var exceptionMessage, "divideNumbersUnmarshalled", numberA, numberB, null);
if (exceptionMessage != null)
{
return $".NET got exception: {exceptionMessage}";
Expand Down
4 changes: 2 additions & 2 deletions samples/MonoSanityClient/MonoSanityClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<Import Project="..\..\src\Microsoft.AspNetCore.Blazor.Build\ReferenceFromSource.props" />

<ItemGroup>
<!-- Share the WebAssembly.Runtime.cs source here so we get access to the same interop externs -->
<Compile Include="..\..\src\Microsoft.AspNetCore.Blazor.Browser\Interop\WebAssembly.Runtime.cs" />
<!-- Share the InternalCalls.cs source here so we get access to the same interop externs -->
<Compile Include="..\..\src\mono\Mono.WebAssembly.Interop\InternalCalls.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.0" />
<WebpackInputs Include="**\*.ts" Exclude="node_modules\**" />
<WebpackInputs Include="..\Microsoft.JSInterop\TypeScript\src\**" />
</ItemGroup>

<Import Project="..\Microsoft.AspNetCore.Blazor.BuildTools\ReferenceFromSource.props" />
Expand Down
Loading