avrotize 2.21.1__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.
- avrotize/__init__.py +66 -0
- avrotize/__main__.py +6 -0
- avrotize/_version.py +34 -0
- avrotize/asn1toavro.py +160 -0
- avrotize/avrotize.py +152 -0
- avrotize/avrotocpp/CMakeLists.txt.jinja +77 -0
- avrotize/avrotocpp/build.bat.jinja +7 -0
- avrotize/avrotocpp/build.sh.jinja +7 -0
- avrotize/avrotocpp/dataclass_body.jinja +108 -0
- avrotize/avrotocpp/vcpkg.json.jinja +21 -0
- avrotize/avrotocpp.py +483 -0
- avrotize/avrotocsharp/README.md.jinja +166 -0
- avrotize/avrotocsharp/class_test.cs.jinja +266 -0
- avrotize/avrotocsharp/dataclass_core.jinja +293 -0
- avrotize/avrotocsharp/enum_test.cs.jinja +20 -0
- avrotize/avrotocsharp/project.csproj.jinja +30 -0
- avrotize/avrotocsharp/project.sln.jinja +34 -0
- avrotize/avrotocsharp/run_coverage.ps1.jinja +98 -0
- avrotize/avrotocsharp/run_coverage.sh.jinja +149 -0
- avrotize/avrotocsharp/testproject.csproj.jinja +19 -0
- avrotize/avrotocsharp.py +1180 -0
- avrotize/avrotocsv.py +121 -0
- avrotize/avrotodatapackage.py +173 -0
- avrotize/avrotodb.py +1383 -0
- avrotize/avrotogo/go_enum.jinja +12 -0
- avrotize/avrotogo/go_helpers.jinja +31 -0
- avrotize/avrotogo/go_struct.jinja +151 -0
- avrotize/avrotogo/go_test.jinja +47 -0
- avrotize/avrotogo/go_union.jinja +38 -0
- avrotize/avrotogo.py +476 -0
- avrotize/avrotographql.py +197 -0
- avrotize/avrotoiceberg.py +210 -0
- avrotize/avrotojava/class_test.java.jinja +212 -0
- avrotize/avrotojava/enum_test.java.jinja +21 -0
- avrotize/avrotojava/testproject.pom.jinja +54 -0
- avrotize/avrotojava.py +2156 -0
- avrotize/avrotojs.py +250 -0
- avrotize/avrotojsons.py +481 -0
- avrotize/avrotojstruct.py +345 -0
- avrotize/avrotokusto.py +364 -0
- avrotize/avrotomd/README.md.jinja +49 -0
- avrotize/avrotomd.py +137 -0
- avrotize/avrotools.py +168 -0
- avrotize/avrotoparquet.py +208 -0
- avrotize/avrotoproto.py +359 -0
- avrotize/avrotopython/dataclass_core.jinja +241 -0
- avrotize/avrotopython/enum_core.jinja +87 -0
- avrotize/avrotopython/pyproject_toml.jinja +18 -0
- avrotize/avrotopython/test_class.jinja +97 -0
- avrotize/avrotopython/test_enum.jinja +23 -0
- avrotize/avrotopython.py +626 -0
- avrotize/avrotorust/dataclass_enum.rs.jinja +74 -0
- avrotize/avrotorust/dataclass_struct.rs.jinja +204 -0
- avrotize/avrotorust/dataclass_union.rs.jinja +105 -0
- avrotize/avrotorust.py +435 -0
- avrotize/avrotots/class_core.ts.jinja +140 -0
- avrotize/avrotots/class_test.ts.jinja +77 -0
- avrotize/avrotots/enum_core.ts.jinja +46 -0
- avrotize/avrotots/gitignore.jinja +34 -0
- avrotize/avrotots/index.ts.jinja +0 -0
- avrotize/avrotots/package.json.jinja +23 -0
- avrotize/avrotots/tsconfig.json.jinja +21 -0
- avrotize/avrotots.py +687 -0
- avrotize/avrotoxsd.py +344 -0
- avrotize/cddltostructure.py +1841 -0
- avrotize/commands.json +3496 -0
- avrotize/common.py +834 -0
- avrotize/constants.py +87 -0
- avrotize/csvtoavro.py +132 -0
- avrotize/datapackagetoavro.py +76 -0
- avrotize/dependencies/cpp/vcpkg/vcpkg.json +19 -0
- avrotize/dependencies/cs/net90/dependencies.csproj +29 -0
- avrotize/dependencies/go/go121/go.mod +6 -0
- avrotize/dependencies/java/jdk21/pom.xml +91 -0
- avrotize/dependencies/python/py312/requirements.txt +13 -0
- avrotize/dependencies/rust/stable/Cargo.toml +17 -0
- avrotize/dependencies/typescript/node22/package.json +16 -0
- avrotize/dependency_resolver.py +348 -0
- avrotize/dependency_version.py +432 -0
- avrotize/generic/generic.avsc +57 -0
- avrotize/jsonstoavro.py +2167 -0
- avrotize/jsonstostructure.py +2864 -0
- avrotize/jstructtoavro.py +878 -0
- avrotize/kstructtoavro.py +93 -0
- avrotize/kustotoavro.py +455 -0
- avrotize/openapitostructure.py +717 -0
- avrotize/parquettoavro.py +157 -0
- avrotize/proto2parser.py +498 -0
- avrotize/proto3parser.py +403 -0
- avrotize/prototoavro.py +382 -0
- avrotize/prototypes/any.avsc +19 -0
- avrotize/prototypes/api.avsc +106 -0
- avrotize/prototypes/duration.avsc +20 -0
- avrotize/prototypes/field_mask.avsc +18 -0
- avrotize/prototypes/struct.avsc +60 -0
- avrotize/prototypes/timestamp.avsc +20 -0
- avrotize/prototypes/type.avsc +253 -0
- avrotize/prototypes/wrappers.avsc +117 -0
- avrotize/structuretocddl.py +597 -0
- avrotize/structuretocpp/CMakeLists.txt.jinja +76 -0
- avrotize/structuretocpp/build.bat.jinja +3 -0
- avrotize/structuretocpp/build.sh.jinja +3 -0
- avrotize/structuretocpp/dataclass_body.jinja +50 -0
- avrotize/structuretocpp/vcpkg.json.jinja +11 -0
- avrotize/structuretocpp.py +697 -0
- avrotize/structuretocsharp/class_test.cs.jinja +180 -0
- avrotize/structuretocsharp/dataclass_core.jinja +156 -0
- avrotize/structuretocsharp/enum_test.cs.jinja +36 -0
- avrotize/structuretocsharp/json_structure_converters.cs.jinja +399 -0
- avrotize/structuretocsharp/program.cs.jinja +49 -0
- avrotize/structuretocsharp/project.csproj.jinja +17 -0
- avrotize/structuretocsharp/project.sln.jinja +34 -0
- avrotize/structuretocsharp/testproject.csproj.jinja +18 -0
- avrotize/structuretocsharp/tuple_converter.cs.jinja +121 -0
- avrotize/structuretocsharp.py +2295 -0
- avrotize/structuretocsv.py +365 -0
- avrotize/structuretodatapackage.py +659 -0
- avrotize/structuretodb.py +1125 -0
- avrotize/structuretogo/go_enum.jinja +12 -0
- avrotize/structuretogo/go_helpers.jinja +26 -0
- avrotize/structuretogo/go_interface.jinja +18 -0
- avrotize/structuretogo/go_struct.jinja +187 -0
- avrotize/structuretogo/go_test.jinja +70 -0
- avrotize/structuretogo.py +729 -0
- avrotize/structuretographql.py +502 -0
- avrotize/structuretoiceberg.py +355 -0
- avrotize/structuretojava/choice_core.jinja +34 -0
- avrotize/structuretojava/class_core.jinja +23 -0
- avrotize/structuretojava/enum_core.jinja +18 -0
- avrotize/structuretojava/equals_hashcode.jinja +30 -0
- avrotize/structuretojava/pom.xml.jinja +26 -0
- avrotize/structuretojava/tuple_core.jinja +49 -0
- avrotize/structuretojava.py +938 -0
- avrotize/structuretojs/class_core.js.jinja +33 -0
- avrotize/structuretojs/enum_core.js.jinja +10 -0
- avrotize/structuretojs/package.json.jinja +12 -0
- avrotize/structuretojs/test_class.js.jinja +84 -0
- avrotize/structuretojs/test_enum.js.jinja +58 -0
- avrotize/structuretojs/test_runner.js.jinja +45 -0
- avrotize/structuretojs.py +657 -0
- avrotize/structuretojsons.py +498 -0
- avrotize/structuretokusto.py +639 -0
- avrotize/structuretomd/README.md.jinja +204 -0
- avrotize/structuretomd.py +322 -0
- avrotize/structuretoproto.py +764 -0
- avrotize/structuretopython/dataclass_core.jinja +363 -0
- avrotize/structuretopython/enum_core.jinja +45 -0
- avrotize/structuretopython/map_alias.jinja +21 -0
- avrotize/structuretopython/pyproject_toml.jinja +23 -0
- avrotize/structuretopython/test_class.jinja +103 -0
- avrotize/structuretopython/test_enum.jinja +34 -0
- avrotize/structuretopython.py +799 -0
- avrotize/structuretorust/dataclass_enum.rs.jinja +63 -0
- avrotize/structuretorust/dataclass_struct.rs.jinja +121 -0
- avrotize/structuretorust/dataclass_union.rs.jinja +81 -0
- avrotize/structuretorust.py +714 -0
- avrotize/structuretots/class_core.ts.jinja +78 -0
- avrotize/structuretots/enum_core.ts.jinja +6 -0
- avrotize/structuretots/gitignore.jinja +8 -0
- avrotize/structuretots/index.ts.jinja +1 -0
- avrotize/structuretots/package.json.jinja +39 -0
- avrotize/structuretots/test_class.ts.jinja +35 -0
- avrotize/structuretots/tsconfig.json.jinja +21 -0
- avrotize/structuretots.py +740 -0
- avrotize/structuretoxsd.py +679 -0
- avrotize/xsdtoavro.py +413 -0
- avrotize-2.21.1.dist-info/METADATA +1319 -0
- avrotize-2.21.1.dist-info/RECORD +171 -0
- avrotize-2.21.1.dist-info/WHEEL +4 -0
- avrotize-2.21.1.dist-info/entry_points.txt +3 -0
- avrotize-2.21.1.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using NUnit.Framework;
|
|
4
|
+
|
|
5
|
+
{% if namespace %}
|
|
6
|
+
namespace {{ namespace }}
|
|
7
|
+
{
|
|
8
|
+
{% endif %}
|
|
9
|
+
{% set ind=4 if namespace else 0 %}
|
|
10
|
+
{% filter indent(width=ind, first=True) %}
|
|
11
|
+
/// <summary> Test class for {{ class_base_name }} </summary>
|
|
12
|
+
[TestFixture]
|
|
13
|
+
public class {{ test_class_name }}
|
|
14
|
+
{
|
|
15
|
+
private {{ class_base_name }} _instance;
|
|
16
|
+
|
|
17
|
+
/// <summary> Constructor </summary>
|
|
18
|
+
public {{ test_class_name }}()
|
|
19
|
+
{
|
|
20
|
+
_instance = CreateInstance();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// <summary> Create instance of {{ class_base_name }} </summary>
|
|
24
|
+
public {{ class_base_name }} CreateInstance()
|
|
25
|
+
{
|
|
26
|
+
var instance = new {{ class_base_name }}();
|
|
27
|
+
{%- for field in fields %}
|
|
28
|
+
{%- if not field.is_const %}
|
|
29
|
+
instance.{{ field.field_name }} = {{ field.test_value }};
|
|
30
|
+
{%- endif %}
|
|
31
|
+
{%- endfor %}
|
|
32
|
+
return instance;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// <summary> Testing Equals and GetHashCode - positive case </summary>
|
|
36
|
+
[Test]
|
|
37
|
+
public void TestEqualsAndHashCode_PositiveCase()
|
|
38
|
+
{
|
|
39
|
+
var instance1 = CreateInstance();
|
|
40
|
+
var instance2 = CreateInstance();
|
|
41
|
+
|
|
42
|
+
// Test equality
|
|
43
|
+
Assert.That(instance1.Equals(instance2), Is.True, "Two instances with same values should be equal");
|
|
44
|
+
Assert.That(instance1 == instance2, Is.False, "Operator == should use reference equality");
|
|
45
|
+
|
|
46
|
+
// Test hash codes
|
|
47
|
+
Assert.That(instance1.GetHashCode(), Is.EqualTo(instance2.GetHashCode()),
|
|
48
|
+
"Equal instances should have equal hash codes");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// <summary> Testing Equals and GetHashCode - negative case </summary>
|
|
52
|
+
[Test]
|
|
53
|
+
public void TestEqualsAndHashCode_NegativeCase()
|
|
54
|
+
{
|
|
55
|
+
var instance1 = CreateInstance();
|
|
56
|
+
var instance2 = CreateInstance();
|
|
57
|
+
|
|
58
|
+
{%- set ns = {'found': false, 'is_complex_non_nullable': false} %}
|
|
59
|
+
{%- for field in fields if not field.is_const %}
|
|
60
|
+
{%- if not ns.found %}
|
|
61
|
+
{%- set _ = ns.update({'found': true}) %}
|
|
62
|
+
// Modify {{ field.field_name }} and verify inequality
|
|
63
|
+
{%- set base_type = field.field_type.rstrip('?') %}
|
|
64
|
+
{%- if base_type == "string" %}
|
|
65
|
+
instance2.{{ field.field_name }} = (instance2.{{ field.field_name }} ?? "test") + "_modified";
|
|
66
|
+
{%- elif base_type in ["int", "long", "short", "byte", "sbyte", "uint", "ulong", "ushort"] %}
|
|
67
|
+
instance2.{{ field.field_name }} = ({{ base_type }})({{ "(instance2." + field.field_name + " ?? 0)" if field.field_type.endswith("?") else "instance2." + field.field_name }} + 1);
|
|
68
|
+
{%- elif base_type in ["float", "double", "decimal"] %}
|
|
69
|
+
instance2.{{ field.field_name }} = {{ "(instance2." + field.field_name + " ?? 0)" if field.field_type.endswith("?") else "instance2." + field.field_name }} + 1.0{{ "f" if base_type == "float" else "m" if base_type == "decimal" else "" }};
|
|
70
|
+
{%- elif base_type == "bool" %}
|
|
71
|
+
instance2.{{ field.field_name }} = !{{ "(instance2." + field.field_name + " ?? false)" if field.field_type.endswith("?") else "instance2." + field.field_name }};
|
|
72
|
+
{%- elif field.field_type.endswith("?") %}
|
|
73
|
+
// For nullable complex types (including global:: types), set to null to make it different
|
|
74
|
+
instance2.{{ field.field_name }} = null;
|
|
75
|
+
{%- elif base_type.startswith("global::") and field.is_enum %}
|
|
76
|
+
// For non-nullable enum, cast to int and increment
|
|
77
|
+
instance2.{{ field.field_name }} = ({{ base_type }})((int)instance2.{{ field.field_name }} + 1);
|
|
78
|
+
{%- else %}
|
|
79
|
+
{%- set _ = ns.update({'is_complex_non_nullable': true}) %}
|
|
80
|
+
{%- endif %}
|
|
81
|
+
{%- if not ns.is_complex_non_nullable %}
|
|
82
|
+
Assert.That(instance1.Equals(instance2), Is.False,
|
|
83
|
+
"Instances with different {{ field.field_name }} should not be equal");
|
|
84
|
+
{%- endif %}
|
|
85
|
+
{%- endif %}
|
|
86
|
+
{%- endfor %}
|
|
87
|
+
{%- if ns.is_complex_non_nullable %}
|
|
88
|
+
// For non-nullable complex types (like unions), verify the positive case works correctly
|
|
89
|
+
// since we cannot create a meaningfully different value without knowing the type internals
|
|
90
|
+
Assert.Pass("Skipped negative test for complex non-nullable type - positive case validates Equals implementation");
|
|
91
|
+
{%- endif %}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
{%- for field in fields %}
|
|
95
|
+
/// <summary> Testing property {{ field.field_name }} </summary>
|
|
96
|
+
[Test]
|
|
97
|
+
public void Test{{ field.field_name | replace ('@','') | pascal }}Property()
|
|
98
|
+
{
|
|
99
|
+
var testValue = {{ field.test_value }};
|
|
100
|
+
{%- if not field.is_const %}
|
|
101
|
+
_instance.{{ field.field_name }} = testValue;
|
|
102
|
+
{%- endif %}
|
|
103
|
+
{%- if field.is_primitive %}
|
|
104
|
+
{%- if field.field_type.startswith("List<") or field.field_type.startswith("Dictionary<") %}
|
|
105
|
+
Assert.That(_instance.{{ field.field_name }}, Is.EquivalentTo(testValue));
|
|
106
|
+
{%- else %}
|
|
107
|
+
Assert.That(_instance.{{ field.field_name }}, Is.EqualTo(testValue));
|
|
108
|
+
{%- endif %}
|
|
109
|
+
{%- else %}
|
|
110
|
+
Assert.That(_instance.{{ field.field_name }}, Is.EqualTo(testValue));
|
|
111
|
+
{%- endif %}
|
|
112
|
+
}
|
|
113
|
+
{%- endfor %}
|
|
114
|
+
{%- if avro_annotation %}
|
|
115
|
+
/// <summary> Testing Avro serializer </summary>
|
|
116
|
+
[Test]
|
|
117
|
+
public void Test_ToByteArray_FromData_Avro()
|
|
118
|
+
{
|
|
119
|
+
var mediaType = "application/vnd.apache.avro+avro";
|
|
120
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
121
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
122
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
123
|
+
}
|
|
124
|
+
{%- endif %}
|
|
125
|
+
{%- if protobuf_net_annotation %}
|
|
126
|
+
/// <summary> Testing Protobuf serializer </summary>
|
|
127
|
+
[Test]
|
|
128
|
+
public void Test_ToByteArray_FromData_Protobuf()
|
|
129
|
+
{
|
|
130
|
+
var mediaType = "application/x-protobuf";
|
|
131
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
132
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
133
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
134
|
+
}
|
|
135
|
+
{%- endif %}
|
|
136
|
+
{%- if system_xml_annotation %}
|
|
137
|
+
/// <summary> Testing XML serializer </summary>
|
|
138
|
+
[Test]
|
|
139
|
+
public void Test_ToByteArray_FromData_Xml()
|
|
140
|
+
{
|
|
141
|
+
var mediaType = "application/xml";
|
|
142
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
143
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
144
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
145
|
+
}
|
|
146
|
+
{%- endif %}
|
|
147
|
+
{%- if system_text_json_annotation %}
|
|
148
|
+
/// <summary> Testing JSON serializer </summary>
|
|
149
|
+
[Test]
|
|
150
|
+
public void Test_ToByteArray_FromData_Json()
|
|
151
|
+
{
|
|
152
|
+
var mediaType = "application/json";
|
|
153
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
154
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
155
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
156
|
+
}
|
|
157
|
+
{%- endif %}
|
|
158
|
+
{%- if msgpack_annotation %}
|
|
159
|
+
/// <summary> Testing MsgPack serializer </summary>
|
|
160
|
+
[Test]
|
|
161
|
+
public void Test_ToByteArray_FromData_MsgPack()
|
|
162
|
+
{
|
|
163
|
+
var mediaType = "application/msgpack";
|
|
164
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
165
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
166
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
167
|
+
}
|
|
168
|
+
{%- endif %}
|
|
169
|
+
{%- if avro_annotation or system_text_json_annotation or newtonsoft_json_annotation or system_xml_annotation or msgpack_annotation or protobuf_net_annotation %}
|
|
170
|
+
|
|
171
|
+
/// <summary> Testing FromData with edge cases </summary>
|
|
172
|
+
[Test]
|
|
173
|
+
public void Test_FromData_EdgeCases()
|
|
174
|
+
{
|
|
175
|
+
{%- if system_text_json_annotation %}
|
|
176
|
+
// Test null data - FromData returns null for null input
|
|
177
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/json"), Is.Null);
|
|
178
|
+
// Test empty data - should throw JsonException for invalid JSON
|
|
179
|
+
Assert.Throws<System.Text.Json.JsonException>(() => {{ class_base_name }}.FromData(Array.Empty<byte>(), "application/json"));
|
|
180
|
+
{%- elif newtonsoft_json_annotation %}
|
|
181
|
+
// Test null data - FromData returns null for null input
|
|
182
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/json"), Is.Null);
|
|
183
|
+
// Test empty data - Newtonsoft.Json returns null for empty string
|
|
184
|
+
Assert.That({{ class_base_name }}.FromData(Array.Empty<byte>(), "application/json"), Is.Null);
|
|
185
|
+
{%- elif avro_annotation %}
|
|
186
|
+
// Test null data - FromData returns null for null input
|
|
187
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "avro/binary"), Is.Null);
|
|
188
|
+
{%- elif msgpack_annotation %}
|
|
189
|
+
// Test null data - FromData returns null for null input
|
|
190
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/msgpack"), Is.Null);
|
|
191
|
+
{%- elif protobuf_net_annotation %}
|
|
192
|
+
// Test null data - FromData returns null for null input
|
|
193
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/x-protobuf"), Is.Null);
|
|
194
|
+
{%- elif system_xml_annotation %}
|
|
195
|
+
// Test null data - FromData returns null for null input
|
|
196
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/xml"), Is.Null);
|
|
197
|
+
{%- endif %}
|
|
198
|
+
}
|
|
199
|
+
{%- endif %}
|
|
200
|
+
{%- if system_text_json_annotation %}
|
|
201
|
+
|
|
202
|
+
/// <summary> Testing IsJsonMatch </summary>
|
|
203
|
+
[Test]
|
|
204
|
+
public void Test_IsJsonMatch()
|
|
205
|
+
{
|
|
206
|
+
var json = System.Text.Json.JsonSerializer.Serialize(_instance);
|
|
207
|
+
using var doc = System.Text.Json.JsonDocument.Parse(json);
|
|
208
|
+
Assert.That({{ class_base_name }}.IsJsonMatch(doc.RootElement), Is.True);
|
|
209
|
+
}
|
|
210
|
+
{%- endif %}
|
|
211
|
+
{%- if system_text_json_annotation or newtonsoft_json_annotation %}
|
|
212
|
+
|
|
213
|
+
/// <summary> Testing Gzip compression </summary>
|
|
214
|
+
[Test]
|
|
215
|
+
public void Test_ToByteArray_Gzip()
|
|
216
|
+
{
|
|
217
|
+
var mediaType = "application/json";
|
|
218
|
+
var gzipMediaType = "application/json+gzip";
|
|
219
|
+
var plainBytes = _instance.ToByteArray(mediaType);
|
|
220
|
+
var gzipBytes = _instance.ToByteArray(gzipMediaType);
|
|
221
|
+
// Gzip compressed data should start with magic bytes 0x1f 0x8b
|
|
222
|
+
Assert.That(gzipBytes.Length >= 2 && gzipBytes[0] == 0x1f && gzipBytes[1] == 0x8b, Is.True,
|
|
223
|
+
"Gzip compressed data should have correct magic bytes");
|
|
224
|
+
var newInstance = {{ class_base_name }}.FromData(gzipBytes, gzipMediaType);
|
|
225
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
226
|
+
}
|
|
227
|
+
{%- endif %}
|
|
228
|
+
{%- if msgpack_annotation and not (system_text_json_annotation or newtonsoft_json_annotation) %}
|
|
229
|
+
|
|
230
|
+
/// <summary> Testing Gzip compression with MessagePack </summary>
|
|
231
|
+
[Test]
|
|
232
|
+
public void Test_ToByteArray_Gzip_MsgPack()
|
|
233
|
+
{
|
|
234
|
+
var mediaType = "application/msgpack";
|
|
235
|
+
var gzipMediaType = "application/msgpack+gzip";
|
|
236
|
+
var plainBytes = _instance.ToByteArray(mediaType);
|
|
237
|
+
var gzipBytes = _instance.ToByteArray(gzipMediaType);
|
|
238
|
+
// Gzip compressed data should start with magic bytes 0x1f 0x8b
|
|
239
|
+
Assert.That(gzipBytes.Length >= 2 && gzipBytes[0] == 0x1f && gzipBytes[1] == 0x8b, Is.True,
|
|
240
|
+
"Gzip compressed data should have correct magic bytes");
|
|
241
|
+
var newInstance = {{ class_base_name }}.FromData(gzipBytes, gzipMediaType);
|
|
242
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
243
|
+
}
|
|
244
|
+
{%- endif %}
|
|
245
|
+
{%- if protobuf_net_annotation and not (system_text_json_annotation or newtonsoft_json_annotation or msgpack_annotation) %}
|
|
246
|
+
|
|
247
|
+
/// <summary> Testing Gzip compression with Protobuf </summary>
|
|
248
|
+
[Test]
|
|
249
|
+
public void Test_ToByteArray_Gzip_Protobuf()
|
|
250
|
+
{
|
|
251
|
+
var mediaType = "application/x-protobuf";
|
|
252
|
+
var gzipMediaType = "application/x-protobuf+gzip";
|
|
253
|
+
var plainBytes = _instance.ToByteArray(mediaType);
|
|
254
|
+
var gzipBytes = _instance.ToByteArray(gzipMediaType);
|
|
255
|
+
// Gzip compressed data should start with magic bytes 0x1f 0x8b
|
|
256
|
+
Assert.That(gzipBytes.Length >= 2 && gzipBytes[0] == 0x1f && gzipBytes[1] == 0x8b, Is.True,
|
|
257
|
+
"Gzip compressed data should have correct magic bytes");
|
|
258
|
+
var newInstance = {{ class_base_name }}.FromData(gzipBytes, gzipMediaType);
|
|
259
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
260
|
+
}
|
|
261
|
+
{%- endif %}
|
|
262
|
+
}
|
|
263
|
+
{% endfilter %}
|
|
264
|
+
{% if namespace %}
|
|
265
|
+
}
|
|
266
|
+
{% endif %}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
{%- if avro_annotation or system_text_json_annotation or newtonsoft_json_annotation or system_xml_annotation or protobuf_net_annotation or msgpack_annotation %}
|
|
2
|
+
/// <summary>
|
|
3
|
+
/// Creates an object from the data
|
|
4
|
+
/// </summary>
|
|
5
|
+
/// <param name="data">The input data to convert</param>
|
|
6
|
+
/// <param name="contentTypeString">The content type string of the desired encoding</param>
|
|
7
|
+
/// <returns>The converted object</returns>
|
|
8
|
+
public static {{ class_name }}? FromData(object? data, string? contentTypeString )
|
|
9
|
+
{
|
|
10
|
+
if ( data == null ) return null;
|
|
11
|
+
if ( data is {{ class_name }}) return ({{ class_name }})data;
|
|
12
|
+
if ( contentTypeString == null ) contentTypeString = System.Net.Mime.MediaTypeNames.Application.Octet;
|
|
13
|
+
var contentType = new System.Net.Mime.ContentType(contentTypeString);
|
|
14
|
+
{%- if avro_annotation or system_text_json_annotation or newtonsoft_json_annotation or system_xml_annotation or protobuf_net_annotation or msgpack_annotation %}
|
|
15
|
+
if ( contentType.MediaType.EndsWith("+gzip"))
|
|
16
|
+
{
|
|
17
|
+
var stream = data switch
|
|
18
|
+
{
|
|
19
|
+
System.IO.Stream s => s, System.BinaryData bd => bd.ToStream(), byte[] bytes => new System.IO.MemoryStream(bytes),
|
|
20
|
+
_ => throw new NotSupportedException("Data is not of a supported type for gzip decompression")
|
|
21
|
+
};
|
|
22
|
+
using (var gzip = new System.IO.Compression.GZipStream(stream, System.IO.Compression.CompressionMode.Decompress))
|
|
23
|
+
{
|
|
24
|
+
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
|
|
25
|
+
gzip.CopyTo(memoryStream);
|
|
26
|
+
memoryStream.Position = 0;
|
|
27
|
+
data = memoryStream.ToArray();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
{%- endif %}
|
|
31
|
+
{%- if avro_annotation %}
|
|
32
|
+
if ( contentType.MediaType.StartsWith("avro/") || contentType.MediaType.StartsWith("application/vnd.apache.avro") )
|
|
33
|
+
{
|
|
34
|
+
var stream = data switch
|
|
35
|
+
{
|
|
36
|
+
System.IO.Stream s => s, System.BinaryData bd => bd.ToStream(), byte[] bytes => new System.IO.MemoryStream(bytes),
|
|
37
|
+
_ => throw new NotSupportedException("Data is not of a supported type for conversion to Stream")
|
|
38
|
+
};
|
|
39
|
+
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
|
40
|
+
if (contentType.MediaType.StartsWith("avro/binary") || contentType.MediaType.StartsWith("application/vnd.apache.avro+avro"))
|
|
41
|
+
{
|
|
42
|
+
var reader = new global::Avro.Generic.GenericDatumReader<global::Avro.Generic.GenericRecord>({{ class_name }}.AvroSchema, {{ class_name }}.AvroSchema);
|
|
43
|
+
return new {{ class_name }}(reader.Read(null, new global::Avro.IO.BinaryDecoder(stream)));
|
|
44
|
+
}
|
|
45
|
+
if ( contentType.MediaType.StartsWith("avro/json") || contentType.MediaType.StartsWith("application/vnd.apache.avro+json"))
|
|
46
|
+
{
|
|
47
|
+
var reader = new global::Avro.Generic.GenericDatumReader<global::Avro.Generic.GenericRecord>({{ class_name }}.AvroSchema, {{ class_name }}.AvroSchema);
|
|
48
|
+
return new {{ class_name }}(reader.Read(null, new global::Avro.IO.JsonDecoder({{ class_name }}.AvroSchema, stream)));
|
|
49
|
+
}
|
|
50
|
+
#pragma warning restore CS8625
|
|
51
|
+
}
|
|
52
|
+
{%- endif %}
|
|
53
|
+
{%- if system_text_json_annotation %}
|
|
54
|
+
if ( contentType.MediaType.StartsWith(System.Net.Mime.MediaTypeNames.Application.Json))
|
|
55
|
+
{
|
|
56
|
+
if (data is System.Text.Json.JsonElement)
|
|
57
|
+
{
|
|
58
|
+
return System.Text.Json.JsonSerializer.Deserialize<{{ class_name }}>((System.Text.Json.JsonElement)data);
|
|
59
|
+
}
|
|
60
|
+
else if ( data is string)
|
|
61
|
+
{
|
|
62
|
+
return System.Text.Json.JsonSerializer.Deserialize<{{ class_name }}>((string)data);
|
|
63
|
+
}
|
|
64
|
+
else if (data is System.BinaryData)
|
|
65
|
+
{
|
|
66
|
+
return ((System.BinaryData)data).ToObjectFromJson<{{ class_name }}>();
|
|
67
|
+
}
|
|
68
|
+
else if (data is byte[])
|
|
69
|
+
{
|
|
70
|
+
return System.Text.Json.JsonSerializer.Deserialize<{{ class_name }}>(new ReadOnlySpan<byte>((byte[])data));
|
|
71
|
+
}
|
|
72
|
+
else if (data is System.IO.Stream)
|
|
73
|
+
{
|
|
74
|
+
return System.Text.Json.JsonSerializer.DeserializeAsync<{{ class_name }}>((System.IO.Stream)data).Result;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
{%- endif %}
|
|
78
|
+
{%- if newtonsoft_json_annotation %}
|
|
79
|
+
if ( contentType.MediaType.StartsWith(System.Net.Mime.MediaTypeNames.Application.Json))
|
|
80
|
+
{
|
|
81
|
+
if (data is string)
|
|
82
|
+
{
|
|
83
|
+
return Newtonsoft.Json.JsonConvert.DeserializeObject<{{ class_name }}>((string)data);
|
|
84
|
+
}
|
|
85
|
+
else if (data is System.BinaryData)
|
|
86
|
+
{
|
|
87
|
+
return Newtonsoft.Json.JsonConvert.DeserializeObject<{{ class_name }}>(((System.BinaryData)data).ToString());
|
|
88
|
+
}
|
|
89
|
+
else if (data is byte[])
|
|
90
|
+
{
|
|
91
|
+
return Newtonsoft.Json.JsonConvert.DeserializeObject<{{ class_name }}>(System.Text.Encoding.UTF8.GetString((byte[])data));
|
|
92
|
+
}
|
|
93
|
+
else if (data is System.IO.Stream)
|
|
94
|
+
{
|
|
95
|
+
using (var reader = new System.IO.StreamReader((System.IO.Stream)data))
|
|
96
|
+
{
|
|
97
|
+
return Newtonsoft.Json.JsonConvert.DeserializeObject<{{ class_name }}>(reader.ReadToEnd());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
{%- endif %}
|
|
102
|
+
{%- if protobuf_net_annotation %}
|
|
103
|
+
if ( contentType.MediaType.StartsWith("application/x-protobuf") || contentType.MediaType.StartsWith("application/protobuf") || contentType.MediaType.StartsWith("application/vnd.google.protobuf"))
|
|
104
|
+
{
|
|
105
|
+
var stream = data switch
|
|
106
|
+
{
|
|
107
|
+
System.IO.Stream s => s, System.BinaryData bd => bd.ToStream(), byte[] bytes => new System.IO.MemoryStream(bytes),
|
|
108
|
+
_ => throw new NotSupportedException("Data is not of a supported type for conversion to Stream")
|
|
109
|
+
};
|
|
110
|
+
return global::ProtoBuf.Serializer.Deserialize<{{ class_name }}>(stream);
|
|
111
|
+
}
|
|
112
|
+
{%- endif %}
|
|
113
|
+
{%- if system_xml_annotation %}
|
|
114
|
+
if ( contentType.MediaType.StartsWith(System.Net.Mime.MediaTypeNames.Text.Xml) || contentType.MediaType.StartsWith(System.Net.Mime.MediaTypeNames.Application.Xml) || contentType.MediaType.EndsWith("+xml"))
|
|
115
|
+
{
|
|
116
|
+
var serializer = new System.Xml.Serialization.XmlSerializer(typeof({{ class_name }}));
|
|
117
|
+
if (data is string)
|
|
118
|
+
{
|
|
119
|
+
using (var reader = new System.IO.StringReader((string)data))
|
|
120
|
+
{
|
|
121
|
+
return ({{ class_name }}?)serializer.Deserialize(reader);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (data is System.IO.Stream)
|
|
125
|
+
{
|
|
126
|
+
return ({{ class_name }}?)serializer.Deserialize((System.IO.Stream)data);
|
|
127
|
+
}
|
|
128
|
+
else if (data is System.BinaryData)
|
|
129
|
+
{
|
|
130
|
+
var memoryStream = new System.IO.MemoryStream(((System.BinaryData)data).ToArray());
|
|
131
|
+
return ({{ class_name }}?)serializer.Deserialize(memoryStream);
|
|
132
|
+
}
|
|
133
|
+
else if (data is byte[])
|
|
134
|
+
{
|
|
135
|
+
var memoryStream = new System.IO.MemoryStream((byte[])data);
|
|
136
|
+
return ({{ class_name }}?)serializer.Deserialize(memoryStream);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
{%- endif %}
|
|
140
|
+
{%- if msgpack_annotation %}
|
|
141
|
+
if (contentType.MediaType.StartsWith("application/msgpack") || contentType.MediaType.StartsWith("application/x-msgpack"))
|
|
142
|
+
{
|
|
143
|
+
var bytes = data switch
|
|
144
|
+
{
|
|
145
|
+
byte[] b => b,
|
|
146
|
+
System.IO.Stream s => ReadStreamToBytes(s),
|
|
147
|
+
System.BinaryData bd => bd.ToArray(),
|
|
148
|
+
_ => throw new NotSupportedException("Data type not supported for MsgPack")
|
|
149
|
+
};
|
|
150
|
+
return MessagePack.MessagePackSerializer.Deserialize<{{ class_name }}>(bytes);
|
|
151
|
+
}
|
|
152
|
+
{%- endif %}
|
|
153
|
+
throw new System.NotSupportedException($"Unsupported media type {contentType.MediaType}");
|
|
154
|
+
}
|
|
155
|
+
{%- endif %}
|
|
156
|
+
|
|
157
|
+
{%- if msgpack_annotation %}
|
|
158
|
+
private static byte[] ReadStreamToBytes(System.IO.Stream stream)
|
|
159
|
+
{
|
|
160
|
+
using (var memoryStream = new System.IO.MemoryStream())
|
|
161
|
+
{
|
|
162
|
+
stream.CopyTo(memoryStream);
|
|
163
|
+
return memoryStream.ToArray();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
{%- endif %}
|
|
167
|
+
|
|
168
|
+
{%- if avro_annotation %}
|
|
169
|
+
private class SpecificDatumWriter : global::Avro.Specific.SpecificDatumWriter<{{ class_name }}>
|
|
170
|
+
{
|
|
171
|
+
public SpecificDatumWriter() : base({{ class_name }}.AvroSchema)
|
|
172
|
+
{
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
protected override WriteItem ResolveEnum(global::Avro.EnumSchema es)
|
|
176
|
+
{
|
|
177
|
+
var enumType = GetType().Assembly.GetType(GetType().Assembly.GetName().Name+"."+es.Namespace + "." + es.Name, false, true);
|
|
178
|
+
if (enumType != null)
|
|
179
|
+
{
|
|
180
|
+
return base.ResolveEnum(global::Avro.EnumSchema.Create(enumType.Name, es.Symbols, enumType.Namespace, null, null, es.Documentation, es.Default));
|
|
181
|
+
}
|
|
182
|
+
else
|
|
183
|
+
{
|
|
184
|
+
return base.ResolveEnum(es);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
{%- endif %}
|
|
189
|
+
|
|
190
|
+
{%- if avro_annotation %}
|
|
191
|
+
{%- endif%}
|
|
192
|
+
|
|
193
|
+
{%- if avro_annotation or system_text_json_annotation or newtonsoft_json_annotation or system_xml_annotation or protobuf_net_annotation or msgpack_annotation %}
|
|
194
|
+
/// <summary>
|
|
195
|
+
/// Converts the object to a byte array
|
|
196
|
+
/// </summary>
|
|
197
|
+
/// <param name="contentTypeString">The content type string of the desired encoding</param>
|
|
198
|
+
/// <returns>The encoded data</returns>
|
|
199
|
+
public byte[] ToByteArray(string contentTypeString)
|
|
200
|
+
{
|
|
201
|
+
var contentType = new System.Net.Mime.ContentType(contentTypeString);
|
|
202
|
+
byte[]? result = null;
|
|
203
|
+
{%- if avro_annotation %}
|
|
204
|
+
if (contentType.MediaType.StartsWith("avro/binary") || contentType.MediaType.StartsWith("application/vnd.apache.avro+avro"))
|
|
205
|
+
{
|
|
206
|
+
var stream = new System.IO.MemoryStream();
|
|
207
|
+
var writer = new SpecificDatumWriter();
|
|
208
|
+
var encoder = new global::Avro.IO.BinaryEncoder(stream);
|
|
209
|
+
writer.Write(this, encoder);
|
|
210
|
+
encoder.Flush();
|
|
211
|
+
result = stream.ToArray();
|
|
212
|
+
}
|
|
213
|
+
else if (contentType.MediaType.StartsWith("avro/json") || contentType.MediaType.StartsWith("application/vnd.apache.avro+json"))
|
|
214
|
+
{
|
|
215
|
+
var stream = new System.IO.MemoryStream();
|
|
216
|
+
var writer = new global::Avro.Specific.SpecificDatumWriter<{{ class_name }}>({{ class_name }}.AvroSchema);
|
|
217
|
+
var encoder = new global::Avro.IO.JsonEncoder({{ class_name }}.AvroSchema, stream);
|
|
218
|
+
writer.Write(this, encoder);
|
|
219
|
+
encoder.Flush();
|
|
220
|
+
result = stream.ToArray();
|
|
221
|
+
}
|
|
222
|
+
{%- endif %}
|
|
223
|
+
{%- if system_text_json_annotation %}
|
|
224
|
+
if (contentType.MediaType.StartsWith(System.Net.Mime.MediaTypeNames.Application.Json))
|
|
225
|
+
{
|
|
226
|
+
result = System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(this);
|
|
227
|
+
}
|
|
228
|
+
{%- endif %}
|
|
229
|
+
{%- if newtonsoft_json_annotation %}
|
|
230
|
+
if (contentType.MediaType.StartsWith(System.Net.Mime.MediaTypeNames.Application.Json))
|
|
231
|
+
{
|
|
232
|
+
result = System.Text.Encoding.GetEncoding(contentType.CharSet??"utf-8").GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
|
|
233
|
+
}
|
|
234
|
+
{%- endif %}
|
|
235
|
+
{%- if system_xml_annotation %}
|
|
236
|
+
if (contentType.MediaType.StartsWith(System.Net.Mime.MediaTypeNames.Text.Xml) || contentType.MediaType.StartsWith(System.Net.Mime.MediaTypeNames.Application.Xml) || contentType.MediaType.EndsWith("+xml"))
|
|
237
|
+
{
|
|
238
|
+
var serializer = new System.Xml.Serialization.XmlSerializer(typeof({{ class_name }}));
|
|
239
|
+
using (var stream = new System.IO.MemoryStream())
|
|
240
|
+
{
|
|
241
|
+
using (var writer = new System.IO.StreamWriter(stream))
|
|
242
|
+
{
|
|
243
|
+
serializer.Serialize(writer, this);
|
|
244
|
+
writer.Flush();
|
|
245
|
+
result = stream.ToArray();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
{%- endif %}
|
|
250
|
+
{%- if protobuf_net_annotation %}
|
|
251
|
+
if (contentType.MediaType.StartsWith("application/x-protobuf") || contentType.MediaType.StartsWith("application/protobuf") || contentType.MediaType.StartsWith("application/vnd.google.protobuf"))
|
|
252
|
+
{
|
|
253
|
+
using (var stream = new System.IO.MemoryStream())
|
|
254
|
+
{
|
|
255
|
+
global::ProtoBuf.Serializer.Serialize(stream, this);
|
|
256
|
+
result = stream.ToArray();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
{%- endif %}
|
|
260
|
+
{%- if msgpack_annotation %}
|
|
261
|
+
if (contentType.MediaType.StartsWith("application/msgpack") || contentType.MediaType.StartsWith("application/x-msgpack"))
|
|
262
|
+
{
|
|
263
|
+
result = MessagePack.MessagePackSerializer.Serialize(this);
|
|
264
|
+
}
|
|
265
|
+
{%- endif %}
|
|
266
|
+
{%- if avro_annotation or system_text_json_annotation or newtonsoft_json_annotation or system_xml_annotation or protobuf_net_annotation or msgpack_annotation %}
|
|
267
|
+
if (result != null && contentType.MediaType.EndsWith("+gzip"))
|
|
268
|
+
{
|
|
269
|
+
var stream = new System.IO.MemoryStream();
|
|
270
|
+
using (var gzip = new System.IO.Compression.GZipStream(stream, System.IO.Compression.CompressionMode.Compress))
|
|
271
|
+
{
|
|
272
|
+
gzip.Write(result, 0, result.Length);
|
|
273
|
+
}
|
|
274
|
+
result = stream.ToArray();
|
|
275
|
+
}
|
|
276
|
+
{%- endif %}
|
|
277
|
+
return ( result != null ) ? result : throw new System.NotSupportedException($"Unsupported media type {contentType.MediaType}");
|
|
278
|
+
}
|
|
279
|
+
{%- endif %}
|
|
280
|
+
|
|
281
|
+
{%- if system_text_json_annotation or newtonsoft_json_annotation %}
|
|
282
|
+
/// <summary>
|
|
283
|
+
/// Checks if the JSON element matches the schema
|
|
284
|
+
/// </summary>
|
|
285
|
+
/// <param name="element">The JSON element to check</param>
|
|
286
|
+
public static bool IsJsonMatch(System.Text.Json.JsonElement element)
|
|
287
|
+
{
|
|
288
|
+
return
|
|
289
|
+
{%- for clause in json_match_clauses %}
|
|
290
|
+
{{ clause }}{{ ' &&' if not loop.last }}
|
|
291
|
+
{%- endfor %};
|
|
292
|
+
}
|
|
293
|
+
{%- endif %}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using NUnit.Framework;
|
|
3
|
+
|
|
4
|
+
namespace {{ namespace }}
|
|
5
|
+
{
|
|
6
|
+
/// <summary> Test class for {{ enum_base_name }} </summary>
|
|
7
|
+
[TestFixture]
|
|
8
|
+
public class {{ test_class_name }}
|
|
9
|
+
{
|
|
10
|
+
/// <summary> Test {{ enum_base_name }} Enum </summary>
|
|
11
|
+
[Test]
|
|
12
|
+
public void Test_{{ enum_base_name }}_Enum()
|
|
13
|
+
{
|
|
14
|
+
var values = Enum.GetValues(typeof({{ enum_base_name }}));
|
|
15
|
+
{%- for symbol in symbols %}
|
|
16
|
+
Assert.That(Enum.IsDefined(typeof({{ enum_base_name }}), "{{ symbol }}"));
|
|
17
|
+
{%- endfor %}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
<PropertyGroup>
|
|
3
|
+
<TargetFramework>net9.0</TargetFramework>
|
|
4
|
+
<Nullable>enable</Nullable>
|
|
5
|
+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<ItemGroup>
|
|
8
|
+
{%- if avro_annotation %}
|
|
9
|
+
<PackageReference Include="Apache.Avro" Version="{{ CSHARP_AVRO_VERSION }}" />
|
|
10
|
+
{%- endif %}
|
|
11
|
+
{%- if protobuf_net_annotation %}
|
|
12
|
+
<PackageReference Include="protobuf-net" Version="{{ PROTOBUF_NET_VERSION }}" />
|
|
13
|
+
{%- endif %}
|
|
14
|
+
{%- if newtonsoft_json_annotation %}
|
|
15
|
+
<PackageReference Include="Newtonsoft.Json" Version="{{ NEWTONSOFT_JSON_VERSION }}" />
|
|
16
|
+
{%- endif %}
|
|
17
|
+
{%- if system_text_json_annotation %}
|
|
18
|
+
<PackageReference Include="System.Text.Json" Version="{{ SYSTEM_TEXT_JSON_VERSION }}" />
|
|
19
|
+
{%- endif %}
|
|
20
|
+
{%- if msgpack_annotation %}
|
|
21
|
+
<PackageReference Include="MessagePack" Version="{{ MSGPACK_VERSION }}" />
|
|
22
|
+
{%- endif %}
|
|
23
|
+
<PackageReference Include="System.Memory.Data" Version="{{ SYSTEM_MEMORY_DATA_VERSION }}" />
|
|
24
|
+
</ItemGroup>
|
|
25
|
+
<ItemGroup>
|
|
26
|
+
<PackageReference Include="NUnit" Version="{{ NUNIT_VERSION }}" />
|
|
27
|
+
<PackageReference Include="NUnit3TestAdapter" Version="{{ NUNIT_ADAPTER_VERSION }}" />
|
|
28
|
+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="{{ MSTEST_SDK_VERSION }}" />
|
|
29
|
+
</ItemGroup>
|
|
30
|
+
</Project>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{%- set slnguid = uuid() -%}
|
|
2
|
+
{%- set prjguid = uuid() -%}
|
|
3
|
+
{%- set testguid = uuid() -%}
|
|
4
|
+
{%- set slnguid2 = uuid() -%}
|
|
5
|
+
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
6
|
+
# Visual Studio Version 17
|
|
7
|
+
VisualStudioVersion = 17.5.002.0
|
|
8
|
+
MinimumVisualStudioVersion = 10.0.40219.1
|
|
9
|
+
Project("{ {{-slnguid-}} }") = "{{project_name|pascal}}", "src\{{project_name|pascal}}.csproj", "{ {{-prjguid-}} }"
|
|
10
|
+
EndProject
|
|
11
|
+
Project("{ {{-slnguid-}} }") = "{{project_name|pascal}}_test", "test\{{project_name|pascal}}.Test.csproj", "{ {{-testguid-}} }"
|
|
12
|
+
EndProject
|
|
13
|
+
Global
|
|
14
|
+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
15
|
+
Debug|Any CPU = Debug|Any CPU
|
|
16
|
+
Release|Any CPU = Release|Any CPU
|
|
17
|
+
EndGlobalSection
|
|
18
|
+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
19
|
+
{ {{-prjguid-}} }.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
20
|
+
{ {{-prjguid-}} }.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
21
|
+
{ {{-prjguid-}} }.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
22
|
+
{ {{-prjguid-}} }.Release|Any CPU.Build.0 = Release|Any CPU
|
|
23
|
+
{ {{-testguid-}} }.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
24
|
+
{ {{-testguid-}} }.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
25
|
+
{ {{-testguid-}} }.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
26
|
+
{ {{-testguid-}} }.Release|Any CPU.Build.0 = Release|Any CPU
|
|
27
|
+
EndGlobalSection
|
|
28
|
+
GlobalSection(SolutionProperties) = preSolution
|
|
29
|
+
HideSolutionNode = FALSE
|
|
30
|
+
EndGlobalSection
|
|
31
|
+
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
32
|
+
SolutionGuid = { {{-slnguid2-}} }
|
|
33
|
+
EndGlobalSection
|
|
34
|
+
EndGlobal
|