forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split WebAssembly SDK from Blazor SDK (dotnet#31154)
- Loading branch information
Showing
58 changed files
with
3,266 additions
and
2,514 deletions.
There are no files selected for viewing
This file contains 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 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,18 @@ | ||
using System; | ||
using System.Runtime.InteropServices.JavaScript; | ||
|
||
Console.WriteLine("Hello, Browser!"); | ||
|
||
public partial class MyClass | ||
{ | ||
[JSExport] | ||
internal static string Greeting() | ||
{ | ||
var text = $"Hello, World! Greetings from {GetHRef()}"; | ||
Console.WriteLine(text); | ||
return text; | ||
} | ||
|
||
[JSImport("window.location.href", "main.js")] | ||
internal static partial string GetHRef(); | ||
} |
4 changes: 4 additions & 0 deletions
4
src/Assets/TestProjects/VanillaWasm/Properties/AssemblyInfo.cs
This file contains 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,4 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
[assembly:System.Runtime.Versioning.SupportedOSPlatform("browser")] |
13 changes: 13 additions & 0 deletions
13
src/Assets/TestProjects/VanillaWasm/Properties/launchSettings.json
This file contains 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,13 @@ | ||
{ | ||
"profiles": { | ||
"WasmMySdk": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "https://localhost:7251;http://localhost:5015", | ||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/debug?browser={browserInspectUri}" | ||
} | ||
} | ||
} |
This file contains 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,6 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WebAssembly"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
</Project> |
11 changes: 11 additions & 0 deletions
11
src/Assets/TestProjects/VanillaWasm/runtimeconfig.template.json
This file contains 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 @@ | ||
{ | ||
"wasmHostProperties": { | ||
"perHostConfig": [ | ||
{ | ||
"name": "browser", | ||
"html-path": "index.html", | ||
"Host": "browser" | ||
} | ||
] | ||
} | ||
} |
This file contains 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,17 @@ | ||
<!DOCTYPE html> | ||
<!-- Licensed to the .NET Foundation under one or more agreements. --> | ||
<!-- The .NET Foundation licenses this file to you under the MIT license. --> | ||
<html> | ||
|
||
<head> | ||
<title>WasmMySdk</title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script type='module' src="./main.js"></script> | ||
</head> | ||
|
||
<body> | ||
<span id="out"></span> | ||
</body> | ||
|
||
</html> |
This file contains 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,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
import { dotnet } from './_framework/dotnet.js' | ||
|
||
const { setModuleImports, getAssemblyExports, getConfig } = await dotnet | ||
.withDiagnosticTracing(false) | ||
.withApplicationArgumentsFromQuery() | ||
.create(); | ||
|
||
setModuleImports('main.js', { | ||
window: { | ||
location: { | ||
href: () => globalThis.window.location.href | ||
} | ||
} | ||
}); | ||
|
||
const config = getConfig(); | ||
const exports = await getAssemblyExports(config.mainAssemblyName); | ||
const text = exports.MyClass.Greeting(); | ||
console.log(text); | ||
|
||
document.getElementById('out').innerHTML = text; | ||
await dotnet.run(); |
This file contains 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 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
Oops, something went wrong.