microsoft / CodeContracts

Source code for the CodeContracts tools for .NET
Other
882 stars 150 forks source link

Could not resolve type reference: type is declared in assembly being rewritten #391

Open Dennis-Petrov opened 8 years ago

Dennis-Petrov commented 8 years ago

I've build CC from master branch using VS2013 just now. When building my solution from VS2015, ccrewrite fails with these messages:

6> Reading assembly 'A' from 'Path\A\obj\Debug\A.dll' resulted in errors. 6> Could not resolve type reference: [mscorlib]A.ISomeInterface,. 6> Could not resolve type reference: [mscorlib]B.SomeType. 6> Could not resolve type reference: [mscorlib]B 6> Could not resolve type reference: [mscorlib]Version=1.0.0.0. 6> Could not resolve type reference: [mscorlib].Culture=neutral. 6> Could not resolve type reference: [mscorlib].PublicKeyToken=null.

ISomeInterface is declared in A.dll and has contract class associated. B.dll is just another my assembly: A references B, and B is successfully built.

RC doesn't reproduce this error.

What additional info should I post?

hubuk commented 8 years ago

@Dennis-Petrov Is it possible to attach some minimal sample project which reproduces the problem?

General-Fault commented 7 years ago

I've encountered this error in v.1.10.20606.1-rc2 under VS 2015 when using a MEF Export attribute to export a class method as a Func<IFoo, Task<bool>>. I've attached a simple solution that should fail to compile in Debug configuration.

The error is on failure to reference IFoo, however the issue is only encountered if the IFoo is used as an input to the Func and not as the Func return value. i.e. [Export(typeof(Func<IFoo, Task<bool>>)] results in the error, however [Export(typeof(Func<Task<bool>, IFoo>)] compiles.

CodeContractSandbox.zip