Question

I've added a Fakes assembly to my Visual Studio 2012 unit test project, corresponding to my application project (the System Under Test), as described in Peter Provost's article. However, the project will no longer build, on account of an unresolved type reference in the generated Fakes code:

The type or namespace name 'FieldDefinition' does not exist in the namespace 'bc::ProductStudio' (are you missing an assembly reference?)
[C:\Users\arvek\Projects\Project\Project.Tests\obj\Debug\Fakes\bc\f.csproj]
C:\Users\arvek\Projects\Project\Project.Tests\f.cs

What's going wrong here? From what I know, this is supposed to just work, so it would seem to me there's a bug in the Fakes facilities.

Was it helpful?

Solution 2

The error is most likely due to bug in Fakes triggered by the faked assembly. I've submitted the issue to Microsoft.

OTHER TIPS

This bug is present in VS2013 as well. Link to MSDN bug.

Work Around: Delete file .messages from FakeAssemblies folder.

One option that may help you diagnose the issue is turning on diagnostics for you fakes. On your .fakes file.

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011" Diagnostic="true" Verbosity="Noisy">

Also, make sure that your "MSBuild project build output verbosity" is set to Diagnostic. You can find this in Tools -> Options -> Projects and Solutions -> Build and Run.

Rebuild you test project and now your output window should be full of info including any failures for Fakes

Deleting Fakes folder will resolve this issue.

You're not going to believe this, but I was able to get the fakes working again by simply adding a new line to the file, removing that new line, and then saving what is effectively an unmodified file. After the next build everything was fine.

Things that make you go... hmm...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top