Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yfakariya/a910778a7fdf434afeaac5396622dcac to your computer and use it in GitHub Desktop.
Save yfakariya/a910778a7fdf434afeaac5396622dcac to your computer and use it in GitHub Desktop.
C#7やC#8の新機能の実装についてのメモ。実装とは、ILなりメタデータの表現のことを指す。

ジェネリック型パラメーターのenum制約

  • 型パラメーターの制約に System.Enum 型があるだけ
  • struct 制約は付かない。

ジェネリック型パラメーターのunmanaged制約

  • 型パラメーターにカスタム属性 System.Runtime.CompilerServices.IsUnamagedAttribute が適用されているかどうか。なお、拡張メソッドと同じく、属性の型のアセンブリ名は無視される。C# 8 previewコンパイラーは、この属性をコンパイル結果のアセンブリに生成している。
  • 型パラメーターに modreq として System.Runtime.InteropServices.UnmanagedType が指定されている。
  • struct 制約も同時に付く。

readonly構造体

  • 型に System.Runtime.CompilerServices.IsReadOnlyAttribute が適用されている。

ref構造体

  • 型に System.Runtime.CompilerServices.IsByRefLikeAttribute が適用されている。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment