Subject: Re: C# POCO serializer/deserializer


Hi Brian,

Thanks for the reply (and for shepherding the project).

Regarding Json. I’ll take a look at the Java code. I’ve also used Newtonsoft for things like this previously. JsonTextReader/JsonTextWriter look like they would map easily to the Avro Encode/Decoder interfaces. The banner on the Json.NET <http://json.net/> documentation says "JsonTextWriter Class Represents a writer that provides a fast, non-cached, forward-only way of generating JSON data.”, which seems like what we need. https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonTextWriter.htm <https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonTextWriter.htm>

Regarding Newtonsoft version. Maybe 10.0.3? It is 2 years old and 2 major versions back. It is also by far the most popular download on nuget. For what I’m trying to do (better error reporting while parsing) I just need the JToken to to have the Path property.

Regarding Roslyn. This is a detailed intro/tutorial https://medium.com/@CPP_Coder/introduction-to-roslyn-and-its-use-in-program-development-bce2043fc45d <https://medium.com/@CPP_Coder/introduction-to-roslyn-and-its-use-in-program-development-bce2043fc45d>. It is the compiler framework that’s being used for code analysis tools, cross compilers etc. For code->schema I’m thinking to do the following:
- open the solution
- use the syntax walker https://joshvarty.com/2014/07/26/learn-roslyn-now-part-4-csharpsyntaxwalker/ <https://joshvarty.com/2014/07/26/learn-roslyn-now-part-4-csharpsyntaxwalker/> to parse the required class, then generate a schema (or possibly a protocol for an entire namespace).

I haven’t thought a lot about the code generation side. But what I’m hoping is that we can parse the C#, as with schema generation, and then generate updates to the code by modifying the syntax tree. This will have the effect of editing the C# and preserving any edits, unmapped properties, and comments the developer has made. https://msdn.microsoft.com/en-us/magazine/mt808499.aspx <https://msdn.microsoft.com/en-us/magazine/mt808499.aspx>. As I’m typing this I think the reverse for the schema would be good too - load C# and schema and then edit the schema tree to sync any changes rather than just regenerating it every time.