Skip to content

Commit 00178a1

Browse files
committed
Add comments explaining behavior of DependencyContext.Default
and protect against null
1 parent 912e1b8 commit 00178a1

File tree

1 file changed

+3
-1
lines changed
  • src/Serilog.Settings.Configuration/Settings/Configuration/Assemblies

1 file changed

+3
-1
lines changed

src/Serilog.Settings.Configuration/Settings/Configuration/Assemblies/AssemblyFinder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ protected static bool IsCaseInsensitiveMatch(string text, string textToFind)
1616

1717
public static AssemblyFinder Auto()
1818
{
19-
if (Assembly.GetEntryAssembly() != null)
19+
// Need to check `Assembly.GetEntryAssembly()` first because
20+
// `DependencyContext.Default` throws an exception when `Assembly.GetEntryAssembly()` returns null
21+
if (Assembly.GetEntryAssembly() != null && DependencyContext.Default != null)
2022
{
2123
return new DependencyContextAssemblyFinder(DependencyContext.Default);
2224
}

0 commit comments

Comments
 (0)