Should FakesAssemblies files be added to source control?

Go To StackoverFlow.com

5

The new Fakes framework in VS11 allows you to create fake (mock or stub) implementations of assembly references in a Unit Test project. When an assembly is faked, VS11 generates two files for each fake:

/FakesAssemblies/[Project].Fakes.dll
/FakesAssemblies/[Project].Fakes.xml

Should these files be added to source control? My assumption is no, because they are auto-generated, but wondered if anyone had other opinions.

2012-04-05 18:51
by mcknz


5

Being auto-generated shouldn't be discriminating factor for presence in repository. After all, all kinds of auto-generated files make their way there fairly often - for example designer files.

Problem is, generating extra fakes assembly all the time could be time consuming. Microsoft posts guidelines on how you can try to optimize that:

The compilation of Fakes assemblies can significantly increase your build time. You can minimize the build time by generating the Fakes assemblies for .NET System assemblies and third-party assemblies in a separate centralized project. Because such assemblies rarely change on your machine, you can reuse the generated Fakes assemblies in other projects.

So, rarely-changing, .NET FCL / 3rd party based fake assemblies should be part of repository to speed up build process. The ones based on your own code, are probably best generated on the fly.

2012-04-06 10:15
by k.m


1

According to http://hamidshahid.blogspot.com.au/2012/11/microsoft-fakes-framework.html

The "FakesAssemblies" folder and all the files in it are generated whenever the project is compiled. This is important because if you are adding fakes for assembly for a changing component, the generation of FakesAssemblies will ensure that all changes are reflected in the generated assembly.

Also in GitHub it is recommended to exclude them in .gitignore

# Microsoft Fakes
FakesAssemblies

If you worry about time of generation during build, you can specify only what you need and disable stubs

mscorlib.fakes:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="mscorlib" Version="4.0.0.0" />
  <StubGeneration Disable="true"/>
  <ShimGeneration>
    <Clear />
    <Add FullName="System.Environment"/>
    <Add FullName="System.TimeZoneInfo"/>
    <Add FullName="System.DateTime"/>
  </ShimGeneration>
</Fakes>
System.fakes:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="System" Version="4.0.0.0"/>
  <StubGeneration Disable="true" /> 
  <ShimGeneration Disable="true" /> 
</Fakes>
2016-04-30 00:50
by Michael Freidgeim
Ads