avrotize 2.18.2__py3-none-any.whl → 2.20.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. avrotize/_version.py +2 -2
  2. avrotize/avrotocsharp/project.csproj.jinja +7 -7
  3. avrotize/avrotocsharp/testproject.csproj.jinja +3 -3
  4. avrotize/avrotocsharp.py +21 -2
  5. avrotize/avrotojava/testproject.pom.jinja +4 -3
  6. avrotize/avrotojava.py +16 -6
  7. avrotize/avrotots/class_core.ts.jinja +12 -0
  8. avrotize/avrotots/class_test.ts.jinja +77 -0
  9. avrotize/avrotots.py +96 -0
  10. avrotize/cddltostructure.py +1841 -0
  11. avrotize/commands.json +226 -0
  12. avrotize/constants.py +71 -4
  13. avrotize/dependencies/cpp/vcpkg/vcpkg.json +19 -0
  14. avrotize/dependencies/cs/net90/dependencies.csproj +27 -0
  15. avrotize/dependencies/go/go121/go.mod +6 -0
  16. avrotize/dependencies/java/jdk21/pom.xml +91 -0
  17. avrotize/dependencies/python/py312/requirements.txt +13 -0
  18. avrotize/dependencies/rust/stable/Cargo.toml +17 -0
  19. avrotize/dependencies/typescript/node22/package.json +16 -0
  20. avrotize/dependency_version.py +432 -0
  21. avrotize/structuretocddl.py +597 -0
  22. avrotize/structuretocsharp/dataclass_core.jinja +6 -1
  23. avrotize/structuretocsharp/json_structure_converters.cs.jinja +399 -0
  24. avrotize/structuretocsharp/program.cs.jinja +11 -6
  25. avrotize/structuretocsharp/project.csproj.jinja +4 -3
  26. avrotize/structuretocsharp/testproject.csproj.jinja +4 -3
  27. avrotize/structuretocsharp.py +311 -21
  28. avrotize/structuretojava/choice_core.jinja +34 -0
  29. avrotize/structuretojava/class_core.jinja +23 -0
  30. avrotize/structuretojava/enum_core.jinja +18 -0
  31. avrotize/structuretojava/equals_hashcode.jinja +30 -0
  32. avrotize/structuretojava/pom.xml.jinja +26 -0
  33. avrotize/structuretojava/tuple_core.jinja +49 -0
  34. avrotize/structuretojava.py +853 -0
  35. {avrotize-2.18.2.dist-info → avrotize-2.20.0.dist-info}/METADATA +29 -2
  36. {avrotize-2.18.2.dist-info → avrotize-2.20.0.dist-info}/RECORD +39 -20
  37. {avrotize-2.18.2.dist-info → avrotize-2.20.0.dist-info}/WHEEL +0 -0
  38. {avrotize-2.18.2.dist-info → avrotize-2.20.0.dist-info}/entry_points.txt +0 -0
  39. {avrotize-2.18.2.dist-info → avrotize-2.20.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,399 @@
1
+ using System;
2
+ using System.Globalization;
3
+ using System.Text.Json;
4
+ using System.Text.Json.Serialization;
5
+ using System.Xml;
6
+
7
+ {% if namespace %}
8
+ namespace {{ namespace }}
9
+ {
10
+ {% endif %}
11
+ {% set ind=4 if namespace else 0 %}
12
+ {% filter indent(width=ind, first=True) %}
13
+ /// <summary>
14
+ /// JSON converters for JSON Structure types that require string serialization.
15
+ /// Per JSON Structure Core spec, int64, uint64, int128, uint128, and decimal
16
+ /// types use string representation in JSON to preserve precision.
17
+ /// </summary>
18
+ public static class JsonStructureConverters
19
+ {
20
+ /// <summary>
21
+ /// Gets default JsonSerializerOptions configured with JSON Structure converters
22
+ /// </summary>
23
+ public static JsonSerializerOptions GetOptions()
24
+ {
25
+ var options = new JsonSerializerOptions();
26
+ options.Converters.Add(new Int64StringConverter());
27
+ options.Converters.Add(new NullableInt64StringConverter());
28
+ options.Converters.Add(new UInt64StringConverter());
29
+ options.Converters.Add(new NullableUInt64StringConverter());
30
+ options.Converters.Add(new Int128StringConverter());
31
+ options.Converters.Add(new NullableInt128StringConverter());
32
+ options.Converters.Add(new UInt128StringConverter());
33
+ options.Converters.Add(new NullableUInt128StringConverter());
34
+ options.Converters.Add(new DecimalStringConverter());
35
+ options.Converters.Add(new NullableDecimalStringConverter());
36
+ options.Converters.Add(new TimeSpanIso8601Converter());
37
+ options.Converters.Add(new NullableTimeSpanIso8601Converter());
38
+ return options;
39
+ }
40
+ }
41
+
42
+ /// <summary>
43
+ /// Converts Int64 (long) to/from JSON string for precision preservation
44
+ /// </summary>
45
+ public class Int64StringConverter : JsonConverter<long>
46
+ {
47
+ /// <inheritdoc/>
48
+ public override long Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
49
+ {
50
+ if (reader.TokenType == JsonTokenType.String)
51
+ {
52
+ return long.Parse(reader.GetString()!, CultureInfo.InvariantCulture);
53
+ }
54
+ return reader.GetInt64();
55
+ }
56
+
57
+ /// <inheritdoc/>
58
+ public override void Write(Utf8JsonWriter writer, long value, JsonSerializerOptions options)
59
+ {
60
+ writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
61
+ }
62
+ }
63
+
64
+ /// <summary>
65
+ /// Converts nullable Int64 (long?) to/from JSON string for precision preservation
66
+ /// </summary>
67
+ public class NullableInt64StringConverter : JsonConverter<long?>
68
+ {
69
+ /// <inheritdoc/>
70
+ public override long? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
71
+ {
72
+ if (reader.TokenType == JsonTokenType.Null)
73
+ {
74
+ return null;
75
+ }
76
+ if (reader.TokenType == JsonTokenType.String)
77
+ {
78
+ var str = reader.GetString();
79
+ if (string.IsNullOrEmpty(str)) return null;
80
+ return long.Parse(str, CultureInfo.InvariantCulture);
81
+ }
82
+ return reader.GetInt64();
83
+ }
84
+
85
+ /// <inheritdoc/>
86
+ public override void Write(Utf8JsonWriter writer, long? value, JsonSerializerOptions options)
87
+ {
88
+ if (value.HasValue)
89
+ {
90
+ writer.WriteStringValue(value.Value.ToString(CultureInfo.InvariantCulture));
91
+ }
92
+ else
93
+ {
94
+ writer.WriteNullValue();
95
+ }
96
+ }
97
+ }
98
+
99
+ /// <summary>
100
+ /// Converts UInt64 (ulong) to/from JSON string for precision preservation
101
+ /// </summary>
102
+ public class UInt64StringConverter : JsonConverter<ulong>
103
+ {
104
+ /// <inheritdoc/>
105
+ public override ulong Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
106
+ {
107
+ if (reader.TokenType == JsonTokenType.String)
108
+ {
109
+ return ulong.Parse(reader.GetString()!, CultureInfo.InvariantCulture);
110
+ }
111
+ return reader.GetUInt64();
112
+ }
113
+
114
+ /// <inheritdoc/>
115
+ public override void Write(Utf8JsonWriter writer, ulong value, JsonSerializerOptions options)
116
+ {
117
+ writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
118
+ }
119
+ }
120
+
121
+ /// <summary>
122
+ /// Converts nullable UInt64 (ulong?) to/from JSON string for precision preservation
123
+ /// </summary>
124
+ public class NullableUInt64StringConverter : JsonConverter<ulong?>
125
+ {
126
+ /// <inheritdoc/>
127
+ public override ulong? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
128
+ {
129
+ if (reader.TokenType == JsonTokenType.Null)
130
+ {
131
+ return null;
132
+ }
133
+ if (reader.TokenType == JsonTokenType.String)
134
+ {
135
+ var str = reader.GetString();
136
+ if (string.IsNullOrEmpty(str)) return null;
137
+ return ulong.Parse(str, CultureInfo.InvariantCulture);
138
+ }
139
+ return reader.GetUInt64();
140
+ }
141
+
142
+ /// <inheritdoc/>
143
+ public override void Write(Utf8JsonWriter writer, ulong? value, JsonSerializerOptions options)
144
+ {
145
+ if (value.HasValue)
146
+ {
147
+ writer.WriteStringValue(value.Value.ToString(CultureInfo.InvariantCulture));
148
+ }
149
+ else
150
+ {
151
+ writer.WriteNullValue();
152
+ }
153
+ }
154
+ }
155
+
156
+ /// <summary>
157
+ /// Converts Int128 to/from JSON string for precision preservation
158
+ /// </summary>
159
+ public class Int128StringConverter : JsonConverter<Int128>
160
+ {
161
+ /// <inheritdoc/>
162
+ public override Int128 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
163
+ {
164
+ if (reader.TokenType == JsonTokenType.String)
165
+ {
166
+ return Int128.Parse(reader.GetString()!, CultureInfo.InvariantCulture);
167
+ }
168
+ // Fallback: try to read as number
169
+ return Int128.Parse(reader.GetInt64().ToString(), CultureInfo.InvariantCulture);
170
+ }
171
+
172
+ /// <inheritdoc/>
173
+ public override void Write(Utf8JsonWriter writer, Int128 value, JsonSerializerOptions options)
174
+ {
175
+ writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
176
+ }
177
+ }
178
+
179
+ /// <summary>
180
+ /// Converts nullable Int128 to/from JSON string for precision preservation
181
+ /// </summary>
182
+ public class NullableInt128StringConverter : JsonConverter<Int128?>
183
+ {
184
+ /// <inheritdoc/>
185
+ public override Int128? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
186
+ {
187
+ if (reader.TokenType == JsonTokenType.Null)
188
+ {
189
+ return null;
190
+ }
191
+ if (reader.TokenType == JsonTokenType.String)
192
+ {
193
+ var str = reader.GetString();
194
+ if (string.IsNullOrEmpty(str)) return null;
195
+ return Int128.Parse(str, CultureInfo.InvariantCulture);
196
+ }
197
+ return Int128.Parse(reader.GetInt64().ToString(), CultureInfo.InvariantCulture);
198
+ }
199
+
200
+ /// <inheritdoc/>
201
+ public override void Write(Utf8JsonWriter writer, Int128? value, JsonSerializerOptions options)
202
+ {
203
+ if (value.HasValue)
204
+ {
205
+ writer.WriteStringValue(value.Value.ToString(CultureInfo.InvariantCulture));
206
+ }
207
+ else
208
+ {
209
+ writer.WriteNullValue();
210
+ }
211
+ }
212
+ }
213
+
214
+ /// <summary>
215
+ /// Converts UInt128 to/from JSON string for precision preservation
216
+ /// </summary>
217
+ public class UInt128StringConverter : JsonConverter<UInt128>
218
+ {
219
+ /// <inheritdoc/>
220
+ public override UInt128 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
221
+ {
222
+ if (reader.TokenType == JsonTokenType.String)
223
+ {
224
+ return UInt128.Parse(reader.GetString()!, CultureInfo.InvariantCulture);
225
+ }
226
+ return UInt128.Parse(reader.GetUInt64().ToString(), CultureInfo.InvariantCulture);
227
+ }
228
+
229
+ /// <inheritdoc/>
230
+ public override void Write(Utf8JsonWriter writer, UInt128 value, JsonSerializerOptions options)
231
+ {
232
+ writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
233
+ }
234
+ }
235
+
236
+ /// <summary>
237
+ /// Converts nullable UInt128 to/from JSON string for precision preservation
238
+ /// </summary>
239
+ public class NullableUInt128StringConverter : JsonConverter<UInt128?>
240
+ {
241
+ /// <inheritdoc/>
242
+ public override UInt128? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
243
+ {
244
+ if (reader.TokenType == JsonTokenType.Null)
245
+ {
246
+ return null;
247
+ }
248
+ if (reader.TokenType == JsonTokenType.String)
249
+ {
250
+ var str = reader.GetString();
251
+ if (string.IsNullOrEmpty(str)) return null;
252
+ return UInt128.Parse(str, CultureInfo.InvariantCulture);
253
+ }
254
+ return UInt128.Parse(reader.GetUInt64().ToString(), CultureInfo.InvariantCulture);
255
+ }
256
+
257
+ /// <inheritdoc/>
258
+ public override void Write(Utf8JsonWriter writer, UInt128? value, JsonSerializerOptions options)
259
+ {
260
+ if (value.HasValue)
261
+ {
262
+ writer.WriteStringValue(value.Value.ToString(CultureInfo.InvariantCulture));
263
+ }
264
+ else
265
+ {
266
+ writer.WriteNullValue();
267
+ }
268
+ }
269
+ }
270
+
271
+ /// <summary>
272
+ /// Converts decimal to/from JSON string for precision preservation
273
+ /// </summary>
274
+ public class DecimalStringConverter : JsonConverter<decimal>
275
+ {
276
+ /// <inheritdoc/>
277
+ public override decimal Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
278
+ {
279
+ if (reader.TokenType == JsonTokenType.String)
280
+ {
281
+ return decimal.Parse(reader.GetString()!, CultureInfo.InvariantCulture);
282
+ }
283
+ return reader.GetDecimal();
284
+ }
285
+
286
+ /// <inheritdoc/>
287
+ public override void Write(Utf8JsonWriter writer, decimal value, JsonSerializerOptions options)
288
+ {
289
+ writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
290
+ }
291
+ }
292
+
293
+ /// <summary>
294
+ /// Converts nullable decimal to/from JSON string for precision preservation
295
+ /// </summary>
296
+ public class NullableDecimalStringConverter : JsonConverter<decimal?>
297
+ {
298
+ /// <inheritdoc/>
299
+ public override decimal? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
300
+ {
301
+ if (reader.TokenType == JsonTokenType.Null)
302
+ {
303
+ return null;
304
+ }
305
+ if (reader.TokenType == JsonTokenType.String)
306
+ {
307
+ var str = reader.GetString();
308
+ if (string.IsNullOrEmpty(str)) return null;
309
+ return decimal.Parse(str, CultureInfo.InvariantCulture);
310
+ }
311
+ return reader.GetDecimal();
312
+ }
313
+
314
+ /// <inheritdoc/>
315
+ public override void Write(Utf8JsonWriter writer, decimal? value, JsonSerializerOptions options)
316
+ {
317
+ if (value.HasValue)
318
+ {
319
+ writer.WriteStringValue(value.Value.ToString(CultureInfo.InvariantCulture));
320
+ }
321
+ else
322
+ {
323
+ writer.WriteNullValue();
324
+ }
325
+ }
326
+ }
327
+
328
+ /// <summary>
329
+ /// Converts TimeSpan to/from ISO 8601 duration format (e.g., "PT1H30M")
330
+ /// </summary>
331
+ public class TimeSpanIso8601Converter : JsonConverter<TimeSpan>
332
+ {
333
+ /// <inheritdoc/>
334
+ public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
335
+ {
336
+ var str = reader.GetString();
337
+ if (string.IsNullOrEmpty(str))
338
+ {
339
+ return TimeSpan.Zero;
340
+ }
341
+ // Try ISO 8601 duration format first
342
+ if (str.StartsWith("P", StringComparison.OrdinalIgnoreCase))
343
+ {
344
+ return XmlConvert.ToTimeSpan(str);
345
+ }
346
+ // Fall back to standard TimeSpan parsing
347
+ return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
348
+ }
349
+
350
+ /// <inheritdoc/>
351
+ public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options)
352
+ {
353
+ writer.WriteStringValue(XmlConvert.ToString(value));
354
+ }
355
+ }
356
+
357
+ /// <summary>
358
+ /// Converts nullable TimeSpan to/from ISO 8601 duration format (e.g., "PT1H30M")
359
+ /// </summary>
360
+ public class NullableTimeSpanIso8601Converter : JsonConverter<TimeSpan?>
361
+ {
362
+ /// <inheritdoc/>
363
+ public override TimeSpan? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
364
+ {
365
+ if (reader.TokenType == JsonTokenType.Null)
366
+ {
367
+ return null;
368
+ }
369
+ var str = reader.GetString();
370
+ if (string.IsNullOrEmpty(str))
371
+ {
372
+ return null;
373
+ }
374
+ // Try ISO 8601 duration format first
375
+ if (str.StartsWith("P", StringComparison.OrdinalIgnoreCase))
376
+ {
377
+ return XmlConvert.ToTimeSpan(str);
378
+ }
379
+ // Fall back to standard TimeSpan parsing
380
+ return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
381
+ }
382
+
383
+ /// <inheritdoc/>
384
+ public override void Write(Utf8JsonWriter writer, TimeSpan? value, JsonSerializerOptions options)
385
+ {
386
+ if (value.HasValue)
387
+ {
388
+ writer.WriteStringValue(XmlConvert.ToString(value.Value));
389
+ }
390
+ else
391
+ {
392
+ writer.WriteNullValue();
393
+ }
394
+ }
395
+ }
396
+ {% endfilter %}
397
+ {% if namespace %}
398
+ }
399
+ {% endif %}
@@ -5,7 +5,8 @@ using System.Text.Json;
5
5
 
6
6
  /// <summary>
7
7
  /// Program that creates instances using test classes and serializes them to JSON
8
- /// for validation against JSON Structure schemas
8
+ /// for validation against JSON Structure schemas.
9
+ /// Uses the ToByteArray method when available to ensure the class's serialization path is tested.
9
10
  /// </summary>
10
11
  public class InstanceSerializerProgram
11
12
  {
@@ -14,11 +15,6 @@ public class InstanceSerializerProgram
14
15
  string outputDir = args.Length > 0 ? args[0] : ".";
15
16
  Directory.CreateDirectory(outputDir);
16
17
 
17
- var jsonOptions = new JsonSerializerOptions
18
- {
19
- WriteIndented = true
20
- };
21
-
22
18
  Console.WriteLine($"Generating JSON instance files in: {outputDir}");
23
19
 
24
20
  {%- for class_info in classes %}
@@ -27,9 +23,18 @@ public class InstanceSerializerProgram
27
23
  {
28
24
  var test_{{ class_info.class_name }} = new {{ class_info.full_qualified_test_name }}();
29
25
  var instance_{{ class_info.class_name }} = test_{{ class_info.class_name }}.CreateInstance();
26
+ {%- if has_to_byte_array %}
27
+ // Use ToByteArray to serialize via the class's serialization method
28
+ var bytes_{{ class_info.class_name }} = instance_{{ class_info.class_name }}.ToByteArray("application/json");
29
+ var filePath_{{ class_info.class_name }} = Path.Combine(outputDir, "{{ class_info.class_name }}.json");
30
+ File.WriteAllBytes(filePath_{{ class_info.class_name }}, bytes_{{ class_info.class_name }});
31
+ {%- else %}
32
+ // Fallback: use JsonSerializer directly when ToByteArray is not available
33
+ var jsonOptions = new JsonSerializerOptions { WriteIndented = true };
30
34
  var json_{{ class_info.class_name }} = JsonSerializer.Serialize(instance_{{ class_info.class_name }}, jsonOptions);
31
35
  var filePath_{{ class_info.class_name }} = Path.Combine(outputDir, "{{ class_info.class_name }}.json");
32
36
  File.WriteAllText(filePath_{{ class_info.class_name }}, json_{{ class_info.class_name }});
37
+ {%- endif %}
33
38
  Console.WriteLine($"Created: {filePath_{{ class_info.class_name }}}");
34
39
  }
35
40
  catch (Exception ex)
@@ -6,11 +6,12 @@
6
6
  </PropertyGroup>
7
7
  <ItemGroup>
8
8
  {%- if newtonsoft_json_annotation %}
9
- <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
9
+ <PackageReference Include="Newtonsoft.Json" Version="{{ NEWTONSOFT_JSON_VERSION }}" />
10
10
  {%- endif %}
11
11
  {%- if system_text_json_annotation %}
12
- <PackageReference Include="System.Text.Json" Version="9.0.3" />
12
+ <PackageReference Include="System.Text.Json" Version="{{ SYSTEM_TEXT_JSON_VERSION }}" />
13
13
  {%- endif %}
14
- <PackageReference Include="System.Memory.Data" Version="9.0.3" />
14
+ <PackageReference Include="System.Memory.Data" Version="{{ SYSTEM_MEMORY_DATA_VERSION }}" />
15
15
  </ItemGroup>
16
16
  </Project>
17
+
@@ -10,8 +10,9 @@
10
10
  <ProjectReference Include="../src/{{project_name | pascal}}.csproj"/>
11
11
  </ItemGroup>
12
12
  <ItemGroup>
13
- <PackageReference Include="NUnit" Version="4.3.2" />
14
- <PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
15
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
13
+ <PackageReference Include="NUnit" Version="{{ NUNIT_VERSION }}" />
14
+ <PackageReference Include="NUnit3TestAdapter" Version="{{ NUNIT_ADAPTER_VERSION }}" />
15
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="{{ MSTEST_SDK_VERSION }}" />
16
16
  </ItemGroup>
17
17
  </Project>
18
+