Skip to content

Commit 9e98413

Browse files
committed
enable ExtensionAttribute polyfills
1 parent b46a5f9 commit 9e98413

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,16 @@ static IList<MethodInfo> FindEventEnricherConfigurationMethods(IReadOnlyCollecti
511511

512512
static List<MethodInfo> FindConfigurationExtensionMethods(IReadOnlyCollection<Assembly> configurationAssemblies, Type configType)
513513
{
514+
// ExtensionAttribute can be polyfilled to support extension methods
515+
bool hasExtensionAttribute(MethodInfo m) =>
516+
m.CustomAttributes.Any(a => a.AttributeType.FullName == "System.Runtime.CompilerServices.ExtensionAttribute");
517+
514518
return configurationAssemblies
515519
.SelectMany(a => a.ExportedTypes
516520
.Select(t => t.GetTypeInfo())
517521
.Where(t => t.IsSealed && t.IsAbstract && !t.IsNested))
518522
.SelectMany(t => t.DeclaredMethods)
519-
.Where(m => m.IsStatic && m.IsPublic && m.IsDefined(typeof(ExtensionAttribute), false))
523+
.Where(m => m.IsStatic && m.IsPublic && hasExtensionAttribute(m))
520524
.Where(m => m.GetParameters()[0].ParameterType == configType)
521525
.ToList();
522526
}

0 commit comments

Comments
 (0)