-
Notifications
You must be signed in to change notification settings - Fork 131
ConfigurationMethod selector dependent on definition order #131
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
Comments
While you raise a valid point, I'm not sure PR #132 focus on This line attempts to convert the config value to the parameter type: And this is the conversion function used for string config values (the other being objects, which are generally config subsections): |
I'd considered that approach as well but after thinking about it I reckoned that if a user has a method that accepts string overloads they would have parsing logic in that method either way. As such the reliance on Thoughts? |
Yes but I may be overthinking it, though. I have not had much success imagining other scalar overload scenarios that seem realistic. Where did you encounter this problem? Was it essentially what you represented in the example? |
Yes indeed, that was my thought process as well. It was encountered while I was patching a bug in the Udp sink package and the maintainer expressed that it was an easy to miss error which they frequently encountered themselves. Basically, in true configuration-by-code manner, the first and original method accepted While one can argue that they could've used separate names for IP address and hostname parameters, that however would've been a workaround if the key is simply stated as |
I suppose the general argument is that if a matching There is a conflict with #128 but I'll merge your PR once that is resolved. |
fixes #131 by preferring string overloaded methods
Uh oh!
There was an error while loading. Please reload this page.
Issue
As of now ConfigurationMethod selector is vaguely dependent on definition order of the configuration methods. Consider the following configuration class:
MyLoggerConfiguration.cs
appsettings.json
Current Behavior
Currently the code will try to get one of the 3
DemoLoggerConfiguration
methods. As of now it will select the twoDemoLoggerConfiguration
instances with the matching parameter namepathFormat
- however it will use the.First()
or the top one and try to invoke it and causing anTypeCastException
toIEnumerable<string>
fromstring
. The problem being that it ignored the other method which was a valid candidate.Temporary Workaround
As of now we can reorder the methods so the method with
string pathFormat
appears before the other method that has it asIEnumerable<string>
but it is easy to miss and not a very elegant approach since the order shouldn't matter.Expected Behavior
The configuration selector should've picked and invoked the 2nd
DemoLoggerConfiguration
which defined the parameter as astring
since it is the most straightforward choice, irrespective of the position where it's defined.PR
#132
The text was updated successfully, but these errors were encountered: