What's new in .NET 7 preview /2#26230
Conversation
| #elif MIN | ||
| // The following code works in .NET 6, not new to .NET 7 | ||
| #region snippet_min | ||
| using Microsoft.AspNetCore.Mvc; | ||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.AddSingleton<IDateTime, SystemDateTime>(); | ||
|
|
||
| var app = builder.Build(); | ||
|
|
||
| app.MapGet("/", ( IDateTime dateTime) => dateTime.Now); | ||
| app.MapGet("/fs", ([FromServices] IDateTime dateTime) => dateTime.Now); | ||
| app.Run(); | ||
| #endregion | ||
| #endif |
There was a problem hiding this comment.
Should I mention in .NET 6, minimal APIs don't require [FromServices]?
There was a problem hiding this comment.
@Rick-Anderson I don't see where this snippet is used in the docs. Are you planning to add something related to that? If not, I am not sure if it is needed
There was a problem hiding this comment.
@Rick-Anderson I don't see where this snippet is used in the docs. Are you planning to add something related to that? If not, I am not sure if it is needed
It's not in the doc. I'll remove it. I was wondering if I should say "Minimal APIs in .NET 6 did not require [FromServices]
There was a problem hiding this comment.
In my opinion, we don't need to mention anything here since it is a doc with the new features.
|
|
||
| [!code-csharp[](~/release-notes/aspnetcore-7/samples/ApiController/Program.cs?name=snippet_dis&highlight=8-11)] | ||
|
|
||
| Prior to ASP.NET Core 7, one of the following approaches was required to bind a source in API Controller action: |
There was a problem hiding this comment.
I am not sure if we need this paragraph here. It is a little bit confusing
brunolins16
left a comment
There was a problem hiding this comment.
The initial API Controller features doc looks good for me (only small nits). It will be awesome when we have all the features together 👏.
Co-authored-by: Bruno Oliveira <brunolins16@users.noreply.github.com>
Fixes #26229
related: dotnet/aspnetcore#40071
Internal review URL