-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Support binding to immutable types #43662 #67161
Support binding to immutable types #43662 #67161
Conversation
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsFixes #43662
|
src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/ConfigurationBinderTests.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Outdated
Show resolved
Hide resolved
@@ -112,6 +112,75 @@ public class DerivedOptionsWithIConfigurationSection : DerivedOptions | |||
public IConfigurationSection DerivedSection { get; set; } | |||
} | |||
|
|||
#if NETCOREAPP |
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 only on NETCOREAPP?
@@ -112,6 +112,75 @@ public class DerivedOptionsWithIConfigurationSection : DerivedOptions | |||
public IConfigurationSection DerivedSection { get; set; } | |||
} | |||
|
|||
#if NETCOREAPP | |||
public record RecordTypeOptions(string Color, int Length); |
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.
How about tests for readonly struct
and record struct
?
@@ -698,6 +746,37 @@ private static Array BindArray(Array source, IConfiguration config, BinderOption | |||
options); | |||
} | |||
|
|||
// todo: steve - we might not need this; currently, these attributes are only applicable to properties and |
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.
What's the plan for addressing this?
I agree that this code doesn't make sense because these attributes can't be on parameters:
Lines 8 to 9 in bd43f55
[AttributeUsage(AttributeTargets.Property)] | |
public sealed class ConfigurationKeyNameAttribute : Attribute |
…y invoke `ConstructorInfo`
4bf28bc
to
15bf080
Compare
15bf080
to
9d70502
Compare
9d70502
to
9bf910f
Compare
9bf910f
to
e32f3b6
Compare
I had some git issues and somehow this PR was closed. Is there a way to reopen it? (cc @maryamariyan ) |
Apologies @davidfowl @eerhardt - It's been one of those evenings and I completely screwed up my git repo and this PR and somehow accidentally closed this PR. I created a new PR at #67258 |
Fixes #43662
Update
I completely screwed up my git repo and this PR, so it was easier and cleaner to create a new branch and a new PR. This is at #67258.