Suppressing Microsoft Fakes warnings

superstator picture superstator · Nov 26, 2013 · Viewed 8k times · Source

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?

Answer

allen picture allen · Nov 27, 2013

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