Skip to content

Commit

Permalink
fix(apireference): Fix loading of referenced assemblies
Browse files Browse the repository at this point in the history
Include the directory a assembly is loaded from as search directory for Mono.Cecil's assembly resolver to fix AssemblyResolutionException
  • Loading branch information
ap0llo committed Aug 22, 2019
1 parent 936af6e commit 230f40d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/MdDocs.ApiReference.Model/AssemblyDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public sealed class AssemblyDocumentation : IDisposable, IDocumentation
private readonly IXmlDocsProvider m_XmlDocsProvider;
private readonly ILogger m_Logger;


/// <summary>
/// Gets the assembly's definition.
/// </summary>
Expand Down Expand Up @@ -64,9 +63,14 @@ public IDocumentation TryGetDocumentation(MemberId member) =>
/// <returns>Returns a new instance of <see cref="AssemblyDocumentation"/> that provides documentation for the specified assembly.</returns>
public static AssemblyDocumentation FromFile(string filePath, ILogger logger)
{
var dir = Path.GetDirectoryName(filePath);

var assemblyResolver = new DefaultAssemblyResolver();
assemblyResolver.AddSearchDirectory(dir);

// load assembly
logger.LogInformation($"Loading assembly from '{filePath}'");
var assemblyDefinition = AssemblyDefinition.ReadAssembly(filePath);
var assemblyDefinition = AssemblyDefinition.ReadAssembly(filePath, new ReaderParameters() { AssemblyResolver = assemblyResolver });

// loads XML documentation comments if the documentation file exists
IXmlDocsProvider xmlDocsProvider;
Expand Down

0 comments on commit 230f40d

Please sign in to comment.