There was some effort to run .net on WASM in browsers. Some effort was on the MONO and some was in CoreRT. But this proposal is not that. This is about running WASM on CLR or on .net. Then WASM modules can be treated as .net assemblies and .net assemblies can reference WASM modules. And this should not be like P/Invoke, where the calling interface has to be defined again in the .net side. Some supporting points-
So, I think CLR can look into running WASM itself.
There's already https://github.com/RyanLamansky/dotnet-webassembly for example to allow compiling wasm modules to .NET assemblies. Right now the biggest pain point will be though that while it's technically not PInvoke, the interface provided is as low level as PInvoke due to WASM being very low level compared to IL.
I think official support makes a huge difference, specially in .net world. Also, producing and consuming/running WASM should be separated in my opinion.
The library Suchiman noted (written by me) does what you're asking for, just needs a few finishing touches to be able to handle any situation. Obviously native CLR support would be more convenient, and performance should be better--for example, I can't use low level memory page tricks to optimize out range checks on memory access like the CLR (and browsers) can.
I think a big barrier is that raw WASM is hard to use... your types are int32, int64, float32, and float64. That's it, and it's truly all you need to build complex types but you can't expect direct mapping of .NET strings into or out of WASM. Likewise, WASM currently has no garbage collection, so you have to use C-style memory management. Given how new it is, there isn't yet a vast array of libraries to call into like P/Invoke, so the value proposition isn't strong today...
@jkotas is this contemplated?
We have no plans in foreseeable future to have a wasm runtime built-in into .NET Runtime.
NuGet packages like https://www.nuget.org/packages/WebAssembly that wrap native wasm runtimes and expose it as .NET APIs are the right way to do this.
The WebAssembly package maps WASM instructions to IL, rather than wrapping an existing runtime. There are two packages that I know of which do wrap a native WASM runtime:
Most helpful comment
The WebAssembly package maps WASM instructions to IL, rather than wrapping an existing runtime. There are two packages that I know of which do wrap a native WASM runtime: