Skip to content

Commit

Permalink
He said ship it, also added some comments for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
OneThatWalks committed Feb 19, 2021
1 parent e5cd12b commit 29b98a2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/FluentMigrator.DotNet.Cli/Program.cs
Expand Up @@ -51,6 +51,12 @@ public static int Main(string[] args)
}

/// <summary>
/// Temporary workaround for
/// https://github.com/fluentmigrator/fluentmigrator/issues/1406
///
/// taken mostly from
/// https://github.com/dotnet/BenchmarkDotNet/blob/852bb8cd9c2ac2530866dc53723c5f2ce3d411fa/src/BenchmarkDotNet/Helpers/DirtyAssemblyResolveHelper.cs#L18
///
/// Sometimes NuGet/VS/other tool does not generate the right assembly binding redirects
/// or just for any other magical reasons
/// our users get FileNotFoundException when trying to run their benchmarks
Expand All @@ -61,7 +67,6 @@ public static int Main(string[] args)
///
/// If one day we can remove it, the person doing that should celebrate!!
/// </summary>
// ReSharper disable once CheckNamespace I did it on purpose to show that it MUST not touch any BenchmarkDotNet stuff
internal class DirtyAssemblyResolveHelper : IDisposable
{
internal static IDisposable Create() => new DirtyAssemblyResolveHelper();
Expand All @@ -85,8 +90,11 @@ private Assembly HelpTheFrameworkToResolveTheAssembly(object sender, ResolveEven

// Create the list of assembly paths consisting of runtime assemblies
var paths = new List<string>(runtimeAssemblies);

// Since we search by simple name, there should hopefully be one file
string guessedPath = paths.FirstOrDefault();

// If there wasn't a runtime file check the app directory for the file
if (guessedPath == null)
{
guessedPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{simpleName}.dll");
Expand Down

0 comments on commit 29b98a2

Please sign in to comment.