Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try and fix options detecting the wrong types sometimes #2444

Merged
merged 2 commits into from
Dec 26, 2024
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
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,9 @@ dotnet_diagnostic.CA1513.severity = none
# CA1514: Avoid redundant length argument
dotnet_diagnostic.CA1514.severity = none

# CA1515: Consider making public types internal
dotnet_diagnostic.CA1515.severity = none

# CA1700: Do not name enum values 'Reserved'
dotnet_diagnostic.CA1700.severity = none
# Options: api_surface
Expand Down Expand Up @@ -3099,6 +3102,8 @@ dotnet_diagnostic.rcs9010.severity = none
# Specify ExportCodeFixProviderAttribute.Name
dotnet_diagnostic.rcs9011.severity = none

dotnet_diagnostic.RMG012.severity = error # Unmapped target member
dotnet_diagnostic.RMG020.severity = error # Unmapped source member

# Refactorings

Expand Down
10 changes: 4 additions & 6 deletions src/Foundation/Conventions/OptionsConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@ public void Register(IConventionContext context, IConfiguration configuration, I
.GetTypes(
z => z
.NotInfoOf(TypeInfoFilter.Abstract, TypeInfoFilter.Static, TypeInfoFilter.GenericType)
.WithAnyAttribute(typeof(RegisterOptionsConfigurationAttribute))
.KindOf(TypeKindFilter.Class)
.WithAttribute<RegisterOptionsConfigurationAttribute>()
)
);

foreach (var options in classes)
foreach (( var options, var attribute ) in classes.SelectMany(z => z.GetCustomAttributes<RegisterOptionsConfigurationAttribute>(), (type, attribute) => ( type, attribute )))
{
var attribute = options.GetCustomAttribute<RegisterOptionsConfigurationAttribute>()!;
#pragma warning disable IL2060
_configureMethod
_ = _configureMethod
.MakeGenericMethod(options)
.Invoke(null, [services, attribute.OptionsName, configuration.GetSection(attribute.ConfigurationKey)]);
#pragma warning restore IL2060
}
}
}
Loading