samedi 2 janvier 2016

How to create the shims for the sealed classes, and where can I find the `fakes`-format description?

MS Visual Studio 2015 Enterprise.

I need to generate the shims through Microsoft Fakes Platform for three classes of external managed assembly. I wrote this:

<Fakes xmlns="http://ift.tt/1nzIu3W">
  <Assembly Name="acmgd" Version="17.2.0.0"/>
  <StubGeneration>
    <Clear/>
  </StubGeneration>
  <ShimGeneration>
    <Clear />
    <Add FullName=
         "Autodesk.AutoCAD.ApplicationServices.Application"/>
    <Add FullName=
         "Autodesk.AutoCAD.ApplicationServices.DocumentCollection"/>
    <Add FullName=
         "Autodesk.AutoCAD.ApplicationServices.Document"/>
  </ShimGeneration>
</Fakes>

The Autodesk.AutoCAD.ApplicationServices.Application class is sealed. The Microsoft Fakes Platform doesn't create the shim for it.

The type or namespace name ShimApplication does not exist in the namespace Autodesk.AutoCAD.ApplicationServices.Fakes (are you missing an assembly reference?)

How can I fix it?

Also I have a question about the fakes-file structure. I can't find info about the ShimGeneration element. In the MSDN samples I see the StubGeneration element using only. From MSDN:

Stubbing concrete classes and virtual methods

By default, stub types are generated for all non-sealed classes. It is possible to restrict the stub types to abstract classes through the .fakes configuration file:

<Fakes xmlns="http://ift.tt/1nzIu3W">
  <Assembly Name="mscorlib" />
  <!-- user code -->
  <StubGeneration>
    <Types>
      <Clear />
      <Add AbstractClasses="true"/>
    </Types>
  </StubGeneration>
  <!-- /user code -->
</Fakes>

But in real life the XSD schema doesn't define the Types and the Add hasn't AbstractClasses attribute...

Where can I find actual and detailed info about the fakes-format?

Aucun commentaire:

Enregistrer un commentaire