Skip to content
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

What's new in .NET 6 Preview 3 #5890

Closed
leecow opened this issue Jan 28, 2021 · 7 comments
Closed

What's new in .NET 6 Preview 3 #5890

leecow opened this issue Jan 28, 2021 · 7 comments
Milestone

Comments

@leecow
Copy link
Member

leecow commented Jan 28, 2021

What's new in .NET 6 Preview 3

This issue is for teams to highlight work for the community that will release .NET 6 Preview 3.

To add content, use a new conversation entry. The entry should include the team name and feature title as the first line as shown in the template below.

## Team Name: Feature title

[link to the tracking issue or epic item for the work]

Tell the story of the feature and anything the community should pay particular attention 
to be successful using the feature.

Preview 1: #5853
Preview 2: #5889
Preview 3: #5890
Preview 4: #6098
Preview 5: #6099

@leecow leecow changed the title What's new in .NET Preview 3 [WIP] What's new in .NET 6 Preview 3 [WIP] Jan 28, 2021
@jeffhandley jeffhandley added this to the 6.0 milestone Feb 4, 2021
@benaadams
Copy link
Member

.NET Libraries: System.Runtime.InteropServices - CollectionsMarshal.GetValueRef

dotnet/runtime#49388

Updating struct values in dictionaries currently can be expensive as it requires a dictionary lookup and a copy to stack of the struct; then after changing the struct it needs to be assigned to the dictionary key again resulting in another look up and copy operation.

A new unsafe api has been added; for high preformance scenarios, that returns a ref to the struct value which can then be updated in place. This reduces the key hashing to 1 (from 2) and removes all the struct copy operations.

Example:

ref MyStruct value = CollectionsMarshal.GetValueRef(dictionary, key);
// Returns Unsafe.NullRef<TValue>() if it doesn't exist; check using Unsafe.IsNullRef(ref value)
if (!Unsafe.IsNullRef(ref value))
{
    // Mutate in-place
    value.MyInt++;
}

@benaadams
Copy link
Member

benaadams commented Mar 25, 2021

Faster interface checking and casting

dotnet/runtime#49257

One of the advantages of more parts of the .NET VM moving from C++ to managed C# is its easier to contribute to,
this includes interface casting.

.NET 6 Preview 3 includes a 16% - 38% performance boost for interface casting; this is particularly useful for C#'s pattern matching to and between interfaces.

image

Method Implementation Mean Version Ratio Improvement
IsInterface1 Interfaces1 2.166 ns .NET 6 Preview 2 1.000
IsInterface1 Interfaces1 1.629 ns .NET 6 Preview 3 0.752 x1.3
IsNotImplemented Interfaces1 2.166 ns .NET 6 Preview 2 1.000
IsNotImplemented Interfaces1 1.950 ns .NET 6 Preview 3 0.900 x1.1
IsInterface1 Interfaces6 2.155 ns .NET 6 Preview 2 1.000
IsInterface1 Interfaces6 1.936 ns .NET 6 Preview 3 0.898 x1.1
IsInterface2 Interfaces6 2.161 ns .NET 6 Preview 2 1.000
IsInterface2 Interfaces6 1.908 ns .NET 6 Preview 3 0.883 x1.1
IsInterface3 Interfaces6 2.188 ns .NET 6 Preview 2 1.000
IsInterface3 Interfaces6 1.672 ns .NET 6 Preview 3 0.764 x1.3
IsInterface4 Interfaces6 2.346 ns .NET 6 Preview 2 1.000
IsInterface4 Interfaces6 1.965 ns .NET 6 Preview 3 0.838 x1.2
IsInterface5 Interfaces6 3.122 ns .NET 6 Preview 2 1.000
IsInterface5 Interfaces6 2.173 ns .NET 6 Preview 3 0.696 x1.4
IsInterface6 Interfaces6 3.472 ns .NET 6 Preview 2 1.000
IsInterface6 Interfaces6 2.687 ns .NET 6 Preview 3 0.774 x1.3
IsNotImplemented Interfaces6 3.644 ns .NET 6 Preview 2 1.000
IsNotImplemented Interfaces6 3.071 ns .NET 6 Preview 3 0.843 x1.2

@danmoseley
Copy link
Member

Thanks for adding these @benaadams !

@JulieLeeMSFT
Copy link
Member

JulieLeeMSFT commented Mar 26, 2021

CodeGen

Community contributions

Dynamic PGO dotnet/runtime#43618

Stabilize performance measurements dotnet/runtime#43227

Keep structs in register dotnet/runtime#43867

Completed .NET 6 EH Write Thru dotnet/runtime#35923

Optimizations:

@davidortinau
Copy link
Contributor

davidortinau commented Apr 6, 2021

.NET MAUI

Community Contributions

image

Windows Platform Added

dotnet/maui#548

// images coming

With the release of Project Reunion 0.5, .NET MAUI now supports Windows development on .NET 6 Preview 3. Using Visual Studio 16.10 latest public preview, clone the .NET 6 sample here for your first look at .NET MAUI with WinUI 3. When .NET build tooling support is enabled for Project Reunion, we will add Windows to the project template and enable single project features.

Platform Lifecycle Events

A new extension has been added to enable application and library authors to easily hook-in to any native lifecycle event. A basic example is connecting to the Android back button event:

public class Startup : IStartup
{
    public void Configure(IAppHostBuilder appBuilder)
    {
        appBuilder
            .UseMauiApp<App>()
            .ConfigureLifecycleEvents(lifecycle => {
                #if ANDROID
                lifecycle.AddAndroid(d => {
                    d.OnBackPressed(activity => {
                        System.Diagnostics.Debug.WriteLine("Back button pressed!");
                    });
                });
                #endif
            });
    }
}

I'm writing a deep dive blog that will go into much more detail

Incremental Updates

// control gallery image coming

  • Continued porting of UI controls and properties from Xamarin.Forms renderers to .NET MAUI handlers:
    o ActivityIndicator
    o Button
    o CheckBox
    o DatePicker
    o Editor
    o Entry
    o Label
    o Picker
    o ProgressBar
    o SearchBar
    o Slider
    o Stepper
    o Switch
    o TimePicker
  • Expanded font support across handlers
  • Grid added support for absolute and auto-sizing
  • Implemented LayoutAlignment for all layouts
  • Application updates for
    • simplified HostBuilder integration
    • new RegisterFormsCompatibility() method enables using App.xaml and auto-registers compatibility renderers
    • added loading global ResourceDictionary

Changes from Preview 2

  • MauiApp is replaced with Application
  • SharedImage and SharedFont are changed to MauiImage and MauiFont

@sps014
Copy link

sps014 commented Apr 15, 2021

@leecow Since Dotnet 6 preview 3 is already released this issue can be closed.

@mairaw
Copy link
Contributor

mairaw commented Apr 17, 2021

@mairaw mairaw closed this as completed Apr 17, 2021
@leecow leecow changed the title What's new in .NET 6 Preview 3 [WIP] What's new in .NET 6 Preview 3 Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants