.Net 6.0 & Visual Studio 2022 Preview
Below are .Net 6.0 & Visual Studio 2022 Preview key points which are coming up for us. Many great and exciting improvements and features which help us in day to day work going forward. If you are interested to get more details then, please refer the links given in bottom of this article.
- Visual Studio 2022 will be a 64-bit application, no longer limited to ~4gb of memory in the main devenv.exe process. We can open, edit, run, and debug even the biggest and most complex solutions without running out of memory.
- Full support for .NET 6 and its unified framework for web, client, and mobile apps for both Windows and Mac developers. That includes the .NET Multi-platform App UI (.NET MAUI) for cross-platform client apps on Windows, Android, macOS, and iOS. You can also use ASP.NET Blazor web technologies to write desktop apps via .NET MAUI.
- NET Hot Reload to apply code changes without needing to restart or lose the app state.
- Performance improvements in the core debugger, with additional features like flame charts in the profiler for better spotting the hot paths, dependent breakpoints for more precise debugging, and integrated decompilation experiences which will allow you to step through code you don’t have locally.
- Live Share opens new opportunities for collaborating with others, exchanging ideas, pair programming, and reviewing code. In Visual Studio 2022, Live Share will introduce integrated text chat so that you can have quick conversations about your code without any context switches. You’ll have options to schedule recurring sessions that reuse the same link, simplifying collaboration with your frequent contacts. To better support Live Share within organizations, we’ll also introduce session polices.
- IntelliCode now can complete the whole line auto-complete. helping you to take the right action in the right place at the right time.
- You will also be able to search outside your loaded scope, to find what you’re looking for no matter what code base or repo it’s located in.
- The Publish summary page now has actions to start / stop remote debugging and profiling under the '...' menu on the top right corner of the 'Hosting' section.
- The Connected Services page now has an action to launch Storage Explorer. Like (git connected, tfs connected).
- The "ASP.NET Core Empty" template that comes with .NET 6 is using the new 'minimal APIs' paradigm for which we have started to add support.To try out creating a minimal API, create a new ASP.NET Core empty web app.
- command to create app: dotnet new web -o MinApi
- With just a single file and a few lines of code, you now have a fully functioning HTTP API.
- New routing APIs allow users to route to any type of method. These methods can use controller-like parameter binding, JSON formatting, and action result execution.app.MapGet("/", (Func<string>)(() => "Hello World!")); So in this scenarios, we can have APIs without controller and we can directly define route and using lambda expression we can call the operations like fetch/save data.
- In 5.0, MVC added support for output formatting IAsyncEnumerable<> types by buffering the sequence in memory and formatting the buffered collection. In 6.0, when formatting using System.Text.Json, IAsyncEnumerable<> instances are no longer buffered by MVC, instead relying on the support for these types added to System.Text.Json.
public IActionResult GetProducts(){
return Ok(dbContext.Products);
}
However, if you have setup EF Core to use lazy loading, this new behavior may result in errors due to concurrent query execution while the data is being enumerated. You can revert back to the previous behavior by buffering the data yourself:
public async Task<IActionResult> Products() {
return Ok(await dbContext.Products.ToListAsync());
}
- HTTP logging is a new built-in middleware that logs information about HTTP requests and HTTP responses including the headers and entire body.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env){
app.UseHttpLogging();
}
To configure the HTTP logging middleware, you can specify HttpLoggingOptions in your call to ConfigureServices().
services.AddHttpLogging(logging => {
// Customize HTTP logging here.
logging.LoggingFields = HttpLoggingFields.All;
logging.RequestHeaders.Add("My-Request-Header");
logging.ResponseHeaders.Add("My-Response-Header");
logging.MediaTypeOptions.AddText("application/javascript");
logging.RequestBodyLogLimit = 4096;
logging.ResponseBodyLogLimit = 4096;
});
- Changed default launch profile from IIS Express to Kestrel for all new projects created in .NET 6 Preview 4. Starting Kestrel is significantly faster and results in a more responsive experience while developing your apps. (Kestrel is a cross-platform web server for ASP.NET Core).
- Previously, the ASP.NET Core template for Angular and React used specialized middleware during development to launch the development server for the front-end framework and then proxy requests from ASP.NET Core to the development server. NET 6 flips this arrangement around and take advantage of the built-in proxying support in the development servers of most modern front-end frameworks. When the ASP.NET Core app is launched, the front-end development server is launched just as before. The startup code for the ASP.NET Core app no longer needs any single-page app specific logic. The logic for starting the front-end development server during development is injecting into the app at runtime by the new Microsoft.AspNetCore.SpaProxy package.
- .NET MAUI Blazor apps: You can now host Blazor components in .NET MAUI apps to build cross-platform native apps using web UI. .NET MAUI Blazor apps can run anywhere .NET MAUI can (Windows, Mac, iOS, and Android) although our primary focus for .NET 6 is on desktop scenarios.
Download Visual Studio preview from here: https://visualstudio.microsoft.com/vs/preview/vs2022/
Release note: https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-preview
Blogs:
- https://devblogs.microsoft.com/visualstudio/visual-studio-2022/
- https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/
Categories/Tags: .net 6~visual studio 2022~vs 2022