summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModLoading/Symbols/SymbolReader.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-25 20:01:59 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-25 20:01:59 -0400
commit0b29eb3bc37553aa2e9776e17727ba07018606ea (patch)
treebb16cc4f680d04fda9db53ea22b818c2858e616f /src/SMAPI/Framework/ModLoading/Symbols/SymbolReader.cs
parente3b38a70f8d710af07732b325a6013ed18aa0fb0 (diff)
downloadSMAPI-0b29eb3bc37553aa2e9776e17727ba07018606ea.tar.gz
SMAPI-0b29eb3bc37553aa2e9776e17727ba07018606ea.tar.bz2
SMAPI-0b29eb3bc37553aa2e9776e17727ba07018606ea.zip
minor refactoring in new symbol code
Diffstat (limited to 'src/SMAPI/Framework/ModLoading/Symbols/SymbolReader.cs')
-rw-r--r--src/SMAPI/Framework/ModLoading/Symbols/SymbolReader.cs59
1 files changed, 40 insertions, 19 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Symbols/SymbolReader.cs b/src/SMAPI/Framework/ModLoading/Symbols/SymbolReader.cs
index f1ae86a2..2171895d 100644
--- a/src/SMAPI/Framework/ModLoading/Symbols/SymbolReader.cs
+++ b/src/SMAPI/Framework/ModLoading/Symbols/SymbolReader.cs
@@ -1,4 +1,3 @@
-using System;
using System.IO;
using Mono.Cecil;
using Mono.Cecil.Cil;
@@ -6,46 +5,68 @@ using Mono.Cecil.Pdb;
namespace StardewModdingAPI.Framework.ModLoading.Symbols
{
+ /// <summary>Reads symbol data for an assembly.</summary>
internal class SymbolReader : ISymbolReader
{
- private ModuleDefinition Module;
- private Stream Stream;
- private ISymbolReader Using;
+ /*********
+ ** Fields
+ *********/
+ /// <summary>The module for which to read symbols.</summary>
+ private readonly ModuleDefinition Module;
- public SymbolReader( ModuleDefinition module, Stream stream )
+ /// <summary>The symbol file stream.</summary>
+ private readonly Stream Stream;
+
+ /// <summary>The underlying symbol reader.</summary>
+ private ISymbolReader Reader;
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="module">The module for which to read symbols.</param>
+ /// <param name="stream">The symbol file stream.</param>
+ public SymbolReader(ModuleDefinition module, Stream stream)
{
this.Module = module;
this.Stream = stream;
- this.Using = new NativePdbReaderProvider().GetSymbolReader( module, stream );
- }
-
- public void Dispose()
- {
- this.Using.Dispose();
+ this.Reader = new NativePdbReaderProvider().GetSymbolReader(module, stream);
}
+ /// <summary>Get the symbol writer provider for the assembly.</summary>
public ISymbolWriterProvider GetWriterProvider()
{
return new PortablePdbWriterProvider();
}
- public bool ProcessDebugHeader( ImageDebugHeader header )
+ /// <summary>Process a debug header in the symbol file.</summary>
+ /// <param name="header">The debug header.</param>
+ public bool ProcessDebugHeader(ImageDebugHeader header)
{
try
{
- return this.Using.ProcessDebugHeader( header );
+ return this.Reader.ProcessDebugHeader(header);
}
- catch (Exception e)
+ catch
{
- this.Using.Dispose();
- this.Using = new PortablePdbReaderProvider().GetSymbolReader( this.Module, this.Stream );
- return this.Using.ProcessDebugHeader( header );
+ this.Reader.Dispose();
+ this.Reader = new PortablePdbReaderProvider().GetSymbolReader(this.Module, this.Stream);
+ return this.Reader.ProcessDebugHeader(header);
}
}
- public MethodDebugInformation Read( MethodDefinition method )
+ /// <summary>Read the method debug information for a method in the assembly.</summary>
+ /// <param name="method">The method definition.</param>
+ public MethodDebugInformation Read(MethodDefinition method)
+ {
+ return this.Reader.Read(method);
+ }
+
+ /// <inheritdoc />
+ public void Dispose()
{
- return this.Using.Read( method );
+ this.Reader.Dispose();
}
}
}