Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;

Expand All @@ -13,16 +14,19 @@ internal static class ProviderAliasUtilities

internal static string GetAlias(Type providerType)
{
foreach (CustomAttributeData attributeData in CustomAttributeData.GetCustomAttributes(providerType))
IList<CustomAttributeData> attributes = CustomAttributeData.GetCustomAttributes(providerType);

for (int i = 0; i < attributes.Count; i++)
{
if (attributeData.AttributeType.FullName == AliasAttibuteTypeFullName)
CustomAttributeData attributeData = attributes[i];
if (attributeData.AttributeType.FullName == AliasAttibuteTypeFullName &&
attributeData.ConstructorArguments.Count > 0)
{
foreach (CustomAttributeTypedArgument arg in attributeData.ConstructorArguments)
{
Debug.Assert(arg.ArgumentType == typeof(string));
CustomAttributeTypedArgument arg = attributeData.ConstructorArguments[0];

Debug.Assert(arg.ArgumentType == typeof(string));

return arg.Value?.ToString();
}
return arg.Value?.ToString();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public LoggerFilterOptions() { }
/// <summary>
/// Gets the collection of <see cref="LoggerFilterRule"/> used for filtering log messages.
/// </summary>
public IList<LoggerFilterRule> Rules { get; } = new List<LoggerFilterRule>();
public IList<LoggerFilterRule> Rules => RulesInternal;

// Concrete representation of the rule list
internal List<LoggerFilterRule> RulesInternal { get; } = new List<LoggerFilterRule>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static void Select(LoggerFilterOptions options, Type providerType, string

string providerAlias = ProviderAliasUtilities.GetAlias(providerType);
LoggerFilterRule current = null;
foreach (LoggerFilterRule rule in options.Rules)
foreach (LoggerFilterRule rule in options.RulesInternal)
{
if (IsBetter(rule, current, providerType.FullName, category)
|| (!string.IsNullOrEmpty(providerAlias) && IsBetter(rule, current, providerAlias, category)))
Expand Down