core icon indicating copy to clipboard operation
core copied to clipboard

.NET 8 Pre-planning

Open richlander opened this issue 2 years ago • 13 comments

Now is a good time to start thinking about what might come next. I've started some issues to that end. Feel free to comment with links to improvements that you'd like to see in .NET 8.

  • #7566
  • https://github.com/dotnet/source-build/issues/2911
  • https://github.com/dotnet/arcade/issues/10100
  • https://github.com/dotnet/runtime/issues/71284
  • https://github.com/dotnet/sdk/issues/26256

richlander avatar Jun 25 '22 17:06 richlander

Would be nice to see more thoughts and possible roadmap around Wasm/Wasi (understanding there is still lots of spec churn that blocks/determines future of .NET support).

https://github.com/SteveSandersonMS/dotnet-wasi-sdk

shaggygi avatar Jun 25 '22 18:06 shaggygi

We have discussed it. I think it is just a when not if. The best way to make that happen sooner is offer scenarios where you think that would be useful and compelling.

richlander avatar Jun 25 '22 19:06 richlander

We have discussed it. I think it is just a when not if. The best way to make that happen sooner is offer scenarios where you think that would be useful and compelling.

I'm actually just starting to get into this space (watching Wasm vids, reading intro books on Rust, etc.). I'm blown away on what Steve has demoed in this space and see great potential. However, with my limited knowledge on topic I'm more just watching from a distance currently.

I think what I struggle with right now is what should we expect from a .NET perspective (again, understanding there is going to be lots of change/innovation as it picks up steam). For example, how will it execute in a Wasm runtime? Can we have a few C# classes that compile down to the Wasm bytecode or is a trimmed down .NET runtime and such required to bundle? And what are some average sizes of .NET code used in the space?

I'm more interested in this using with IoT (smaller constrained device). The selling point for Wasm is the compliance on different devices. Does this mean we could run .NET code on smaller devices like ESP32 using something like WAMR? Lastly, I could see some really nifty things come out of this with the work done over in dotnet/iot. But would those current bindings work if using in a bare-metal scenario or will it require Wasm to be running under Linux?

Anywhos, this definitely will be an interesting space to watch. Thx

shaggygi avatar Jun 25 '22 19:06 shaggygi

The dotnet/iot bindings will work as long as we can write a GpioWasmController. One of the huge advantages we have is that our implementation is abstracted and easy to port. Most of the bindings would not notice the difference.

I didn't know about the ESP32 implementation. I would worry more about resource constraints (memory, clock cycles).

richlander avatar Jun 25 '22 20:06 richlander

Okay. Here are the things I want/love to see in .NET 8

1- Native Support of Python As we know, Python is popular with many libraries. Especially in the field of artificial intelligence (This can greatly help the development of ML.NET, TorchSharp ...) I would like to be able to call Python code directly and interact with it in .NET (Something like P/Invoke for c++ communication) This can now be done with IronPython library.

2- C++/CLI on other platforms I know that C++/CLI is Windows OS specific technology, but is there a way to use C++/CLI on Mobile? (Xamarin/MAUI projects) Our team wrote part of a large project with cpp/cli and we use it in the WPF project. We would love to be able to use it in a future MAUI project. (I think this can even help the development of Unity games)

3- FFmpeg Today, FFmpeg is used by millions of projects Microsoft has introduced an easy way to use FFmpeg library in C#, But it only works on Windows I know this is a library and it has no direct connection to the .NET kernel, but something can be used in millions of projects, can it exist in kernel? Isn't that so? (Same as when Microsoft added system.text.json)

4- HttpClient response time I am currently using this solution Something like RoundtripTime in Ping Class

AliShahesmaeili avatar Jun 25 '22 20:06 AliShahesmaeili

5- Pass data from Attribute to Function arguments Sample:

object myObj = new MyClass();
[TestMethodWithData(new List<int> { 1,2,3,4}, "value", myObj)]
public void MyFunction(List<int> data, string value, object obj)
{
            
}

This feature helps a lot in writing unit tests (TestCaseSource Not a good idea)

6- Calculate the amount of resource usage! I would like it to tell me the amount/value of CPU and RAM used by each line of code that is executed. I know that it is possible to measure these using Visual Studio tools but what about by vscode?

var usage = Usage
{
       //codes
}

Console.WriteLine("Time " + usage.TimeInSecond);
Console.WriteLine("Total CPU Usage percentage" + usage.CPUUsage);
Console.WriteLine("Total thread " + usage.ThreadCount);
Console.WriteLine("Total Memory Usage" + usage.MemoryUsage);

Can .net itself calculate such costs in real/run time? In this way, we can measure the load/usage of our codes without Visual Studio and even in production.

7- Constructor property promotion (Like PHP)

 public class MyClass
    {
        public string Firstname { get; set; }
        public string Lastname { get; set; }
        public MyClass(string firstname, string lastname)
        {
            this.Firstname = firstname;
            this.Lastname = lastname;
        }
    }

To:

 public class MyClass
    {
        public MyClass(public string Firstname, public string Lastname)
        {
        }
    }

AliShahesmaeili avatar Oct 07 '22 21:10 AliShahesmaeili

I hope .NET 8 main focus will be Blazor.

  1. Blazor WASM size should be smaller. A production Blazor WASM should only about < 4mb.
  2. Blazor should have the ability to switch mode between Server and WASM on runtime. Just like mentioned in #38128, #35358, and #17678
  3. Blazor WASM Prerendering should include authentication #29634
  4. Blazor WASM SSG (Static Site Generation). User want their content to be generated on build time to host on Azure Static Web to have a best delivery time to user. This should be also apply to Blazor WASM Hosted Model.

These 4 are the missing pieces that I think Blazor will need to be used by a wider audience.

  • The main issue with Blazor WASM now is size.
  1. People is interested with Blazor but when they see a production Blazor size > 4mb. They will look into other JS Framework like Astro, Svelte, or NextJs.
    • These JS framework allow them to ship raw HTML and JS will be hydrate when user interact with elements so their Size is extremely small. I see their compete with each other by kb, not even mb.
    • These JS framework allow them to generate Static content page on build time and host them on CDN.
  2. Since Blazor WASM size become too large and lower the size to < 4mb is not possible then I think give the user the ability to switch mode on Runtime will become a great solution. The page first load will be Blazor Server, .wasm and .dll will be downloaded in the background, then when everything is downloaded, browser will switch mode to WASM.

arthastheking113 avatar Nov 16 '22 06:11 arthastheking113

It would be nice to reconsider Blazor custom directives for .NET 8. While the original proposal targets Razor, it makes even more sense for Blazor. There are built-in directives such as @page serving purely as a syntax sugar to @attribute []. Exposing an API to do the same would be great.

FooAttribute.cs:

public class FooAttribute : Attribute, IBlazorDirective {
   public FooAttribute(string arg) {

  }
}

BarPage.razor:

@foo "hello world"
<h1>Page title</h1>

lofcz avatar Dec 03 '22 21:12 lofcz

Would love to see (ranked from best):

  • More WASM support (smaller sizes, more docs, independence from Blazor, faster build times...)
  • More C++/C interop cross platformism
  • Extension properties/fields

aymen157 avatar Dec 29 '22 10:12 aymen157

Unfortunately, both Trimmed and AOT compilations have a lot of bugs, so they only work for a small percentage of applications so far

wf-soft avatar Jan 11 '23 09:01 wf-soft

I hope .NET 8 C# more support for native development.These are old problems.

  1. bit-field support ,from https://github.com/dotnet/csharplang/discussions/465
  2. define custom struct fxied size buffer support. from https://github.com/dotnet/csharplang/issues/1314 ,https://github.com/dotnet/csharplang/blob/main/proposals/fixed-sized-buffers.md
  3. c-style anonymous unions and structs. from https://github.com/dotnet/csharplang/discussions/687
  4. Union and Intersection types https://github.com/dotnet/csharplang/discussions/399
  5. support sizeof() used to fixed size buffer, support span<T> direct access the fixed size buffer

Although more code can be written to implement it, or a corresponding library can be developed to support it. But obviously, C# has been around for so many years, and no useful library has been developed. This means that this is not an easy job. I hope that C# can become a language closer to native programming. Although, my proposal is trivial, but I still hope: Please consider supporting these features.

sgf avatar Jan 11 '23 12:01 sgf

I'd love to see:

  1. escape analysis to stack-allocate objects automatically and reduce GC pressure.
  2. fixed size buffer for any type.
  3. more performant GC.

ygc369 avatar Feb 17 '23 13:02 ygc369

Targeted AOT compilation for WASM, as well as improved Webpack (and others) JS bundling support.

ryanwinter avatar Feb 28 '23 00:02 ryanwinter

@richlander

Is this issue still relevant or can it be closed? .NET 8 is already in GA

deeprobin avatar Feb 26 '24 05:02 deeprobin