pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
745 stars 112 forks source link

JetBrains dotCover can't read pdb-files produced by Aspect Injector #107

Closed ESolovova closed 3 years ago

ESolovova commented 4 years ago

dotCover considers pdb-files to be invalid:

Message = Inner scope [IL_0004-IL_005d] is not inside parent Scope(IL_0000-IL_0000, 6000001)
ExceptionPath = Root.InnerException
ClassName = System.ArgumentException
HResult = E_INVALIDARG=COR_E_ARGUMENT=WIN32_ERROR_INVALID_PARAMETER=80070057
Source = JetBrains.Platform.Metadata
StackTraceString = 
  at JetBrains.Metadata.Debug.LocalScope.GetOrCreateInnerScopes(Int32 startOffset, Int32 endOffset, ICollection`1 scopes, ImportScope importScope) in /Product.Root/Platform/Core/Shell/Metadata/Src/Debug/LocalScope.cs:line 155
     at JetBrains.Metadata.Debug.DebugDataExtensions.AddLocalVariables(DebugMethod method, DebugLocalVariable[] localVariables, Int32 scopeStartOffset, Int32 scopeEndOffset, ImportScope importScope) in /Product.Root/Platform/Core/Shell/Metadata/Src/Debug/DebugDataExtensions.cs:line 152
     at JetBrains.Metadata.Debug.DebugDataExtensions.AddLocalVariable(DebugMethod method, Int32 index, String name, LocalVariableAttributes attributes, MetadataToken localSignatureToken, TupleElementNamesData tupleElementNames, Int32 scopeStartOffset, Int32 scopeEndOffset, ImportScope importScope) in /Product.Root/Platform/Core/Shell/Metadata/Src/Debug/DebugDataExtensions.cs:line 142
     at JetBrains.Metadata.Debug.DebugDataExtensions.ProcessScopes(DebugMethod method, PdbScope scope, ImportScope importScope, PdbFunction pdbFunction) in /Product.Root/Platform/Core/Shell/Metadata/Src/Debug/DebugDataExtensions.cs:line 93
     at JetBrains.Metadata.Debug.DebugDataExtensions.CreateMethod(DebugData debugData, PdbFunction pdbFunction) in /Product.Root/Platform/Core/Shell/Metadata/Src/Debug/DebugDataExtensions.cs:line 68
     at JetBrains.Metadata.Debug.Pdb.WindowsPdbFile.GetDebugData(PdbParseLevel level, FileSystemPath originalPdbFilePath) in /Product.Root/Platform/Core/Shell/Metadata/Src/Debug/Pdb/WindowsPdbFile.cs:line 306
     at JetBrains.Metadata.Debug.Pdb.PdbUtils.ToParsedPdb(WindowsPdbFile windowsPdbFile, PdbParseLevel level, DateTime pdbTimestamp) in /Product.Root/Platform/Core/Shell/Metadata/Src/Debug/Pdb/PdbUtils.cs:line 384
     at JetBrains.Metadata.Debug.Pdb.PdbReader.ReadPdb(FileSystemPath pdbPath, PdbParseLevel level, IDebugAssemblyInfo debugAssemblyInfo) in /Product.Root/Platform/Core/Shell/Metadata/Src/Debug/Pdb/PdbReader.cs:line 38

It seems to me that the problem is caused by the FluentIL.MethodEditor.Instead extension which clears method body instructions, but doesn't clear method variables: https://github.com/pamidur/fluent-il/blob/cf245d3e7cb9dab3e72c08b847a7adc5f49d915b/src/FluentIL/MethodEditor.cs#L50

Because of that MonoCecil writes to pdb-files invalid scopes debug info.

pamidur commented 4 years ago

Hi, Thanks for the report. Look like a bug. Will be fixed.

ps. do you know if there is any lib that I can use to check the validity of pdb at runtime (tests)?

ESolovova commented 4 years ago

ps. do you know if there is any lib that I can use to check the validity of pdb at runtime (tests)?

Unfortunately, no, I don't know, sorry. I use our own JetBrains pdb reader, but it's not public.

pamidur commented 4 years ago

Would you mind to check if v2.2.3 fix the issue, please?

lanegoolsby commented 4 years ago

It did not

pamidur commented 4 years ago

There were some changes recently, could you please check it against 2.4.1 if this issue is still relevant

lanegoolsby commented 4 years ago

The issue is not resolved.

pamidur commented 3 years ago

tracked in #150