Code Contracts 1.4.50126.1: ccdocgen error (ContractExtractor.ExtractClump)

Proposed Answer Code Contracts 1.4.50126.1: ccdocgen error (ContractExtractor.ExtractClump)

  • 7 มีนาคม 2555 12:44
     
      มีโค้ด

    Using Code Contracts 1.4.50126.1 I get the following exception on an .NET 3.5 C# project.

    The error occurs during the generation of the xml documentation:

    ContractXmlDocumentation:
      "C:\Program Files (x86)\Microsoft\Contracts\Bin\ccdocgen" "@..\..\scratch\obj\API_I-Debug-AnyCPU\API_Iccdocgen.rsp"
      CCDoc failed with uncaught exception: Index was out of range. Must be non-negative and less than the size of the collection.
      Parameter name: index
      Stack trace:    at System.Collections.Generic.List`1.get_Item(Int32 index)
         at Microsoft.Cci.MutableContracts.ContractExtractor.ExtractClump(List`1 blockList, Int32 startBlockIndex, Int32 startStmtIndex, Int32 endBlockIndex, Int32 endStmtIndex)
         at Microsoft.Cci.MutableContracts.ContractExtractor.RewriteChildren(BlockStatement blockStatement)
         at Microsoft.Cci.MutableCodeModel.CodeRewriter.Rewrite(IBlockStatement block)
         at Microsoft.Cci.MutableContracts.ContractExtractor.SplitMethodBodyIntoContractAndCode(IBlockStatement blockStatement)
         at Microsoft.Cci.MutableContracts.ContractExtractor.SplitMethodBodyIntoContractAndCode(IContractAwareHost host, ISourceMethodBody sourceMethodBody, PdbReader pdbReader)
         at Microsoft.Cci.Contracts.LazyContractExtractor.GetMethodContractFor(Object method)
         at Microsoft.Cci.Contracts.CodeContractsContractExtractor.GetMethodContractFor(Object method)
         at CCDoc.CCDocContractHelper.TryGetMethodContract(CodeContractAwareHostEnvironment host, IMethodReference method, IMethodContract& methodContract, DocTracker docTracker)
         at CCDoc.ContractVisitor.ContractPackager.PackageMethodContracts(IMethodDefinition method, Boolean isPure)
         at CCDoc.ContractVisitor.Visit(IMethodDefinition methodDefinition)
         at Microsoft.Cci.MetadataTraverser.Traverse(IMethodDefinition method)
         at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 methods)
         at Microsoft.Cci.MetadataTraverser.TraverseChildren(ITypeDefinition typeDefinition)
         at Microsoft.Cci.MetadataTraverser.Traverse(INamespaceTypeDefinition namespaceTypeDefinition)
         at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 namespaceMembers)
         at Microsoft.Cci.MetadataTraverser.Traverse(INestedUnitNamespace nestedUnitNamespace)
         at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 namespaceMembers)
         at Microsoft.Cci.MetadataTraverser.Traverse(INestedUnitNamespace nestedUnitNamespace)
         at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 namespaceMembers)
         at Microsoft.Cci.MetadataTraverser.Traverse(INestedUnitNamespace nestedUnitNamespace)
         at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 namespaceMembers)
         at Microsoft.Cci.MetadataTraverser.Traverse(INestedUnitNamespace nestedUnitNamespace)
         at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 namespaceMembers)
         at Microsoft.Cci.MetadataTraverser.Traverse(INestedUnitNamespace nestedUnitNamespace)
         at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 namespaceMembers)
         at Microsoft.Cci.MetadataTraverser.Traverse(IRootUnitNamespace rootUnitNamespace)
         at Microsoft.Cci.MetadataTraverser.Traverse(IAssembly assembly)
         at CCDoc.CCDoc.GetContracts(Options options, DocTracker docTracker)
         at CCDoc.CCDoc.RealMain(String[] args)
         at CCDoc.CCDoc.Main(String[] args)
      elapsed time: 1619,1619ms
    

    Any ideas what is causing this error? Is there a bug tracker for Code Contracts?

    Ruben Vandeginste

ตอบทั้งหมด

  • 7 มีนาคม 2555 15:10
     
     

    Hi Ruben,

    > Is there a bug tracker for Code Contracts?

    You've found it; this forum.

    I recently got a CCDoc error and was able to identify the failing code by attaching WinDbg.  My stack trace is different but the error message is the same.  Perhaps it'll help you to identify your failing code so that you can post a small repro of the bug:

    http://social.msdn.microsoft.com/Forums/en/codecontracts/thread/f46cf6dd-e03a-4831-8b9a-1446c6a4732b

    - Dave


    http://davesexton.com/blog

  • 11 มีนาคม 2555 22:32
    เจ้าของ
     
     คำตอบที่เสนอ
    I believe I have found and fixed this bug, but if you can send me a self-contained repro (in a zip file), then I can make sure. The fix will be in the next release in any case.

    Mike Barnett

  • 12 มีนาคม 2555 23:44
     
     

    @Dave Sexton: I installed WinDbg and ran ccdocgen from it, but I am not getting any wiser... Obviously I am missing something, how were you able to trace back which code was making ccdocgen fail?

    @Mike Barnett: The code is not self-contained, and there are a lot of contracts in it, so it's not immediately clear where the error is coming from. I'll let you know more if I can find out more with WinDbg.

  • 12 มีนาคม 2555 23:46
    เจ้าของ
     
     
    Okay, the problem I fixed had to do with an abstract generic class that contained multiple methods with the same name. The contracts were not being matched correctly from the contract class defined for the abstract class. So if you have any of those, that would be a good place to start looking.

    Mike Barnett