Skip to content
Merged
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 @@ -34,14 +34,22 @@ public sealed class ConfigurationFeatureDefinitionProvider : IFeatureDefinitionP

const string ParseValueErrorString = "Invalid setting '{0}' with value '{1}' for feature '{2}'.";

/// <summary>
/// Creates a configuration feature definition provider.
/// </summary>
/// <param name="configuration">The configuration of feature definitions.</param>
public ConfigurationFeatureDefinitionProvider(IConfiguration configuration) : this(configuration, null)
{
}

/// <summary>
/// Creates a configuration feature definition provider.
/// </summary>
/// <param name="configuration">The configuration of feature definitions.</param>
/// <param name="options">The options for the configuration feature definition provider.</param>
public ConfigurationFeatureDefinitionProvider(
IConfiguration configuration,
ConfigurationFeatureDefinitionProviderOptions options = null)
ConfigurationFeatureDefinitionProviderOptions options)
Copy link
Member

@zhiyuanliang-ms zhiyuanliang-ms Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a test to verify that DI will pick the ctor with most parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's necessary, for two reasons:

  1. The library doesn't rely on DI (ref) to construct ConfigurationFeatureDefinitionProviderOptions - it always new's it up inline
  2. The MS DI Constructor selection rules are quite clear: the constructor with the most arguments is used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referencing implementation shouldn't be used to justify tests. Otherwise, we wouldn't need tests, we could just say look at the code, it works.

The thing that needs coverage is if ConfigurationFeatureDefinitionProviderOptions are registered, then they are respected.

@zhiyuanliang-ms , I believe that's covered here, can you confirm?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed

{
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
_options = options ?? new ConfigurationFeatureDefinitionProviderOptions();
Expand Down
Loading