Github user jbaehr commented on the issue:

    https://github.com/apache/logging-log4net/pull/3
  
    while I like the general idea, I have concerns regarding the ctor 
resolution. The current proposal works only with ctor arguments of type 
`String` and uses their names to find the right ctor. C#, however, uses the 
arugment's type for overload resolution. In addition, how does this approach 
mix with the existing, "by property" initialization?
    I'd prefer a syntax compatible with the existing [xml 
parametritazion](http://logging.apache.org/log4net/release/manual/configuration.html#Parameters)
 and following the same rules as C# for overload resolution. What about this:
    
    currnetly
    ```
    <param name="evaluator" type="log4net.spi.LevelEvaluator">
        <param name="Threshold" value="WARN"/>
    <param>
    ```
    and
    ```
    <evaluator type="log4net.spi.LevelEvaluator">
        <threshold value="WARN"/>
    <evaluator>
    ```
    both translate to the following C# equvalent:
    ```
    evaluator = new log4net.spi.LevelEvaluator { Threshold = "WARN" };
    ```
    
    To achieve something like this
    ```
    foo = new my.Foo(arg1: 22) { Bar = "baz" };
    ```
    we could have this extension to the XML parametrization:
    ```
    <param name="foo" type="my.Foo">
        <constructor>
            <param type="System.Int32" name="arg1" value="22"/><!-- name is not 
required, but may help the human reading the xml -->
        <constructor>
        <param name="Bar " value="baz"/>
    <param>
    ```
    or, using the compact parameter syntax
    ```
    <foo type="my.Foo">
        <constructor>
            <arg1 type="System.Int32" value="22"/>
        <constructor>
        <bar>baz</bar>
    <param>
    ```
    
    This would introduce a new child element for "param", namely "constructor", 
which is not 100% backward compatible. But neither is the original proposal. 
And a workaround in the form of `<param name="Constructor", ... />` is possible.
    
    An implementation could collect and convert all params from the 
"constructor" element and feed them as array to System.Activator (there is an 
overload of `CreateInstance` taking the ctor arguments as `Object[]`). This one 
will then select the right ctor according to c#'s overload resolution rules. No 
need to iterate over the ctor meta data manually.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to