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.
classwith default constructor.classwith no default constructor.classwith both default constructor and other constructors.structwith default constructor.structwith no default constructor.structwith both default constructor and other constructors.recordrecord structreadonly record structMember mapping can be a property or field or both based on the
CsvConfiguration.MemberTypesflag.classwith default constructorAuto Map Rules:
[Ignore]will stop from mapping.Class Map Rules:
classwith no default constructorAuto Map Rules:
[Ignore]will stop from mapping.Class Map Rules:
classwith both default constructor and other constructorsAuto Map Rules:
class with default constructorapply.Class Map Rules:
class with default constructorapply.structwith default constructorAuto Map Rules:
class with default constructorapply.Class Map Rules:
class with default constructorapply.structwith no default constructor.Auto Map Rules:
struct with default constructorapply.Class Map Rules:
struct with default constructorapply.structwith both default constructor and other constructors.Auto Map Rules:
class with no default constructorapply.Class Map Rules:
class with no default constructorapply.recordAuto Map Rules:
class with no default constructorapply.Class Map Rules:
class with no default constructorapply.record structAuto Map Rules:
struct with no default constructorapply.Class Map Rules:
struct with no default constructorapply.readonly record structAuto Map Rules:
struct with no default constructorapply.Class Map Rules:
struct with no default constructorapply.Beta Was this translation helpful? Give feedback.
All reactions