Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

.NET Standard for WebAssembly #1073

Closed
kjpou1 opened this issue Feb 18, 2019 · 4 comments
Closed

.NET Standard for WebAssembly #1073

kjpou1 opened this issue Feb 18, 2019 · 4 comments
Labels
netstandard-api This tracks requests for standardizing APIs. question General question, not a problem in source code or documentation (yet)
Milestone

Comments

@kjpou1
Copy link

kjpou1 commented Feb 18, 2019

Rationale and Usage

As WebAssembly support in Mono is being worked on there is a need to consider it as a platform for NS2.1. PlatformID.WebAssembly

Proposed API

PlatformID

This adds WebAssembly enum to PlatformID

    public enum PlatformID
    {
        [EditorBrowsable(EditorBrowsableState.Never)] Win32S = 0,
        [EditorBrowsable(EditorBrowsableState.Never)] Win32Windows = 1,
        Win32NT = 2,
        [EditorBrowsable(EditorBrowsableState.Never)] WinCE = 3,
        Unix = 4,
        [EditorBrowsable(EditorBrowsableState.Never)] Xbox = 5,
        [EditorBrowsable(EditorBrowsableState.Never)] MacOSX = 6
        [EditorBrowsable(EditorBrowsableState.Never)] WebAssembly = 7
    }

OSPlatform

This adds OSPlatform.WebAssembly.

namespace System.Runtime.InteropServices
{
    public readonly struct OSPlatform : IEquatable<OSPlatform>
    {
        private readonly string _osPlatform;

        public static OSPlatform WebAssembly { get; } = new OSPlatform("WEBASSEMBLY");

        public static OSPlatform FreeBSD { get; } = new OSPlatform("FREEBSD");

        public static OSPlatform Linux { get; } = new OSPlatform("LINUX");

        public static OSPlatform OSX { get; } = new OSPlatform("OSX");

        public static OSPlatform Windows { get; } = new OSPlatform("WINDOWS");

Issue from Blazor: mono/mono#13002

@terrajobst @marek-safar @lewing

@terrajobst
Copy link

terrajobst commented Feb 23, 2019

@danroth27

This requires more thought than just this API change. We'll have to figure out how we're going to model web assembly all up (e.g. will we have a TFM), including how many APIs/behaviors need to be tweaked for web assembly. It's a great issue and it should be discussed. Not sure this is the right place, but there is also no reason to close this issue :-)

@terrajobst terrajobst added question General question, not a problem in source code or documentation (yet) netstandard-api This tracks requests for standardizing APIs. labels Feb 23, 2019
@terrajobst terrajobst added this to the Future milestone Feb 23, 2019
@jeromelaban
Copy link

jeromelaban commented Feb 23, 2019

A lot of the discussion around this topic happened in this PR: NuGet/NuGet.Client#2159, which was closed for some reason, without having a follow-up.

@timcromarty
Copy link

Is there any update or progress on this? I am writing .NET standard libraries for use in both server side and WASM client side. Looking for a way to determine which environment I am running in so I can tailor some functionality accordingly. In my case exception handling logic needs to be different.

@lewing lewing closed this as completed Aug 2, 2020
@danroth27
Copy link
Member

@timcromarty This should do the trick: RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
netstandard-api This tracks requests for standardizing APIs. question General question, not a problem in source code or documentation (yet)
Projects
None yet
Development

No branches or pull requests

6 participants