Comments (5)
See this pull request for a quick implementation that adds basic compatibility with Code Contracts.
from moq4.
Does this build on SL or do we have conditionals in place?
from moq4.
Code Contracts should be fully support on the Silverlight platform. It compiles.
from moq4.
This doesn't compile or work on v3.5.
I'm reverting this change until that's figured out.
Thanks.
from moq4.
It would seem that since Moq no longer targets .NET 3.5 at all, that roadblock would be out of the way.
First, let me admit that while I've played around with Code Contracts it a few times over the years, I am not deeply familiar with it.
That being said, I fail to see how sprinkling a few Contract.Requires
and Contract.Ensures
is going to benefit any consumers of Moq.dll
. Unless Moq is compiled with a CONTRACTS_FULL
preprocessor symbol defined, those are simply stripped out by the compiler. And if Moq is compiled with CONTRACTS_FULL
, then those method calls in the produced binary are going to produce runtime assertion errors unless Moq.dll
is rewritten with ccrewrite
as a post-compilation step. (Which also means that the Code Contracts tools need to be installed on all build machines, including the CI server.)
As far as I understand it, ccrewrite
will perform static analysis on the Moq code base itself, based on the added contract blocks. If static analysis doesn't find any problems, the contract methods are removed. So again, we would end up with a Moq.dll
without any embedded Code Contracts information that would be useful to the consumer. Code Contracts would only have been useful to Moq's own code base.
The once possible option I can see is to factor out the contract blocks into separate contract classes ([ContractClassFor(…)]
) and not run ccrewrite
on Moq.dll
. Not sure whether this would be possible in all cases, such as for static methods like Mock.Of<T>
.
Finally, and this is perhaps the final nail in the coffin, according to microsoft/CodeContracts#409 ("What does the Future of Code Contracts Look Like?"), development on Code Contracts has more or less ceased and it apparently isn't supported on .NET Core.
I will happily stand corrected if I have misunderstood anything in this issue or in the PR referred above (#95). Until that happens, I don't see how adding Code Contracts contract blocks would benefit Moq or its consumers, so I'm closing this issue for the time being.
from moq4.
Related Issues (20)
- Wrong Setup by using String interpolation within It.Is<string> HOT 4
- Question: would it make sense to call verify all on a strict mock when the mock gets disposed?
- `DefaultValueProvider` extensibility
- Some source code files is filled with comments like: "Unmerged change from project "
- Exception throw in dotnet8 (working in dotnet6) HOT 2
- VerifySet throws TargetInvocationException when constructer refers to itself
- Add ability for asynchronously waiting for an invocation
- Moq library throwing TypeIniatilizationException. HOT 1
- Request: Ability to setup a property of type Task<ConcreteType> by mocking interface
- Supporting .NET8 HOT 2
- Mock.Protected().Verify fails sometimes
- Moq "set" matcher fails when setting StringValues with string HOT 1
- It.IsAny<StructObject>() isn't
- Documentation Unavailable Online HOT 2
- Consider adding IgnoresAccessChecksTo("Unsupported")
- Explicit support for matching cancellation tokens with It class. (It.IsCancellationToken())
- Moq Setup does not work with "object" as generic type? HOT 1
- IVerifies.Verifiable* documentation comments errata?
- Support for post-invocation callbacks on void methods?
- Semantic error in unit test MatchesIsNotInEnumerable()?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moq4.