Implementation of non-void interface Code Contracts - default(T) vs throw NotImplementedException
问题 This may be mostly a question of style but when defining code contracts for non-void interface members, which approach is best: Interface: [ContractClass(typeof(IFooContract))] public interface IFoo { object Bar(); } Contract option 1: [ContractClassFor(typeof(IFoo))] public abstract class IFooContract : IFoo { object IFoo.Bar() { Contract.Ensures(Contract.Result<object>() != null); throw new NotImplementedException(); } } Contract option 2: [ContractClassFor(typeof(IFoo))] public abstract