13

I'm using Microsoft Fakes to shim a couple WindowsAzure components for testing. Following the advice in vs 2012: Shims compile, I updated my .fakes file to just generate the shims I actually need:

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="false">
  <Assembly Name="Microsoft.WindowsAzure.Storage" Version="2.1.0.0"/>
  <StubGeneration>
    <Clear/>
  </StubGeneration>
  <ShimGeneration>
    <Clear/>
    <Add FullName="Microsoft.WindowsAzure.Storage.CloudStorageAccount"/>
    <Add FullName="Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient"/>
    <Add FullName="Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer"/>
    <Add FullName="Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob"/>
    <Add FullName="Microsoft.WindowsAzure.Storage.Queue.CloudQueueClient"/>
    <Add FullName="Microsoft.WindowsAzure.Storage.Queue.CloudQueue"/>
  </ShimGeneration>
</Fakes>

But I'm still getting the "Some fakes could not be generated..." warning. All the specified shims are being generated, and commenting any of those above lines out causes my test project to fail to build. If I turn on diagnostics, I see dozens of messages like:

Warning 2   Cannot generate shim for Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient+<>c__DisplayClass1: type is not supported because of internal limitations.

Everything works, I just want to suppress the warning so it stops confusing our CI server. Is there a warning number for the non-diagnostic message I can just stick in the test project to ignore?

Community
  • 1
  • 1
superstator
  • 3,005
  • 1
  • 33
  • 43

2 Answers2

14

You can remove types from the shimgeneration using

<Remove TypeName="c__DisplayClass" />

That will remove out all the types containing the above string.

See msdn link

allen
  • 4,627
  • 1
  • 22
  • 33
  • 2
    This isn't working for me. After adding that, I am STILL getting the same warning... like it's ignoring the fact I added that line. It's doing this for about four dozen other classes as well. No matter how many REMOVE lines I put in, it still claims it can't generate shims for them (I don't want it to!)... this is getting very annoying. Any additional help? Any ideas why I can't get rid of these warnings? – pmbAustin Aug 27 '14 at 22:09
  • @pmbAustin This should work. If it isnt you should open a ticket on connect. – allen Apr 12 '16 at 11:44
  • 1
    We're abandoning MS Fakes. They're just broken, slow, and there are other better alternatives, and MS doesn't seem to be doing anything with them anyway. – pmbAustin Apr 12 '16 at 18:14
  • 1
    Unfortunately, the question as asked has not been answered; how do I suppress warnings from fakes generation? If you have a shim class that you actually need, but which has a method not used in your tests which is unstubbable, you get a similar warning with no CA number. – TamaMcGlinn Mar 28 '18 at 07:58
0

I solved this by going into my Fakes folder and deleting the fakes for that assembly, then going into the References folder and deleting the fakes DLL for that assembly. Then I right-clicked on the assembly in references, and chose Add Fakes Assembly (again).
After it did all the fakes creation stuff (takes a few minutes), I built the project again and all the errors went away.

David Storfer
  • 333
  • 3
  • 11