dimohy
November 17, 2022, 2:23pm
1
어느덧 C# 11이 릴리스 되었고 C# 12에서 구현될 후보를 살펴볼 시간입니다.
현재 등록된 C# Next (C# 12 후보)는 다음의 링크를 통해 확인할 수 있습니다.
Language Feature Status
=====
This document reflects the status, and planned work in progress, for the compiler team. It is a live document
and will be updated as work progresses, features are added / removed, and as work on feature progresses.
This is not an exhaustive list of our features but rather the ones which have active development
efforts behind them.
# Working Set
| Feature | Branch | State | Developer | Reviewer | IDE Buddy | LDM Champ |
| ------- | ------ | ----- | --------- | -------- | --------- | --------- |
| [Semi-auto-properties](https://github.com/dotnet/csharplang/issues/140) | [semi-auto-props](https://github.com/dotnet/roslyn/tree/features/semi-auto-props) | [In Progress](https://github.com/dotnet/roslyn/issues/57012) | [Youssef1313](https://github.com/Youssef1313) | [333fred](https://github.com/333fred), [RikkiGibson](https://github.com/RikkiGibson) | | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) |
| [Params Span\<T> + Stackalloc any array type](https://github.com/dotnet/csharplang/issues/1757) | [params-span](https://github.com/dotnet/roslyn/tree/features/params-span) | [In Progress](https://github.com/dotnet/roslyn/issues/57049) | [cston](https://github.com/cston) | TBD | | [jaredpar](https://github.com/jaredpar) |
| [Default in deconstruction](https://github.com/dotnet/roslyn/pull/25562) | [decon-default](https://github.com/dotnet/roslyn/tree/features/decon-default) | [In Progress](https://github.com/dotnet/roslyn/issues/25559) | [jcouv](https://github.com/jcouv) | [gafter](https://github.com/gafter) | | [jcouv](https://github.com/jcouv) |
| [Roles/Extensions](https://github.com/dotnet/csharplang/issues/5497) | [roles](https://github.com/dotnet/roslyn/tree/features/roles) | [In Progress](https://github.com/dotnet/roslyn/issues/66722) | [jcouv](https://github.com/jcouv) | [AlekseyTs](https://github.com/AlekseyTs), [jjonescz](https://github.com/jjonescz) | | [MadsTorgersen](https://github.com/MadsTorgersen) |
# C# 12.0
| Feature | Branch | State | Developer | Reviewer | LDM Champ |
This file has been truncated. show original
1 Like
dimohy
November 17, 2022, 2:29pm
2
속성을 그대로 필드 처럼 사용하는 것은 다음 처럼 간단히 쓸 수 있습니다.
int Number { get; set; }
하지만 속성에 코드가 포함되면 지금까지는 필드를 선언해야만 했습니다.
int _number;
int Number {
get => _number;
set
{
if (value < 0)
_number = 0;
else
_number = value;
}
}
개선 될 내용은 필드를 선언하지 않고 field 키워드를 이용해서 다음과 같이 표현할 수 있게 합니다.
int Number {
get => field;
set
{
if (value < 0)
field = 0;
else
field = value;
}
}
4 Likes
dimohy
November 17, 2022, 2:33pm
3
지금은 최상위문에서 Main 메소드에 특성을 부여할 방법이 없습니다.
개선될 예정으로는
[main: STAThread]
처럼 메인 메소드에 특성을 부여할 수 있게 합니다.
2 Likes
dimohy
November 17, 2022, 2:40pm
4
record의 기본 생성자 처럼 class에서 기본 생성자를 사용할 수 있게 확장합니다.
record는 기본 생성자의 매개변수가 읽기 속성이 되는데 class의 경우 최종 어떻게 적용될지는 모르겠군요.
1 Like
dimohy
November 17, 2022, 2:46pm
5
C#에서 배열은 힙 메모리에 놓입니다. params를 사용할 때 이는 성능면에서 불합리한 점이 있는데요,
params에 Span로 전달할 수 있도록 개선될 예정입니다.
1 Like
dimohy
November 17, 2022, 2:50pm
6
C# 11까지 nameof에 인스턴스 멤버로 접근이 되지 않는데요, 이름이 바뀔 때 nameof 에도 반영되면 좋기 때문에 필요할 기능인 것 같습니다.
public class Other
{
public Class Class;
}
public class Class
{
[Attr(nameof(Other.Class))] // error CS0120 An object reference is required
public Other Other;
}
public class Attr : System.Attribute
{
public Attr(string s) {}
}
1 Like
dimohy
November 17, 2022, 2:52pm
7
지금은 람다의 매개변수에 기본값을 사용할 수 없습니다.
var addWithDefault = (int addTo = 2) => addTo + 1;
addWithDefault(); // 3
addWithDefault(5); // 6
이 기능은 구현되어 있으며 Visual Studio 17.5p2 부터 사용 가능합니다.
1 Like
dimohy
November 17, 2022, 2:57pm
8
C# 11까지
(int i, string j) = default; // // error CS8131: Deconstruct assignment requires an expression with a type on the right-hand-side.
(i, s) = default; // // error CS8131: Deconstruct assignment requires an expression with a type on the right-hand-side.
이렇게 사용할 수 없고 다음처럼 사용해야만 했습니다.
(int i, string s) = (default, default!);
(i, s) = (default, default!);
(int i, string s) = default; 이렇게도 사용이 가능할 예정입니다.
1 Like