Skip to content
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

Add access to the MemberInfo via ReferenceHeaderPrefixArgs #2312

Open
Lucas-HMS opened this issue Jan 10, 2025 · 0 comments
Open

Add access to the MemberInfo via ReferenceHeaderPrefixArgs #2312

Lucas-HMS opened this issue Jan 10, 2025 · 0 comments
Labels

Comments

@Lucas-HMS
Copy link

Is your feature request related to a problem? Please describe.
We currently mostly use the auto mapping together with the NameAttribute when generating CSV files. It works very well with the customized column names, except when we have nested DTO references. In that case we currently can only access the member name and type but not the MemberInfo itself, which could be used to find more informations about the parent property.
For example, if we consider the following data classes:

public class MyRootDto
{
    [Name("Foo")]
    public MyInnerDto Nested1 { get; set; }

    [Name("Bar")]
    public MyInnerDto Nested2 { get; set; }
}

public class MyInnerDto
{
    [Name("MyCustomName")]
    public string SomeProp { get; set; }
}

By using the ReferenceHeaderPrefix setting, we currently can not detect, which property we're currently generating the prefix for. (e.g. "Foo.MyCustomName" or "Bar.MyCustomName")

Describe the solution you'd like
If the current MemberInfo instance would be added to the ReferenceHeaderPrefixArgs, we would gain more options to generate prefixes. For example, we could search the members NameAttribute or do other work with reflection code.

This would allow for a more powerful way to still mostly use automatic mapping with some minimal configuration via attributes.

Describe alternatives you've considered
Otherwise we would have to stop using the automatic mapping, which currently otherwise works great for our use case.

Additional context
As far as I can tell, do all locations which instantiate a ReferenceHeaderPrefixArgs object currenlty have access to the current MemberInfo object.

What I currently don't know is, how prefixes of references nested deeper than 1 layer currently react to this.

Thank you for your consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant