JetBrains dotCover 代码覆盖率分析失败并出现错误 "Invalid stream header"

JetBrains dotCover code coverage analysis fails with error "Invalid stream header"

我正在尝试使用 JetBrains dotCover 在 Visual Studio 2015 年确定我的 .Net Core 解决方案的单元测试覆盖率。

不幸的是,它失败并出现错误 "Coverage analysis: Invalid stream header!"。

我使用的是 ReSharper Ultimate 版本 2016.3.2。

来自日志:

|I| UnitTestSessionManager | HandleAnalysisFinished
|I| CoverageSnapshotManager | Merging snapshots 1-4
|I| CoverageSnapshotManager | Merge finished
|I| UnitTestSessionOperationManager| Operation aborted
|I| UnitTestSessionOperationManager| Operation error: Invalid stream header!
|I| UnitTestSessionOperationManager| Operation finished
|W| | Invalid stream header!

--- EXCEPTION #1/2 [PdbException]
Message = “Invalid stream header!”
ExceptionPath = Root.InnerException
ClassName = JetBrains.Metadata.Utils.Pdb.Common.PdbException
HResult = COR_E_EXCEPTION=80131500
Source = JetBrains.Platform.Metadata
StackTraceString = “
at JetBrains.Metadata.Utils.Pdb.PdbHeader..ctor(BinaryReader reader)
at JetBrains.Metadata.Utils.Pdb.PdbFile..ctor(Stream pdbStream)
at JetBrains.dotCover.DataAccess.SnapshotCore.Dal.Complementer.CoverageSnapshotStorageComplementer.TryGetAssemblyMetadataAndPdb(Lifetime lifetime, FileSystemPath assemblyPath, Stream& metadataStream, PdbFile& pdbFile)
at JetBrains.dotCover.DataAccess.SnapshotCore.Dal.Complementer.CoverageSnapshotStorageComplementer.Complement(ISnapshotStorage sourceStorage, IStorageSectionWriter storageAppender, ISnapshotScopeInfoProvider snapshotScopeInfoProvider, Predicate`1 includeModule, IEnumerable`1 patternFilters, IEnumerable`1 attributeFilters, IProgressIndicator progress)
at JetBrains.dotCover.DataAccess.SnapshotCore.Dal.CoverageSnapshotManager.Complement(IStorageDescriptor source, ISnapshotScopeInfoProvider snapshotScopeInfoProvider, Predicate`1 includeModule, IEnumerable`1 patternFilters, IEnumerable`1 attributeFilters, IProgressIndicator progress)
at JetBrains.dotCover.Workspace.Impl.UnitTesting.Model.UnitTestSessionManager.HandleAnalysisFinished(ProgressId progressId, Boolean complementSnapshot, CoverageFilterSet coverageFilters, AttributeFilterSet attributeFilters, ElementInfoProvider elementInfoProvider)
at SyncInvokeHandleAnalysisFinished(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
”

--- Outer ---

--- EXCEPTION #2/2 [LoggerException]
Message = “Invalid stream header!”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = “Exception #1 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
at System.ServiceModel.Dispatcher.ErrorBehavior.HandleErrorCommon(Exception error, ErrorHandlerFaultInfo& faultInfo)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessageCleanup(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage9(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage8(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.ProcessError(Exception e)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state)
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
at System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(Boolean haveResult, Int32 error, Int32 numBytes)
at System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 error, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

dotCover 2016.3 和新样式 "portable" pdb 文件存在问题。

您可以:

  • 使用 "full" pdb 文件,通过编辑 project.json
  • 中的 属性
  • 在 ReSharper → 选项 → dotCover → 常规中取消选中 "Include not loaded solution assemblies into coverage results" 设置。

这将在 2017.1 中修复