自動生成したクラスなど、プロパティが非常に多いクラスを、Watch式などでデバッグ中に表示した際に、StackOverflowが起きる事がある。
例えばこういうコード
// ShaderのSwizzle operator相当の事をしたい
public Int4 xxxx { get=>new Int4(x,x,x,x); }
public Int4 xxxy { get=>new Int4(x,x,x,y); }
public Int4 xxxz { get=>new Int4(x,x,x,z); }
public Int4 xxxw { get=>new Int4(x,x,x,w); }
public Int4 xxyx { get=>new Int4(x,x,y,x); }
public Int4 xxyy { get=>new Int4(x,x,y,y); }
public Int4 xxyz { get=>new Int4(x,x,y,z); }
public Int4 xxyw { get=>new Int4(x,x,y,w); }
public Int4 xxzx { get=>new Int4(x,x,z,x); }
public Int4 xxzy { get=>new Int4(x,x,z,y); }
public Int4 xxzz { get=>new Int4(x,x,z,z); }
public Int4 xxzw { get=>new Int4(x,x,z,w); }
public Int4 xxwx { get=>new Int4(x,x,w,x); }
public Int4 xxwy { get=>new Int4(x,x,w,y); }
public Int4 xxwz { get=>new Int4(x,x,w,z); }
public Int4 xxww { get=>new Int4(x,x,w,w); }
public Int4 xyxx { get=>new Int4(x,y,x,x); }
public Int4 xyxy { get=>new Int4(x,y,x,y); }
public Int4 xyxz { get=>new Int4(x,y,x,z); }
public Int4 xyxw { get=>new Int4(x,y,x,w); }
public Int4 xyyx { get=>new Int4(x,y,y,x); }
:
:
以下1000行ほど
これを含むクラスのインスタンスをWatchすると落ちる。
System.Diagnostics.DebuggerBrowsable
属性を使用する
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Int4 xxxx { get=>new Int4(x,x,x,x); }
これでデバッグ中に表示されなくなり、StackOverflowを避けられる