Closed ufcpp closed 4 years ago
配信中書き捨てコード1 ReferenceEquals (警告ウェーブ)で警告が出る条件
public static void MInt(int x, int y)
{
ReferenceEquals(x, y); // 警告あり
}
public static void MValue<T>(T x, T y)
where T : struct
{
ReferenceEquals(x, y); // 警告あり
}
public static void MUnconstrained<T>(T x, T y)
{
ReferenceEquals(x, y); // 警告なし
}
2 record の ToString の中身の仕様。 PrintMembers メソッドを介してる。
record Point(int X, int Y)
{
// ToString の挙動をカスタマイズしたければこいつを上書き。
// Point { 「この中の部分を Append」 }
protected virtual bool PrintMembers(StringBuilder sb)
{
sb.Append("aaa");
return true;
}
}
3
C# 9.0 では直さない(たぶん直してる余裕ない)やつちょこっとあり。
↑直すPR出てそう。
record Derived : Base(0)
はダメだけど、record Derived() : Base(0)
は 9.0 正式リリースまでにはできるように。
record Base(int X);
record Derived : Base(0); // C# 9.0 時点ではエラーになる仕様
// C# 10.0 待ち…
//record Derived() : Base(0);
// 9.1 はないよなぁ…
// 7 時代、小数点リリースはなかなか大変だった…
//void m(int? x = default) { } // 7.1 のころ、0 扱い(本来は null。今は null)
4 もちろんリリースまでに治るやつもある。
record Point(int X, int Y);
record Point3D(int Z) : Point(1, 2); // Z のところに「未使用引数」警告
// C# 9.0 正式リリースまでには治る
record Base(int X);
record Derived : Base(0); // C# 9.0 時点ではエラーになる仕様
// C# 9.0 正式リリースまでには以下の書き方はできるようになるはず。
//record Derived() : Base(0);
ついにリリース候補に。
VS の方は「Preview 3」。
Preview 2 からの C# 差分:
==
オーバーロード、ToString
オーバーライド追加あと、Design Meeting Note 1件
a?.b.c!.d.e
問題とかは「可能な限り早くやる」とか言ってるSource Generator がらみもちゃんと試しておきたかったものの… Microsoft.CodeAnalysis.Analyzers パッケージを nuget.org 上じゃなくて、
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
からでないと取れないバージョンに更新しないと動かなくなってる状態なのでまた今度。