Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9312

2020 で一番期待している C# の機能

$
0
0

Champion "Allow Generic Attributes" · Issue #124 · dotnet/csharplang

Generic な Attribute が使えるようになる、予定。 Null check parameterも捨てがたかったけど、これでコードを綺麗に出来る部分が増えてきそうで楽しみです。あくまで気がするだけ。それとデザイン決定の会話をあんまり見ていないので、もしかしたら違ったり、実際に使えるようになったらこれは NG みたいなのもあるかもしれません。

どんなコードが書けるか

こういうクラスがあって、

classGenericAttribute<T>:Attribute{}

こんな感じで使う。と、思う。

[Generic<string>]publicstringMethodA(){}publicstringMethodB([Generic<int>]intid){}[Generic<MyClass>]publicMyClassHogeHoge{get;set;}

Note

コンパイラのステータスは roslyn/Language Feature Status.md at master · dotnet/roslynです。 C# はこっち Language Version Planningだと思います。

現状は C# 9.0 に Generic Attributesは入っていないように見えるので、もしかしたら入るかもしれないし、その次の C# 10.0 かもしれないし、もっと先の C# なのかもしれません。


Viewing all articles
Browse latest Browse all 9312

Latest Images

Trending Articles



Latest Images