-
Notifications
You must be signed in to change notification settings - Fork 8
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
Create Internal Interfaces? #12
Comments
Figured it out: internals have to be visible to But the dynamic creation of implementations does not seem to apply to properties within the interface, i.e. those remain |
Sorted this one out, too: To do that, I added |
Good to see you got around this. TBH though, I'd be inclined to use POCOs instead of interfaces - the interface stuff was really a bad excuse to play with codegen. POCOs are easier to reason with and control IMHO, and easier to test without mocking config. |
I prefer the interfaces, because they work without setters on the properties. With pocos, technically anybody can modify the settings. |
I believe your Poco could be public class SomeConfig
{
public string SomeValue { get; private set }
} And obviously it's a valid defensive position to make, but conversely (it took me a number of years to reach this point), do you rate your colleagues so low that they'd be modifying a config instance after initialisation? Possible, but not probable |
It works with a private setter, just not for read-only properties. You might add the line to As for the colleagues... they'll do anything you can or cannot imaging, so I prefer to be safe than sorry :-D |
Ok.
Read-only properties don't have a setter at all, I believe (I moved over to
java a year ago, so my c# is a little rusty). I'll take a look at your
suggestion, and make changes as necessary. Otherwise, PRs with test cases
are always welcome!
…On Tue, 1 Jan 2019, 14:55 Haukinger ***@***.*** wrote:
It works with a private setter, just not for read-only properties. You
might add the line to GetMappingStrategies just for completeness' sake,
in case someone tries an interface property in an interface.
As for the colleagues... they'll do anything you can or cannot imaging, so
I prefer to be safe than sorry :-D
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANOrOIHfye4J50LLID3cdJAzj_5dplZks5u-3bOgaJpZM4WJzjn>
.
|
Hi, I no longer have access to a windows machine, and getting this stuff up and running in netstandard so I can develop and test it is not trivial (e.g. I'm not sure I have the energy to fix this on a mac |
For completeness, I took a look at this code with Mono, and I'm hesitant to add your addition. The current code is for a specific property instance that happens to have a name. Your code will find mapping strategies for any property that has the same name, but a class can have multiple properties with the same name if they're an explicit interface implementation, so the mapping strategies could end up being a superset of the legal strategies |
This works fine with internal classes, but when I try to use an internal interface as settings container, I get
Type 'SimpleConfig.Dynamic.InterfaceImplementations._MyAssembly.IServiceSettings_Impl' from assembly 'SimpleConfig.Dynamic.InterfaceImplementations, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.
I've tried to make my
InternalsVisibleTo
"SimpleConfig", but that doesn't help. Any idea?The text was updated successfully, but these errors were encountered: