ardalis/SmartEnum

Can/should SmartEnum implement the non-generic IComparable interface?

開放

#427 建立於 2023年8月28日

 (0 則留言) (1 個反應) (0 位負責人)C# (185 個分叉)github user discovery
enhancementhelp wanted

倉庫指標

星標
 (2,420 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Hi. We depend on some framework code that does comparison of objects based on the non-generic IComparable interface. I just stumbled across a CS0029 compilation error when trying to use a SmartEnum derived type. I quickly realized that this is because it doesn't implement the non-generic version of the IComparable interface, only the generic one.

In this particular case, I can modify my SmartEnum-derived type to implement IComparable itself, but that may not always be possible, and obviously isn't desirable from a DRY/code maintenance point of view.

Is there a reason that SmartEnum couldn't or shouldn't also implement the non-generic IComparable interface?

Thanks in advance for any consideration of this idea.

貢獻者指南