-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Implement proper parsing of primitives in config binder generator #83533
Comments
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue Detailsfrom @eerhardt in #82179 (comment) (fyi @stephentoub)
|
If we decide to directly use converters we should measure the size impact -- maybe directly referencing a converter is less expensive then GetCoverter (which I think @eerhardt said is huge), but it still looks pretty big. Maybe we can just look to the converters for inspiration of which parse/tryparse signatures to call, then generate those? |
I think the idea is not using the converters at all and just having the parse code embedded inside the generated code. no dependency and not calling type converter. |
For built-in types like See also #44493 (comment) about TypeConverter extensibility being opt-in. The one use of config binding in Console Logging shouldn't pull in TypeConverter at all. See #81931 for why and numbers. |
Yeah this is what I meant. |
One option for the "opt in" model of
So, for example: [TypeConverter(typeof(PointConverter))]
public struct Point
{
public int X;
public int Y;
}
public class CustomOptions
{
public Point CurrentPoint { get; set }
} or public struct Point
{
public int X;
public int Y;
}
public class CustomOptions
{
[TypeConverter(typeof(PointConverter))]
public Point CurrentPoint { get; set }
} See also: |
@tarekgh @eerhardt I'm using the list of "intrinsic" types specified in the core Lines 162 to 198 in 967250c
Are there any other strategies for picking these types that come to mind? |
I think the collected list of primitives is good enough and we can watch if we get more cases we need to support. |
Looking at: runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs Lines 838 to 873 in bd6ed47
I think starting with those built-in Types makes a lot of sense, as those will be the types that can be converted out of the box with
|
Yup we already have tests for these two; will just doublecheck that the implementation lines up with reflection in all cases. |
from @eerhardt in #82179 (comment) (fyi @stephentoub)
The text was updated successfully, but these errors were encountered: