Code Contracts: How do I supply a contract class for a generic interface?

断了今生、忘了曾经 提交于 2019-11-28 09:36:52

As mentioned by other comments in this question, you should remove the generic type identifier from your attribute usage as it can not be resolved at compile time:

[ContractClass(typeof(IRandomWriteAccessibleContract<>))] 

Good question, but you can see the technical reasons behind this limitation, right?

The reason that you can't specify the ContractClass is because Blah<T> is not a class.

If you can make an interface for a concrete class by specifying a value for T, even though I'm sure this is sub-optimal.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!