벌써 Preview 7이군요. 올해도 빨리 갑니다;
opened 11:09PM - 08 Jul 21 UTC
closed 07:53PM - 11 Jan 22 UTC
documentation
# What's new in .NET 6 Preview 7
This issue is for teams to highlight work fo… r the community that will release .NET 6 Preview 7.
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: https://github.com/dotnet/core/issues/5853
Preview 2: https://github.com/dotnet/core/issues/5889
Preview 3: https://github.com/dotnet/core/issues/5890
Preview 4: https://github.com/dotnet/core/issues/6098
Preview 5: https://github.com/dotnet/core/issues/6099
Preview 6: https://github.com/dotnet/core/issues/6325
4개의 좋아요
rkttu
7월 28, 2021, 4:35오전
2
What’s new in .NET 6 Preview 7 [WIP] · Issue #6444 · dotnet/core (github.com)
암묵적 네임스페이스 import 기능은 TLP의 완성이죠.
For example, an empty web app looked like this:
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.MapGet("/", () => "Hello World!");
app.Run();
but now it’s simplified to:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.MapGet("/", () => "Hello World!");
app.Run();
3개의 좋아요
호오 .NET 콘솔 템플릿이 최신 관용구가 앞으로 적용될 예정이군요. 막 C#을 접하는 친구들에게 쉬운 느낌을 줘서 접근성이 높이질것이라는데 좋은 변화라 생각합니다.
opened 09:32PM - 29 Jun 21 UTC
closed 08:43PM - 03 Nov 21 UTC
Epic
area: template-content
In .NET 6, the included C# project templates will use the latest language idioms… .
The following language features will be used or enabled by default in the SDK-included project templates as applicable:
- [Top-level statements](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements)
- [Global using directives](https://github.com/dotnet/csharplang/issues/3428) (via [SDK driven defaults](https://github.com/dotnet/aspnetcore/issues/32451))
- [File-scoped namespaces](https://github.com/dotnet/csharplang/issues/137) ([compiler tracking issue](https://github.com/dotnet/roslyn/issues/49000))
- [Target-typed `new` expressions](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/target-typed-new)
- [Nullable reference types](https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references)
- [async Main](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.1/async-main)
## Issues
- [x] #3360
- [x] dotnet/test-templates#164
- [x] dotnet/aspnetcore#33947
- [x] dotnet/aspnetcore#33948
- [x] dotnet/winforms#5171
- [x] dotnet/wpf#4779
- [x] dotnet/wpf#4774
- [x] dotnet/maui#1497
- [x] xamarin/xamarin-android#6076
- [x] xamarin/xamarin-macios#12085
- [ ] dotnet/scaffolding#1594
- [x] dotnet/efcore#25223
## Area owners
Template area | Owner
--- | ---
Neutral (Console/Class lib) | @KathleenDollard
Unit testing | @kendrahavens
ASP.NET Core/gRPC/Worker | @DamianEdwards
Blazor | @danroth27
WinForms | @OliaG
WPF | @OliaG
MAUI | @mhutch
## Implementation Considerations
- All changes detailed here will only be applied when the project is created targeting .NET 6+ (the default)
- Some templates have a `--langVersion` option and will need to condition the relevant changes based on the supplied value so that only compatible features are utilized in the new project
- Making the changes opt-in is not being considered at this time as it defeats the intended purpose which is to have the default experience for new projects reflect the latest language idioms
- ❓ Should all changes detailed here have corresponding template options to allow opting-out of them at project creation time?
- ☑️ Decision on this is "No" for now. We can revisit based on feedback if necessary.
### Top-level statements
- [Language feature documentation](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements)
- Introduced in C# 9
- Project templates with an existing `Program.cs` will be updated to use top-level statements
### Global using directives
- [Language feature implementation issue](https://github.com/dotnet/csharplang/issues/3428)
- Introduced in C# 10
- This feature is driven by [SDK changes](https://github.com/dotnet/aspnetcore/issues/32451) and as such no actual `global using` statements should appear in the template
- Existing `using` statements in project templates that conflict with new SDK-driven default global using directives will be removed
- The following namespaces are being globally included by the SDKs:
- Microsoft.NET.SDK:
- System
- System.Collections.Generic
- System.IO
- System.Linq
- System.Net.Http
- System.Threading
- System.Threading.Tasks
- Microsoft.NET.SDK.Web:
- Everything included by Microsoft.NET.SDK, plus:
- System.Net.Http.Json
- Microsoft.AspNetCore.Builder
- Microsoft.AspNetCore.Hosting
- Microsoft.AspNetCore.Http
- Microsoft.AspNetCore.Routing
- Microsoft.Extensions.Configuration
- Microsoft.Extensions.DependencyInjection
- Microsoft.Extensions.Hosting
- Microsoft.Extensions.Logging
- Microsoft.NET.SDK.Worker
- Everything included by Microsoft.NET.SDK, plus:
- Microsoft.Extensions.Configuration
- Microsoft.Extensions.DependencyInjection
- Microsoft.Extensions.Hosting
- Microsoft.Extensions.Logging
### File-scoped namespaces
- [Language feature implementation issue](https://github.com/dotnet/csharplang/issues/137)
- Introduced in C# 10
- Any namespaces declared in existing project templates will be changed to use the file-scoped namespaces syntax
- ℹ️ This feature is not yet available in `main` builds but is expected to land during _preview.7_
### Target-typed `new` expressions
- [Language feature documentation](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/target-typed-new)
- Introduced in C# 9
- Any constructor invocation where the type name can be omitted to reduce its duplication
- ✔️ `private readonly static object s_syncObj = new object();` to `private readonly static object s_syncObj = new();`
- ❌ `var someStrings = new List<string>();` stays as it is now as the type name is not repeated
### Nullable reference types
- [Language feature documentation](https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references)
- Introduced in C# 8
- Existing project templates will enable the feature by default by having `<Nullable>enable</Nullable>` added to their `.csproj` files
- ℹ️ Enabling nullable reference types via SDK defaults was considered but rejected due to concerns with the experience during migration of existing projects to .NET 6, in that existing projects changed to target the .NET 6 TFM as part of migration will immediately exhibit compiler warnings associated with the feature being enabled and not handled correctly by the existing project code
- `.cs`, `.cshtml`, and `.razor` files in existing project templates will be updated to appropriately handle nullable reference types
- Code generation tools (e.g. Scaffolding, EF Core Migrations, etc.) should also be updated to ensure they produce code that is aligned with the nullable configuration of the target project.
### async Main
- [Language feature documentation](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.1/async-main)
- Introduced in C# 7.1
- Project templates with an existing `Program.cs` containing a `static void Main` method declaration with a body that includes calls to `Task`-returning methods (or methods with a `Task`-returning alternative) will be updated to declare the method as `async` and the calls to `Task`-returning methods will be updated with the `await` keyword.
3개의 좋아요
rkttu
8월 1, 2021, 12:41오후
4
최신 문법을 입힌 상태로 작성한 코드를 보고 C#이 아니라고 오해하실 분들도 꽤 있을것 같군요
3개의 좋아요
오 Generic Math
가 포함될 예정인가 봅니다.
public static TSelf Sum<TSelf>(IEnumerable<TSelf> values)
where TSelf : INumber<TSelf>
{
TSelf result = TSelf.Zero;
foreach (var value in values)
{
result += value;
}
return result;
}
이 기능은 C# 10에 포함될 Static abstract members in interfaces 의 기능을 이용한 것으로, 연산자 등 static의 인터페이스를 노출할 수 있게 해 특히 숫자 유형에 대한 일반 알고리즘을 제네릭으로 작성할 수 있게 합니다.
// Interface specifies static properties and operators
interface IAddable<T> where T : IAddable<T>
{
static abstract T Zero { get; }
static abstract T operator +(T t1, T t2);
}
// Classes and structs (including built-ins) can implement interface
struct Int32 : …, IAddable<Int32>
{
static Int32 I.operator +(Int32 x, Int32 y) => x + y; // Explicit
public static int Zero => 0; // Implicit
}
// Generic algorithms can use static members on T
public static T AddAll<T>(T[] ts) where T : IAddable<T>
{
T result = T.Zero; // Call static operator
foreach (T t in ts) { result += t; } // Use `+`
return result;
}
// Generic method can be applied to built-in and user-defined types
int sixtyThree = AddAll(new [] { 1, 2, 4, 8, 16, 32 });
4개의 좋아요
rkttu
8월 6, 2021, 3:58오전
7
아직은 proposal 단계이고, 작업을 시작하진 않았네요. 닷넷 6에 들어가기에는 변화 폭이 큰 기능이라 아직은 알 수 없는 부분인 것 같아요! 참고하시면 좋을듯 합니다.
3개의 좋아요