Skip to content

Commit

Permalink
fixed plugins loading in certain context (fixes #145 thanks to @a10r)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doraku committed Oct 23, 2024
1 parent 1fd517a commit 22e4484
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion documentation/NEXT_RELEASENOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
- fixed unhandled xml elements not rendering as is in markdown (fixes #126)
- fixed issue with list rendering
- fixed enum fields to respect code order (fixes #131)
- fixed c and see elements with leading and trailing linebreak chars (fixes #113)
- fixed c and see elements with leading and trailing linebreak chars (fixes #113)
- fixed plugins loading in certain context (fixes #145 thanks to @a10r)
25 changes: 25 additions & 0 deletions source/DefaultDocumentation.Common/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,31 @@ private Generator(Target loggerTarget, IRawSettings settings)
GetSetting<string>(nameof(settings.LinksBaseUrl)),
GetSetting<string[]>(nameof(settings.ExternLinksFilePaths)));

AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs args) =>
{
AssemblyName assemblyName = new(args.Name);

Assembly? loadedAssembly = Array.Find(((AppDomain)sender).GetAssemblies(), assemby => assemby.GetName().Name.Equals(assemblyName.Name, StringComparison.OrdinalIgnoreCase));

if (loadedAssembly?.GetName() is AssemblyName loadedAssemblyName
&& loadedAssemblyName.Version != assemblyName.Version)
{
string message = $"using {assemblyName.Name} version {loadedAssemblyName.Version} instead of version {assemblyName.Version}, may cause issue";

if (loadedAssemblyName.Version.Major == assemblyName.Version.Major)
{
// there shouldn't be any breaking changes
_logger.Info(message);
}
else
{
_logger.Warn(message);
}
}

return loadedAssembly;
};

_context = new GeneralContext(
_configuration,
((Assembly[])[
Expand Down

0 comments on commit 22e4484

Please sign in to comment.