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 2 #5889

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

What's new in .NET 6 Preview 2 #5889

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

Comments

@leecow
Copy link
Member

leecow commented Jan 28, 2021

What's new in .NET Preview 2

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

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

@Jozkee
Copy link
Member

Jozkee commented Feb 18, 2021

.NET Libraries: System.Text.Json - ReferenceHandler.IgnoreCycles

dotnet/runtime#40099

Added a new ReferenceHandler.IgnoreCycles option capable of ignoring cycles on serialization in a similar fashion to Newtonsoft's ReferenceLoopHandling.Ignore. Notice that this new feature replaces reference loops with JSON token null instead of ignoring the offending object/property+object.

Example:

class Node
{
    public string Description { get; set; }
    public object Next { get; set; }
}

void Test()
{
    var node = new Node { Description = "Node 1" };
    node.Next = node;
    
    var opts = new JsonSerializerOptions { ReferenceHandler = ReferenceHandler.IgnoreCycles };
    
    string json = JsonSerializer.Serialize(node, opts);
    Console.WriteLine(json); // Prints {"Description":"Node 1","Next":null}
}

@JulieLeeMSFT
Copy link
Member

JulieLeeMSFT commented Feb 24, 2021

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Feb 24, 2021

.NET Libraries: PriorityQueue

dotnet/runtime#43957

We have added a PriorityQueue<TElement, TPriority> collection to the System.Collections.Generic namespace. The type is similar to Queue<T> but associates each enqueued element with a priority value. On dequeue the PriorityQueue returns the element with the smallest priority. It is implemented using an array-backed min-heap.

Sample code:

// creates a priority queue of strings with integer priority
var pq = new PriorityQueue<string, int>();

// enqueue elements with associate priorities
pq.Enqueue("A", 3);
pq.Enqueue("B", 1);
pq.Enqueue("C", 2);
pq.Enqueue("D", 3);

pq.Dequeue(); // returns "B"
pq.Dequeue(); // returns "C"
pq.Dequeue(); // either "A" or "D", stability is not guaranteed.

@BrennanConroy
Copy link
Member

ASP.NET Core: SignalR - Nullable annotations

dotnet/aspnetcore#29219

We added nullable annotations to the SignalR client packages, and modified some of the annotations on SignalR server. Please try it out and see if the annotations make sense or not. You will need to put <Nullable>enable</Nullable> in your csproj in order to use the nullable annotations.

@mangod9
Copy link
Member

mangod9 commented Feb 26, 2021

All Framework Assemblies Precompiled by Crossgen2

As mentioned in the Preview1 update, System.Private.CoreLib was being compiled using the new Crossgen2 toolset. As part of extending that functionality all framework assemblies are now compiled using Crossgen2. There shouldn't be any noticeable performance differences. There are some size optimizations so size on disk for NetCoreApp should be slightly smaller

Size [MB] FullName
--------- --------
64.22     C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.3
63.31     C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.0-preview.1.21102.12
63.00     C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.0-preview.2.21118.6

@pgovind
Copy link

pgovind commented Mar 3, 2021

.NET Libraries: Numerics - Better parsing of standard numeric formats

  1. Numeric parsing precision breaking change docs#23046 (for the docs) and Update standard numeric format parsing to handle higher precision docs#22458 (for the description)
  2. Double.Parse rounding bug when there are trailing zeroes in the input string runtime#46827

We've improved the parser for the standard numeric types. Specifically, .ToString and .TryFormat will behave better when precision > 99 is specified. Also, the parser now better supports trailing zeros in the Parse method.

Examples

Old (wrong) behavior

32.ToString("C100") -> C132
Here, we had an artificial limitation in the formatting code to only handle a precision of <= 99. For precision >= 100, we instead interpreted the input as a custom format.

32.ToString("H99") -> throw a FormatException
This is correct behavior, but is called here to contrast with the next example.

32.ToString("H100") -> H132
Here, H is an invalid format specifier. So, we should've thrown a FormatException. Instead, our incorrect behavior of interpreting precision >= 100 as custom formats meant we returned wrong values.

double.Parse("9007199254740997.0") -> 9007199254740998
Here, 9007199254740997.0 is not exactly representable in the IEEE 754 format. With our current rounding scheme, the correct return value should have been 9007199254740996. However, the last .0 portion of the input was forcing the parser to incorrectly round the result and return 9007199254740998.

P2 (correct) behavior

32.ToString("C100") -> $32.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
32.ToString("H99") -> throw a FormatException
32.ToString("H100") -> throw a FormatException
double.Parse("9007199254740997.0") -> 9007199254740996.

@davidortinau
Copy link
Contributor

davidortinau commented Mar 8, 2021

.NET Multi-platform App UI

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

We have added .NET MAUI and single project developer experiences for Android, iOS, and Mac Catalyst. This release includes:

Mac Catalyst SDK and target framework moniker (`net6) for compiling .NET MAUI apps for macOS desktop

<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>

A single, multi-targeted application project

single-proj-preview2

Shared fonts, images, and app icons

Fonts and images can be placed in one location in your solution and .NET MAUI will enable them to natively work on all platforms you target. These are tracked in your *.csproj as SharedImage and SharedFont.

<ItemGroup>
    <SharedImage Include="appicon.svg" ForegroundFile="appiconfg.svg" IsAppIcon="true" />
    <SharedFont Include="Resources\Fonts\ionicons.ttf" />
  </ItemGroup>

Both accept wildcards to include all files within a location.

<ItemGroup>
    <SharedImage Include="appicon.svg" ForegroundFile="appiconfg.svg" IsAppIcon="true" />
    <SharedImage Include="Resources\Images\*" />
    <SharedFont Include="Resources\Fonts\*" />
  </ItemGroup>

MauiApp with Host Builder for bootstrapping your app

We have extensions for configuring services, fonts, and compatibility renderers for migrating Xamarin.Forms projects. IWindow has been introduced for future multi-window support coming in a future release.

public class Application : MauiApp
{
    public override IAppHostBuilder CreateBuilder() => 
        base.CreateBuilder()
            .RegisterCompatibilityRenderers()
            .ConfigureServices((ctx, services) =>
            {
                services.AddTransient<MainPage>();
                services.AddTransient<IWindow, MainWindow>();
            })
            .ConfigureFonts((hostingContext, fonts) =>
            {
                fonts.AddFont("ionicons.ttf", "IonIcons");
            });

    public override IWindow CreateWindow(IActivationState state)
    {
        Microsoft.Maui.Controls.Compatibility.Forms.Init(state);
        return Services.GetService<IWindow>();
    }
}

New Control Handlers

We have introduced the first controls and properties that implement a new handler approach. These include partial implementations of Button, Label, and Entry, Slider, and Switch.

macOS:
Screen Shot 2021-03-08 at 10 57 44 AM

iOS:
Screen Shot 2021-03-08 at 2 39 34 PM

Android:
Android emulator screenshot of .NET MAUI controls

Updates to Mobile SDKs

Android:

  • Android X libraries are now available for .NET 6 and the default dependency for Android apps

iOS:

  • Windows developers can use the Remote iOS Simulator
  • VS Mac on Windows can connect to the remote Mac build host
  • AOT enables build and deploy to physical iOS hardware

@richlander
Copy link
Member

.NET 6 Preview 2 was released: https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-2/

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

10 participants