KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'd like to specify a contract for this generic interface, using Code Contracts: interface IRandomWriteAccessible<T> { T this[uint index] { set; } uint Length { get; } } The documentation says to use the ContractClass attribute when specifying a contract for an interface. However, the compiler will complain about this: [ContractClass(typeof(IRandomWriteAccessibleContract<T>))] // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <-- compiler error interface IRandomWriteAccessible<T> { … } [ContractClassFor(typeof(IRandomWriteAccessible<T>))] // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <-- compiler error sealed class IRandomWriteAccessibleContract<T> : IRandomWriteAccessible<T> { … } It seems that type parameters cannot be used with attributes. How do I write a contract for my generic interface? Or is this not possible with Code Contracts?
Tags (comma-separated)
Save Edits
Cancel