Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
メソッドの呼び出し元がアセンブリへの内部アクセスを持っているかどうかをメソッドで検出する必要があります。つまり、a) 同じアセンブリ内のコードであるか、b) アセンブリとの InternalsVisibleTo 関係がある場合です。理想的には、チェックは高速であるべきです。
私のオプションは何ですか?
更新: 問題の一部に適切な解決策があれば、私も部分的に満足します。
System.Diagnostics.StackTrace を調べる
System.Diagnostics.StackTrace st = new StackTrace(); MethodBase mb = st.GetFrame(1).GetMethod(); Assembly a = mb.DeclaringType.Assembly;
a)現在のアセンブリをaと比較するだけです
b) アセンブリの InternalsVisibleTo 属性を選択できるはずだと思います