Calling Map and AutoMap from ClassMap constructor triggers ReSharper warnings
The documentation (see these 5 examples) ...
- https://joshclose.github.io/CsvHelper/getting-started/
- https://joshclose.github.io/CsvHelper/examples/configuration/class-maps/auto-mapping/
- https://joshclose.github.io/CsvHelper/examples/configuration/class-maps/inline-type-conversion/
- https://joshclose.github.io/CsvHelper/examples/configuration/class-maps/optional-maps/
- https://joshclose.github.io/CsvHelper/examples/configuration/class-maps/validation/
... illustrates calling Map and AutoMap from the constructor of a derived class of ClassMap<T>. Doing so immediately triggers a warning from ReSharper: Virtual member call in constructor, which is explained here: https://www.jetbrains.com/help/resharper/2022.3/VirtualMemberCallInConstructor.html
This design seems inherently flawed. Is there any alternative way (perhaps from a non-constructor method) to apply mapping that won't trigger a scary warning about virtual members being called from constructors? I would prefer not to pretend this is not a problem by suppressing the warning.
Did you make your class sealed? I believe you won't get that warning if you do.
Bam, that solves it. Thank you!
P.S. Should one or more of the examples used sealed?
All ClassMap implementations should probably have it in the documentation.