Suppressing Microsoft Fakes warnings

China☆狼群 提交于 2019-11-27 23:31:00

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/20228290/suppressing-microsoft-fakes-warnings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!