-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[wasm] updated samples for ES6 and CJS #62292
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
33e71a9
* samples for ES6 and CJS
pavelsavara 3f71bce
feedback
pavelsavara a5fafb3
fix+more node tests
pavelsavara eb8b1e0
feedback
pavelsavara fe8f415
feedback
pavelsavara 566a214
Merge branch 'main' into wasm_samples
pavelsavara b810641
later
pavelsavara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
TOP=../../../../.. | ||
|
||
include ../wasm.mk | ||
|
||
ifneq ($(AOT),) | ||
override MSBUILD_ARGS+=/p:RunAOTCompilation=true | ||
endif | ||
|
||
PROJECT_NAME=Wasm.Browser.ES6.Sample.csproj | ||
|
||
run: run-browser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import createDotnetRuntime from './dotnet.js' | ||
|
||
const { MONO, BINDING, Module, RuntimeBuildInfo } = await createDotnetRuntime((api) => ({ | ||
disableDotnet6Compatibility: true, | ||
configSrc: "./mono-config.json", | ||
onAbort: () => { | ||
wasm_exit(1); | ||
}, | ||
})); | ||
|
||
function wasm_exit(exit_code) { | ||
/* Set result in a tests_done element, to be read by xharness in runonly CI test */ | ||
const tests_done_elem = document.createElement("label"); | ||
tests_done_elem.id = "tests_done"; | ||
tests_done_elem.innerHTML = exit_code.toString(); | ||
document.body.appendChild(tests_done_elem); | ||
|
||
console.log(`WASM EXIT ${exit_code}`); | ||
} | ||
|
||
const testMeaning = BINDING.bind_static_method("[Wasm.Browser.ES6.Sample] Sample.Test:TestMeaning"); | ||
const ret = testMeaning(); | ||
document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`; | ||
try { | ||
const { MONO, BINDING, Module, RuntimeBuildInfo } = await createDotnetRuntime(); | ||
const testMeaning = BINDING.bind_static_method("[Wasm.Browser.ES6.Sample] Sample.Test:TestMeaning"); | ||
const ret = testMeaning(); | ||
document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`; | ||
console.debug(`ret: ${ret}`); | ||
|
||
console.debug(`ret: ${ret}`); | ||
let exit_code = ret == 42 ? 0 : 1; | ||
wasm_exit(exit_code); | ||
let exit_code = await MONO.mono_run_main("Wasm.Browser.ES6.Sample.dll", []); | ||
wasm_exit(exit_code); | ||
} catch (err) { | ||
console.log(`WASM ERROR ${err}`); | ||
wasm_exit(2); | ||
} |
4 changes: 2 additions & 2 deletions
4
src/mono/sample/wasm/browser-legacy/Wasm.Browser.LegacySample.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...e/wasm/browser/Wasm.Browser.Sample.csproj → ...sm/browser/Wasm.Browser.CJS.Sample.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
function wasm_exit(exit_code) { | ||
/* Set result in a tests_done element, to be read by xharness in runonly CI test */ | ||
const tests_done_elem = document.createElement("label"); | ||
tests_done_elem.id = "tests_done"; | ||
tests_done_elem.innerHTML = exit_code.toString(); | ||
document.body.appendChild(tests_done_elem); | ||
|
||
"use strict"; | ||
console.log(`WASM EXIT ${exit_code}`); | ||
} | ||
|
||
createDotnetRuntime(({ MONO, BINDING, Module }) => ({ | ||
disableDotnet6Compatibility: true, | ||
configSrc: "./mono-config.json", | ||
onDotnetReady: () => { | ||
try { | ||
App.init({ MONO, BINDING, Module }); | ||
} catch (error) { | ||
set_exit_code(1, error); | ||
throw (error); | ||
} | ||
}, | ||
onAbort: (error) => { | ||
set_exit_code(1, error); | ||
}, | ||
})); | ||
async function loadRuntime() { | ||
globalThis.exports = {}; | ||
await import("./dotnet.js"); | ||
return globalThis.exports.createDotnetRuntime; | ||
} | ||
|
||
async function main() { | ||
try { | ||
const createDotnetRuntime = await loadRuntime(); | ||
const { MONO, BINDING, Module, RuntimeBuildInfo } = await createDotnetRuntime(() => ({ | ||
disableDotnet6Compatibility: true, | ||
configSrc: "./mono-config.json", | ||
})); | ||
|
||
const testMeaning = BINDING.bind_static_method("[Wasm.Browser.CJS.Sample] Sample.Test:TestMeaning"); | ||
const ret = testMeaning(); | ||
document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`; | ||
|
||
console.debug(`ret: ${ret}`); | ||
let exit_code = ret == 42 ? 0 : 1; | ||
wasm_exit(exit_code); | ||
} catch (err) { | ||
console.log(`WASM ERROR ${err}`); | ||
wasm_exit(2) | ||
} | ||
} | ||
|
||
main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
TOP=../../../../.. | ||
|
||
include ../wasm.mk | ||
|
||
ifneq ($(AOT),) | ||
override MSBUILD_ARGS+=/p:RunAOTCompilation=true | ||
endif | ||
|
||
ifneq ($(V),) | ||
DOTNET_MONO_LOG_LEVEL=--setenv=MONO_LOG_LEVEL=debug | ||
endif | ||
|
||
PROJECT_NAME=Wasm.Console.CJS.Sample.csproj | ||
CONSOLE_DLL=Wasm.Console.CJS.Sample.dll | ||
|
||
run: run-console |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we want these conditions anymore?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, there is no other place which would run on NodeJS platform every time. Also this is
runtime-manual
pipeline. So it's already run with intention of getting more. I'm prepared to change it if it doesn't make sense.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed with Radek to put it back and make it consistent with other ones in the same file.
@steveisok
eq(variables['isManualOrIsNotPR'], true),
is this always true in this file ? Was is the idea behind it ? Or is that just copy&paste like in my case ?