-
Notifications
You must be signed in to change notification settings - Fork 119
Add missing feature switch #78
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
Add missing feature switch #78
Conversation
|
@zhenlan thoughts on changing the default behavior to throw on a missing feature? I would prefer that we do it that way. It is a breaking behavioral change, but not a breaking API change. Therefore it wouldn't require a major version bump. |
|
Discussed with @zhenlan, let's go ahead and make the default behavior to not throw for a missing feature. There is a scenario for this where a developer codes ahead of someone who is setting up configuration. |
|
@jimmyca15 Thanks for the clarification, I'll update the PR. |
d2aca88 to
822825f
Compare
|
@jimmyca15 Updated following your comments and now ready for review. |
| /// Controls the behavior of feature evaluation when the specified feature does not exist. | ||
| /// If missing features are not ignored, an exception will be thrown when attempting to evaluate them. | ||
| /// </summary> | ||
| public bool IgnoreMissingFeatures { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want this defaults to true.
| services | ||
| .Configure<FeatureManagementOptions>(options => | ||
| { | ||
| options.IgnoreMissingFeatures = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this so we can test the default behavior and ensure no regressions.
| services | ||
| .Configure<FeatureManagementOptions>(options => | ||
| { | ||
| options.IgnoreMissingFeatures = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change needed?
| using System.Linq; | ||
| using System.Net; | ||
| using System.Net.Http; | ||
| using System.Reflection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I may miss it as it's not very easy to tell. What we are using in the reflection namespace?
| else if (!_options.IgnoreMissingFeatures) | ||
| { | ||
| throw new FeatureManagementException(FeatureManagementError.MissingFeature, $"The feature declaration for specified feature '{feature}' was not found."); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should log a warning even if IgnoreMissingFeatures is true. Suggest change below
else
{
string errorMessage = $"The feature declaration for specified feature '{feature}' was not found.";
if (!_options.IgnoreMissingFeatures)
{
throw new FeatureManagementException(FeatureManagementError.MissingFeature, errorMessage);
}
else
{
_logger.LogWarning(errorMessage);
}
}
No description provided.