Search code examples
.netvisual-studiocode-contracts

Why does Code Contracts produce a MyAssembly.Contracts.pdb file?


When setting "Contract Reference Assembly" to "Build" in the Code Contracts tab of the project properties, two additional files are created (for an assembly named "MyAssembly") in the "CodeContracts" subfolder of the output folder:

MyAssembly.Contracts.dll
MyAssembly.Contracts.pdb

The first file contains all contract metadata and I understand its uses. What I don't understand is why the second file, the .pdb, is created, and whether it is needed by consumers of contract metadata (e.g. Code Contracts itself in another solution, the Code Contracts Editor Extensions, etc).

If I want other consumers of the metadata to work correctly, do I need to include the .pdb as well, or is it completely unneeded?


Solution

  • I've posted this question in the Code Contracts MSDN Forum and got an answer from Manuel Fahndrich.

    The static checker uses the generated pdb file to point to the contract that was violated in the source code (the PDB is used for IL -> source code mapping). This is only useful to whomever wrote the contract, since without the source code the contract pdb has little use, so there's no need to ship the .Contracts.pdb to third parties, only the .Contracts.dll.