私はそれが標準的な慣行ではないことを知っていますが、以下を行うことの欠点またはより良い代替案はありますか?コードが適切に使用されていることを確認したいだけですが、.NETはそれを保証するために何もしません。
public class MyClass : IDisposable
public void Dispose()
{
// Some managed shutdown logic...
GC.SuppressFinalize(this);
}
#if DEBUG
// Why is ConditionalAttribute not allowed if you can still achieve this with compiler directives?
// [Conditional("DEBUG")]
~SFtpClient()
{
Debug.Fail("This class is IDisposable and should be wrapped by using {}");
}
#endif
}