Fix for loading both types of PDBs

This commit is contained in:
Chase Warrington 2021-08-20 01:25:52 -04:00 committed by Jesse Plamondon-Willard
parent c5c7201151
commit 5030e965dc
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 57 additions and 2 deletions

View File

@ -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 );
}
}
}

View File

@ -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 );
}