JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.63k stars 1.05k forks source link

[Feature Request] Generalize Factory Class Method Signatures #2270

Open develop-gby opened 2 weeks ago

develop-gby commented 2 weeks ago

Is your feature request related to a problem? Please describe.

I am referring to the following file Factory.cs. I would like to understand if there is a particular reason why the concrete type CsvConfiguration is present in the signatures of the methods of this class.

Describe the solution you'd like

Couldn't the concrete type be replaced by the reference interface? For example, The following method could become

//NOW
public virtual IParser CreateParser(TextReader reader, Configuration.CsvConfiguration configuration)
{
    return new CsvParser(reader, configuration);
}
//AFTER
public virtual IParser CreateParser(TextReader reader, IParserConfiguration configuration)
{
    return new CsvParser(reader, configuration);
}

I make this request in order to improve the use of this class and enable a more effective dependency injection.

jzabroski commented 1 week ago

This makes sense, in that the context for a CsvParser is reading and not writing.