Back to Blog
4 min read

.NET 7 Release Candidate: Final Preview Before GA

With .NET 7 Release Candidate now available and the November 8th general availability just a week away at .NET Conf 2022, it is time to look at what this release brings for Azure developers. The RC build is go-live ready, meaning you can start using it in production with Microsoft support.

What’s Coming in .NET 7

.NET 7 continues the tradition of making .NET faster and more cloud-native with each release. Here’s a preview of the key improvements we’ll see at GA.

Performance Improvements

.NET 7 brings substantial runtime improvements:

// New On-Stack Replacement (OSR) enables more aggressive optimizations
// Methods can now be optimized while they're running

public async Task ProcessLargeDatasetAsync(IEnumerable<DataRecord> records)
{
    // OSR can now optimize this loop mid-execution
    foreach (var record in records)
    {
        await ProcessRecordAsync(record);
    }
}

Key performance gains in RC:

  • Up to 26% improvement in Arm64 code generation
  • LINQ operations are significantly faster
  • JSON serialization is 20% faster in some scenarios
  • Regex improvements with new source generators

Native AOT Compilation (Preview)

One of the most exciting features is Native AOT (Ahead-of-Time) compilation support:

// Program.cs - Can now be compiled to native code
var builder = WebApplication.CreateSlimBuilder(args);

var app = builder.Build();

app.MapGet("/", () => "Hello from Native AOT!");

app.Run();

Publish with Native AOT:

dotnet publish -c Release -r linux-x64 -p:PublishAot=true

Benefits for Azure:

  • Faster cold starts in Azure Functions
  • Smaller container images for AKS
  • Reduced memory footprint

Container Improvements

.NET 7 makes containerization simpler with built-in container support:

<!-- Project file -->
<PropertyGroup>
    <EnableSdkContainerSupport>true</EnableSdkContainerSupport>
</PropertyGroup>
# Build and publish container directly
dotnet publish --os linux --arch x64 -p:PublishProfile=DefaultContainer

This is particularly useful for Azure Container Apps deployments:

# azure-pipelines.yml
steps:
  - task: DotNetCoreCLI@2
    inputs:
      command: 'publish'
      arguments: '--os linux --arch x64 -p:PublishProfile=DefaultContainer -p:ContainerRegistry=$(containerRegistry)'

System.Text.Json Improvements

Contract customization is now available, making it easier to work with APIs:

using System.Text.Json;
using System.Text.Json.Serialization;

[JsonSerializable(typeof(WeatherForecast))]
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
public partial class AppJsonContext : JsonSerializerContext { }

public record WeatherForecast(
    DateOnly Date,
    int TemperatureC,
    string? Summary
);

// Use the source-generated serializer
var json = JsonSerializer.Serialize(forecast, AppJsonContext.Default.WeatherForecast);

Generic Math

A game-changer for library authors and data processing:

using System.Numerics;

public static T Sum<T>(IEnumerable<T> values) where T : INumber<T>
{
    T result = T.Zero;
    foreach (var value in values)
    {
        result += value;
    }
    return result;
}

// Works with any numeric type
var intSum = Sum(new[] { 1, 2, 3, 4, 5 });
var doubleSum = Sum(new[] { 1.5, 2.5, 3.5 });
var decimalSum = Sum(new[] { 1.0m, 2.0m, 3.0m });

Azure Integration Improvements

The Azure SDK benefits from .NET 7’s improvements:

using Azure.Storage.Blobs;
using Azure.Identity;

// Simplified authentication with DefaultAzureCredential
var blobServiceClient = new BlobServiceClient(
    new Uri("https://mystorageaccount.blob.core.windows.net"),
    new DefaultAzureCredential());

// Async streams work great with .NET 7
await foreach (var blobItem in containerClient.GetBlobsAsync())
{
    Console.WriteLine(blobItem.Name);
}

Minimal API Improvements

Minimal APIs get filters, similar to MVC:

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

// Endpoint filters for cross-cutting concerns
app.MapGet("/items/{id}", async (int id, IItemService service) =>
    await service.GetItemAsync(id))
    .AddEndpointFilter(async (context, next) =>
    {
        var id = context.GetArgument<int>(0);
        if (id <= 0)
        {
            return Results.BadRequest("Invalid ID");
        }
        return await next(context);
    });

app.Run();

Preparing for .NET 7 GA

With GA scheduled for November 8 at .NET Conf, here’s how to prepare:

  1. Test your applications on RC now - it’s supported for production
  2. Update the target framework:
<PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
  1. Update NuGet packages:
dotnet outdated --upgrade
  1. Review breaking changes in the migration guide

  2. Test thoroughly - especially JSON serialization changes

.NET Conf 2022

Mark your calendar for November 8-10 for .NET Conf 2022. The event will feature:

  • Official .NET 7 GA announcement
  • Deep dives into new features
  • Real-world case studies
  • Community sessions and Q&A

Conclusion

.NET 7 RC is a fantastic preview of what’s to come for Azure developers. The combination of performance improvements, Native AOT, and container support makes it easier than ever to build efficient, cloud-native applications. With the go-live license on RC, you can start testing now and be ready for GA next week.

Resources

Michael John Peña

Michael John Peña

Senior Data Engineer based in Sydney. Writing about data, cloud, and technology.