-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 8 Preview 7 [WIP] #8438
Comments
HybridGlobalization mode on iOS/tvOS/MacCatalyst platformsMobile app can use a new globalization mode that brings lighter ICU bundle and leverages Native API instead. In Hybrid mode, globalization data is partially pulled from ICU bundle and partially from calls into Native API. It serves all the locales supported by Mobile. When to consider using HybridGlobalization:This option is most suitable for applications that cannot work in InvariantGlobalization mode and are using cultures which where trimmed from ICU data on mobile or want to load smaller ICU data file. How to use HybridGlobalization:Set MsBuild property: Adventages
Limitations:Due to limitations of Native API, not all Globalization APIs are supported in Hybrid mode. Some of the supported APIs changed their behavior. To make sure your application will not be affected, read the section Behavioral differences for OSX. Final noteWe would like to invite everyone to try out this new feature and file any discovered issues to help us improve the user experience further. |
Re-adding feature we accidentally included in Preview 6 blog post and then removed: #8437 (comment) Support for HTTPS proxyWhile How to Usefor Unix |
System.Text.Json Improvements
|
CodeGenCommunity PRs (Many thanks to JIT community contributors!)
Struct Physical PromotionPR#88090 enabled a new physical promotion optimization pass that generalizes the JIT's ability to promote struct variables. This optimization (also commonly called scalar replacement of aggregates) replaces the fields of struct variables by primitive variables that the JIT is then able to reason about and optimize more precisely. The JIT already supported this optimization but with several large limitations. Some of the largest limitations of the JIT's existing support was that it was only supported for structs with 4 or fewer fields, and only if each field was of a primitive type, or a very simple struct wrapping a primitive type. Physical promotion removes these limitations which fixes a number of long-standing JIT issues (see the PR for some of the issues closed). As an example: private readonly Dictionary<int, int> _dictionary = new(Enumerable.Range(0, 10000).Select(i => KeyValuePair.Create(i, i)));
[Benchmark]
public int SumDict()
{
int sum = 0;
foreach ((int key, int value) in _dictionary)
{
sum += key;
sum += value;
}
return sum;
}
private readonly List<(int, int)> _list = Enumerable.Range(0, 10000).Select(i => (i, i)).ToList();
[Benchmark]
public int SumList()
{
int sum = 0;
foreach ((int key, int value) in _list)
{
sum += key;
sum += value;
}
return sum;
} see significant improvements, here measured on an i9-10885H:
|
OpenFolderDialog in WPFWPF now ships with new dialog box control - OpenFolderDialog which allows users to browse and select folders in their application. This reduces the need for external 3rd party dependency for supporting this usecase. How to use it ? OpenFolderDialog openFolderDialog = new OpenFolderDialog()
{
Title = "Select folder to open ...",
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
};
string folderName = "";
if (openFolderDialog.ShowDialog() == true)
{
folderName = openFolderDialog.FolderName;
} |
Microsoft.Extensions.Hosting.IHostedLifecycleServiceHosted services now have more options for execution during the application lifecycle. How to use it ?IHostBuilder hostBuilder = new HostBuilder();
hostBuilder.ConfigureServices(services =>
{
services.AddHostedService<MyService>();
}
using (IHost host = hostBuilder.Build())
{
await host.StartAsync();
}
public class MyService : IHostedLifecycleService
{
public Task StartingAsync(CancellationToken cancellationToken) => /* add logic here */ Task.CompletedTask;
public Task StartAsync(CancellationToken cancellationToken) => /* add logic here */ Task.CompletedTask;
public Task StartedAsync(CancellationToken cancellationToken) => /* add logic here */ Task.CompletedTask;
public Task StopAsync(CancellationToken cancellationToken) => /* add logic here */ Task.CompletedTask;
public Task StoppedAsync(CancellationToken cancellationToken) => /* add logic here */ Task.CompletedTask;
public Task StoppingAsync(CancellationToken cancellationToken) => /* add logic here */ Task.CompletedTask;
} |
Keyed services support in Microsoft.Extensions.DependencyInjectiondotnet/runtime#64427, dotnet/runtime#87183 Provides a means for registering and retrieving DI services using keys. Keys allow for scoping of registration and consumption of services. Support has been added to DI abstractions, as well as an implementation in the built in Microsoft.Extensions.DependencyInjection. See more detail in the linked issue. How to use it?using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<BigCacheConsumer>();
builder.Services.Addsingleton<SmallCacheConsumer>();
builder.Services.AddKeyedsingleton<IMemoryCache, BigCache>(“big“);
builder.Services.AddKeyedSingleton<IMemoryCache, SmallCache>("small“);
var app = builder.Build();
app.MapGet(“/big", (BigCacheConsumer data) => data.GetData());
app.MapGet(“/small", (SmallCacheConsumer data) => data.GetData());
app.Run();
class BigCacheConsumer([FromKeyedServices("big“)] IMemoryCache cache)
{
public object? GetData() => cache.Get("data");
}
class SmallCacheConsumer(IKeyedServiceProvider keyedServiceProvider)
{
public object? GetData() => keyedServiceProvider.GetRequiredKeyedService<IMemoryCache>("small");
} |
New Platforms for Docker ASP.NET Composite ImagesIn Preview 5, we released a new flavor of our ASP.NET Docker Images: The Composites. These were initially only available on Alpine Linux containers, so as part of the Preview 7 new features, we present to you two new flavors of the composite images:
Here is the original description explaining what the composite images are in more detail, how they work, and where they can be acquired. What are the composite images?As part of the containerization performance efforts, we are now offering a new ASP.NET Alpine-based Docker image with a composite version of the runtime in Preview 5. This composite is built by compiling multiple MSIL assemblies into a single R2R output binary. Due to having these assemblies embedded into a single image, we save jitting time and thus boosting the startup performance of apps. The other big advantage of the composite over the regular ASP.NET image is that the composites have a smaller size on disk. However, all these benefits don't come without a caveat. Since composites have multiple assemblies embedded into one, they have tighter version coupling. This means the final app run cannot use custom versions of framework and/or ASP.NET binaries embedded into the composite one. Where can we get the composite images?As of now, the composite images are available as preview in under the |
Looks like a small typo at the end of this one, I assume you meant it to be |
Seems like a typo. Yes, change to |
fyi this and the asp.net core blog appear on https://devblogs.microsoft.com/dotnet but not https://devblogs.microsoft.com. Not sure if intended |
You're right @Rob-Hague. I'll report that to the devblogs team. |
@Rob-Hague forgot to report earlier that this issue has been fixed. The posts are now at https://devblogs.microsoft.com/page/30 and https://devblogs.microsoft.com/page/31. |
What's new in .NET 8 Preview 7
This issue is for teams to highlight work for the community that will release in .NET 8 Preview 7
To add content, use a new conversation entry. The entry should include the team name and feature title as the first line shown in the template below.
Required
Optional
Below are three additional items to consider. These will help the .NET 8 blog team and the community throughout the release.
Index of .NET 8 releases
Preview 1: #8133
Preview 2: #8134
Preview 3: #8135
Preview 4: #8234
Preview 5: #8436
Preview 6: #8437
Preview 7: #8438
RC 1: #8439
RC 2: #8440
The text was updated successfully, but these errors were encountered: