Fix for loading both types of PDBs
This commit is contained in:
parent
c5c7201151
commit
5030e965dc
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Cecil.Pdb;
|
||||
|
||||
namespace StardewModdingAPI.Framework.ModLoading
|
||||
{
|
||||
internal class MySymbolReader : ISymbolReader
|
||||
{
|
||||
private ModuleDefinition Module;
|
||||
private Stream Stream;
|
||||
private ISymbolReader Using;
|
||||
|
||||
public MySymbolReader( ModuleDefinition module, Stream stream )
|
||||
{
|
||||
this.Module = module;
|
||||
this.Stream = stream;
|
||||
this.Using = new NativePdbReaderProvider().GetSymbolReader( module, stream );
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Using.Dispose();
|
||||
}
|
||||
|
||||
public ISymbolWriterProvider GetWriterProvider()
|
||||
{
|
||||
return new PortablePdbWriterProvider();
|
||||
}
|
||||
|
||||
public bool ProcessDebugHeader( ImageDebugHeader header )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.Using.ProcessDebugHeader( header );
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.Using.Dispose();
|
||||
this.Using = new PortablePdbReaderProvider().GetSymbolReader( this.Module, this.Stream );
|
||||
return this.Using.ProcessDebugHeader( header );
|
||||
}
|
||||
}
|
||||
|
||||
public MethodDebugInformation Read( MethodDefinition method )
|
||||
{
|
||||
return Using.Read( method );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ namespace StardewModdingAPI.Framework.ModLoading
|
|||
public ISymbolReader GetSymbolReader( ModuleDefinition module, string fileName )
|
||||
{
|
||||
if ( this.SymbolMapping.ContainsKey( module.Name ) )
|
||||
return new NativePdbReaderProvider().GetSymbolReader( module, this.SymbolMapping[ module.Name ] );
|
||||
return new MySymbolReader( module, this.SymbolMapping[ module.Name ] );
|
||||
|
||||
return this.BaseProvider.GetSymbolReader( module, fileName );
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace StardewModdingAPI.Framework.ModLoading
|
|||
public ISymbolReader GetSymbolReader( ModuleDefinition module, Stream symbolStream )
|
||||
{
|
||||
if ( this.SymbolMapping.ContainsKey( module.Name ) )
|
||||
return new PortablePdbReaderProvider().GetSymbolReader( module, this.SymbolMapping[ module.Name ] );
|
||||
return new MySymbolReader( module, this.SymbolMapping[ module.Name ] );
|
||||
|
||||
return this.BaseProvider.GetSymbolReader( module, symbolStream );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue