Dynamically generating C# classes for deserializing data
I'm building a little service for reading large Parquet datasets into 'row' object collections for LINQ querying. So far I have been manually creating my 'row' classes, like one dataset is for junior school maths word problems, and I deserialize the Parquet rows into a collection of
WordProblem
WordProblem
objects.
Now I want to generalise the service and have it read a
ParquetSchema
ParquetSchema
from the dataset file, generate a class on the fly and deserialize into that. Second best, or maybe a better design, would be to statically generate class files. I'm using C#12 and .NET 8 with ParquetDotNet.
Claude has suggested some CLI tools and packages for static generation, and these libs I have no idea about, hence this question.
- Language Ext- This library allows defining data types based on a schema at runtime without pre-generated classes using LINQ projections. - Siros- Provides dynamic and typed projection of data sources like Parquet into .NET objects. - Misc.Extensions- A lightweight library with dynamic schema projection capabilities.
Then there are Roslyn code generators, which I should have learnt about yonks ago but haven't. Which is the current best practice way of doing this?