本文介绍了代码合同1.4.50126.1:ccdocgen错误(ContractExtractor.ExtractClump)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用代码约定1.4.50126.1我在.NET 3.5 C#项目中遇到以下异常。

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

生成xml文档时出错:

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

任何想法w帽子导致这个错误?代码合约是否有错误跟踪器?

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

推荐答案

>代码合约是否有错误跟踪器?

您已找到它;这个论坛。

You've found it; this forum.

我最近遇到了一个CCDoc错误,并且能够通过附加WinDbg来识别失败的代码。 我的堆栈跟踪不同,但错误消息是相同的。 也许 它会帮助您识别失败的代码,以便您可以发布
a小错误的重复:

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

- 戴夫


这篇关于代码合同1.4.50126.1:ccdocgen错误(ContractExtractor.ExtractClump)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 23:13