Replies: 2 comments
-
I don't think I would expect a difference based on the object type (struct, class, record), or the presence/absence of constructors and/or accessor keywords. I'm used to serialization libraries (including EF) ignoring almost everything, and just going "right: I've read a value labeled Things which are impossible (or inordinately difficult) due to language design/limitations are understandable. As long as CsvHelper calls these out (example, without knowing if this is even true: "we don't support structs with constructors, because how they work makes it really hard until .NET 7/C# 11, and CsvHelpers wants to support older versions"), I'm sure the community will come to know these limitations, and repeat them on StackOverflow, Discord, etc. |
Beta Was this translation helpful? Give feedback.
-
I think:
Suggested amendments (maybe incomplete):
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This discussion is to figure out how mapping should behave. Let's ignore how it currently behaves and talk about what is ideal.
Mapping scenarios.
class
with default constructor.class
with no default constructor.class
with both default constructor and other constructors.struct
with default constructor.struct
with no default constructor.struct
with both default constructor and other constructors.record
record struct
readonly record struct
Member mapping can be a property or field or both based on the
CsvConfiguration.MemberTypes
flag.class
with default constructorAuto Map Rules:
[Ignore]
will stop from mapping.Class Map Rules:
class
with no default constructorAuto Map Rules:
[Ignore]
will stop from mapping.Class Map Rules:
class
with both default constructor and other constructorsAuto Map Rules:
class with default constructor
apply.Class Map Rules:
class with default constructor
apply.struct
with default constructorAuto Map Rules:
class with default constructor
apply.Class Map Rules:
class with default constructor
apply.struct
with no default constructor.Auto Map Rules:
struct with default constructor
apply.Class Map Rules:
struct with default constructor
apply.struct
with both default constructor and other constructors.Auto Map Rules:
class with no default constructor
apply.Class Map Rules:
class with no default constructor
apply.record
Auto Map Rules:
class with no default constructor
apply.Class Map Rules:
class with no default constructor
apply.record struct
Auto Map Rules:
struct with no default constructor
apply.Class Map Rules:
struct with no default constructor
apply.readonly record struct
Auto Map Rules:
struct with no default constructor
apply.Class Map Rules:
struct with no default constructor
apply.Beta Was this translation helpful? Give feedback.
All reactions