code-contracts
Can I use code contracts to work around the inability to have generic constructor constraints?
I\'m tying to write a class that will create immutable copies of another class, and the way I\'m doing it requires that the copy takes a date and an instance of the original in the constructor. I know[详细]
2023-04-10 00:35 分类:问答Code contracts and ASP.Net Validators
Imagine I have a method having a contract : public void Do(string value) { Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(value));[详细]
2023-04-09 06:29 分类:问答Refactoring method parameter validation code to Contracts - inversion of statements problem
Old validation code is usually checking a boolean condition, and throws an exception if that is true.[详细]
2023-04-04 08:40 分类:问答Strange Warnings/Erros with Code Contracts and Interface inheritance
as the topic subject, I\'ve encountered strage Warnings/Erros with Code Contracts and Interface. Here my scenario[详细]
2023-04-04 05:46 分类:问答Why can't I add Contract.Requires in an overridden method?
I\'m using code contract (actually, learning using this). I\'m facing something weird to me... Ioverride a method, defined in a 3rd party assembly. I want to add a Contract.Require statement like thi[详细]
2023-04-02 08:53 分类:问答How to make Code Contracts believe that variable is not null?
I have some factory method public T Create<T> () where T : class { Contract.Ensures(Contract.Result<T>() != null);[详细]
2023-04-02 04:56 分类:问答Can an Invariant method [ContractInvariantMethod] work inside an Interface Contract?
I\'m creating an Interface Contract as described in § 2.8 Interface Contracts ofFeb 4, 2011 Code Contracts User Manual (PDF). This is not a problem.[详细]
2023-03-29 14:45 分类:问答Can code contracts cross-cut concerns of code?
Is there a way to specify code contract requirements that are cross-cutting, for example a contract at the class level to require an instance variable to be non-null whenever any instance method on th[详细]
2023-03-29 08:15 分类:问答Is it possible it see the progress of the Code Contracts static analyzer?
The static analyzer takes a long time to run. This is understandable, it is doing a lot of work. But while it runs in the background, it is difficult to tell what is going. Is the static analyzer runn[详细]
2023-03-27 22:57 分类:问答Can I get Code Contracts to warn me about "illegal" subtyping?
Sorry if this question seems too long. Before I can ask it, I need to show where it\'s coming from. Set-up:[详细]
2023-03-26 07:11 分类:问答