aas-core-codegen 0.0.16__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.
- aas_core_codegen/__init__.py +6 -0
- aas_core_codegen/__main__.py +8 -0
- aas_core_codegen/common.py +500 -0
- aas_core_codegen/cpp/__init__.py +1 -0
- aas_core_codegen/cpp/aas_common/__init__.py +6 -0
- aas_core_codegen/cpp/aas_common/_generate.py +713 -0
- aas_core_codegen/cpp/common.py +681 -0
- aas_core_codegen/cpp/constants/__init__.py +6 -0
- aas_core_codegen/cpp/constants/_generate.py +568 -0
- aas_core_codegen/cpp/description.py +654 -0
- aas_core_codegen/cpp/enhancing/__init__.py +4 -0
- aas_core_codegen/cpp/enhancing/_generate.py +993 -0
- aas_core_codegen/cpp/iteration/__init__.py +6 -0
- aas_core_codegen/cpp/iteration/_generate.py +2332 -0
- aas_core_codegen/cpp/jsonization/__init__.py +6 -0
- aas_core_codegen/cpp/jsonization/_generate.py +2619 -0
- aas_core_codegen/cpp/main.py +694 -0
- aas_core_codegen/cpp/naming.py +170 -0
- aas_core_codegen/cpp/optionaling.py +557 -0
- aas_core_codegen/cpp/pattern/__init__.py +6 -0
- aas_core_codegen/cpp/pattern/_generate.py +508 -0
- aas_core_codegen/cpp/revm/__init__.py +6 -0
- aas_core_codegen/cpp/revm/_generate.py +1149 -0
- aas_core_codegen/cpp/stringification/__init__.py +5 -0
- aas_core_codegen/cpp/stringification/_generate.py +955 -0
- aas_core_codegen/cpp/structure/__init__.py +7 -0
- aas_core_codegen/cpp/structure/_generate.py +1503 -0
- aas_core_codegen/cpp/transpilation.py +1383 -0
- aas_core_codegen/cpp/unrolling.py +159 -0
- aas_core_codegen/cpp/verification/__init__.py +6 -0
- aas_core_codegen/cpp/verification/_generate.py +3073 -0
- aas_core_codegen/cpp/visitation/__init__.py +6 -0
- aas_core_codegen/cpp/visitation/_generate.py +521 -0
- aas_core_codegen/cpp/wstringification/__init__.py +5 -0
- aas_core_codegen/cpp/wstringification/_generate.py +586 -0
- aas_core_codegen/cpp/xmlization/__init__.py +6 -0
- aas_core_codegen/cpp/xmlization/_generate.py +5373 -0
- aas_core_codegen/cpp/yielding.py +201 -0
- aas_core_codegen/csharp/__init__.py +1 -0
- aas_core_codegen/csharp/common.py +224 -0
- aas_core_codegen/csharp/constants/__init__.py +5 -0
- aas_core_codegen/csharp/constants/_generate.py +409 -0
- aas_core_codegen/csharp/copying/__init__.py +4 -0
- aas_core_codegen/csharp/copying/_generate.py +498 -0
- aas_core_codegen/csharp/description.py +1103 -0
- aas_core_codegen/csharp/enhancing/__init__.py +4 -0
- aas_core_codegen/csharp/enhancing/_generate.py +667 -0
- aas_core_codegen/csharp/jsonization/__init__.py +4 -0
- aas_core_codegen/csharp/jsonization/_generate.py +1630 -0
- aas_core_codegen/csharp/main.py +421 -0
- aas_core_codegen/csharp/naming.py +157 -0
- aas_core_codegen/csharp/reporting/__init__.py +4 -0
- aas_core_codegen/csharp/reporting/_generate.py +266 -0
- aas_core_codegen/csharp/stringification/__init__.py +4 -0
- aas_core_codegen/csharp/stringification/_generate.py +243 -0
- aas_core_codegen/csharp/structure/__init__.py +6 -0
- aas_core_codegen/csharp/structure/_generate.py +1341 -0
- aas_core_codegen/csharp/transpilation.py +990 -0
- aas_core_codegen/csharp/unrolling.py +211 -0
- aas_core_codegen/csharp/verification/__init__.py +6 -0
- aas_core_codegen/csharp/verification/_generate.py +1457 -0
- aas_core_codegen/csharp/visitation/__init__.py +5 -0
- aas_core_codegen/csharp/visitation/_generate.py +579 -0
- aas_core_codegen/csharp/xmlization/__init__.py +4 -0
- aas_core_codegen/csharp/xmlization/_generate.py +1980 -0
- aas_core_codegen/golang/__init__.py +1 -0
- aas_core_codegen/golang/aas_common/__init__.py +4 -0
- aas_core_codegen/golang/aas_common/_generate.py +152 -0
- aas_core_codegen/golang/common.py +303 -0
- aas_core_codegen/golang/constants/__init__.py +5 -0
- aas_core_codegen/golang/constants/_generate.py +339 -0
- aas_core_codegen/golang/description.py +501 -0
- aas_core_codegen/golang/enhancing/__init__.py +4 -0
- aas_core_codegen/golang/enhancing/_generate.py +527 -0
- aas_core_codegen/golang/jsonization/__init__.py +4 -0
- aas_core_codegen/golang/jsonization/_generate.py +1740 -0
- aas_core_codegen/golang/main.py +368 -0
- aas_core_codegen/golang/naming.py +412 -0
- aas_core_codegen/golang/pointering.py +631 -0
- aas_core_codegen/golang/reporting/__init__.py +4 -0
- aas_core_codegen/golang/reporting/_generate.py +218 -0
- aas_core_codegen/golang/stringification/__init__.py +4 -0
- aas_core_codegen/golang/stringification/_generate.py +394 -0
- aas_core_codegen/golang/structure/__init__.py +6 -0
- aas_core_codegen/golang/structure/_generate.py +1493 -0
- aas_core_codegen/golang/transpilation.py +1191 -0
- aas_core_codegen/golang/unrolling.py +159 -0
- aas_core_codegen/golang/verification/__init__.py +6 -0
- aas_core_codegen/golang/verification/_generate.py +1513 -0
- aas_core_codegen/golang/xmlization/__init__.py +4 -0
- aas_core_codegen/golang/xmlization/_generate.py +2507 -0
- aas_core_codegen/infer_for_schema/__init__.py +21 -0
- aas_core_codegen/infer_for_schema/_inline.py +693 -0
- aas_core_codegen/infer_for_schema/_len.py +527 -0
- aas_core_codegen/infer_for_schema/_pattern.py +311 -0
- aas_core_codegen/infer_for_schema/_set.py +394 -0
- aas_core_codegen/infer_for_schema/_stringify.py +201 -0
- aas_core_codegen/infer_for_schema/_types.py +135 -0
- aas_core_codegen/infer_for_schema/match.py +122 -0
- aas_core_codegen/intermediate/__init__.py +78 -0
- aas_core_codegen/intermediate/_hierarchy.py +397 -0
- aas_core_codegen/intermediate/_stringify.py +989 -0
- aas_core_codegen/intermediate/_translate.py +5128 -0
- aas_core_codegen/intermediate/_types.py +2901 -0
- aas_core_codegen/intermediate/construction.py +750 -0
- aas_core_codegen/intermediate/doc.py +344 -0
- aas_core_codegen/intermediate/pattern_verification.py +428 -0
- aas_core_codegen/intermediate/revm.py +985 -0
- aas_core_codegen/intermediate/type_inference.py +2266 -0
- aas_core_codegen/java/__init__.py +1 -0
- aas_core_codegen/java/common.py +197 -0
- aas_core_codegen/java/constants/__init__.py +5 -0
- aas_core_codegen/java/constants/_generate.py +334 -0
- aas_core_codegen/java/copying/__init__.py +4 -0
- aas_core_codegen/java/copying/_generate.py +502 -0
- aas_core_codegen/java/description.py +774 -0
- aas_core_codegen/java/enhancing/__init__.py +4 -0
- aas_core_codegen/java/enhancing/_generate.py +820 -0
- aas_core_codegen/java/generation/__init__.py +5 -0
- aas_core_codegen/java/generation/_generate.py +285 -0
- aas_core_codegen/java/jsonization/__init__.py +4 -0
- aas_core_codegen/java/jsonization/_generate.py +1472 -0
- aas_core_codegen/java/main.py +438 -0
- aas_core_codegen/java/naming.py +187 -0
- aas_core_codegen/java/optional.py +514 -0
- aas_core_codegen/java/reporting/__init__.py +4 -0
- aas_core_codegen/java/reporting/_generate.py +248 -0
- aas_core_codegen/java/stringification/__init__.py +4 -0
- aas_core_codegen/java/stringification/_generate.py +212 -0
- aas_core_codegen/java/structure/__init__.py +6 -0
- aas_core_codegen/java/structure/_generate.py +1767 -0
- aas_core_codegen/java/transpilation.py +1111 -0
- aas_core_codegen/java/verification/__init__.py +6 -0
- aas_core_codegen/java/verification/_generate.py +1536 -0
- aas_core_codegen/java/visitation/__init__.py +5 -0
- aas_core_codegen/java/visitation/_generate.py +689 -0
- aas_core_codegen/java/xmlization/__init__.py +4 -0
- aas_core_codegen/java/xmlization/_generate.py +2274 -0
- aas_core_codegen/jsonld/__init__.py +1 -0
- aas_core_codegen/jsonld/main.py +455 -0
- aas_core_codegen/jsonschema/__init__.py +1 -0
- aas_core_codegen/jsonschema/main.py +982 -0
- aas_core_codegen/main.py +245 -0
- aas_core_codegen/naming.py +133 -0
- aas_core_codegen/opcua/__init__.py +1 -0
- aas_core_codegen/opcua/main.py +1525 -0
- aas_core_codegen/opcua/naming.py +126 -0
- aas_core_codegen/parse/__init__.py +46 -0
- aas_core_codegen/parse/_rules.py +796 -0
- aas_core_codegen/parse/_stringify.py +532 -0
- aas_core_codegen/parse/_translate.py +3940 -0
- aas_core_codegen/parse/_types.py +973 -0
- aas_core_codegen/parse/retree/__init__.py +46 -0
- aas_core_codegen/parse/retree/_fix.py +434 -0
- aas_core_codegen/parse/retree/_parse.py +1143 -0
- aas_core_codegen/parse/retree/_render.py +298 -0
- aas_core_codegen/parse/retree/_stringify.py +199 -0
- aas_core_codegen/parse/retree/_types.py +362 -0
- aas_core_codegen/parse/retree/_visitor.py +70 -0
- aas_core_codegen/parse/tree.py +1303 -0
- aas_core_codegen/protobuf/__init__.py +1 -0
- aas_core_codegen/protobuf/common.py +225 -0
- aas_core_codegen/protobuf/description.py +1102 -0
- aas_core_codegen/protobuf/main.py +115 -0
- aas_core_codegen/protobuf/naming.py +143 -0
- aas_core_codegen/protobuf/structure/__init__.py +6 -0
- aas_core_codegen/protobuf/structure/_generate.py +502 -0
- aas_core_codegen/py.typed +1 -0
- aas_core_codegen/python/__init__.py +1 -0
- aas_core_codegen/python/aas_common/__init__.py +4 -0
- aas_core_codegen/python/aas_common/_generate.py +63 -0
- aas_core_codegen/python/common.py +406 -0
- aas_core_codegen/python/constants/__init__.py +5 -0
- aas_core_codegen/python/constants/_generate.py +377 -0
- aas_core_codegen/python/description.py +508 -0
- aas_core_codegen/python/jsonization/__init__.py +4 -0
- aas_core_codegen/python/jsonization/_generate.py +1391 -0
- aas_core_codegen/python/main.py +323 -0
- aas_core_codegen/python/naming.py +255 -0
- aas_core_codegen/python/stringification/__init__.py +4 -0
- aas_core_codegen/python/stringification/_generate.py +129 -0
- aas_core_codegen/python/structure/__init__.py +6 -0
- aas_core_codegen/python/structure/_generate.py +1801 -0
- aas_core_codegen/python/transpilation.py +958 -0
- aas_core_codegen/python/unrolling.py +156 -0
- aas_core_codegen/python/verification/__init__.py +6 -0
- aas_core_codegen/python/verification/_generate.py +1471 -0
- aas_core_codegen/python/xmlization/__init__.py +4 -0
- aas_core_codegen/python/xmlization/_generate.py +3003 -0
- aas_core_codegen/python_protobuf/__init__.py +1 -0
- aas_core_codegen/python_protobuf/main.py +1424 -0
- aas_core_codegen/python_protobuf/naming.py +85 -0
- aas_core_codegen/rdf_shacl/__init__.py +1 -0
- aas_core_codegen/rdf_shacl/_description.py +351 -0
- aas_core_codegen/rdf_shacl/common.py +206 -0
- aas_core_codegen/rdf_shacl/main.py +114 -0
- aas_core_codegen/rdf_shacl/naming.py +145 -0
- aas_core_codegen/rdf_shacl/rdf.py +435 -0
- aas_core_codegen/rdf_shacl/shacl.py +453 -0
- aas_core_codegen/run.py +124 -0
- aas_core_codegen/smoke/__init__.py +1 -0
- aas_core_codegen/smoke/main.py +219 -0
- aas_core_codegen/specific_implementations.py +72 -0
- aas_core_codegen/stringify.py +333 -0
- aas_core_codegen/typescript/__init__.py +1 -0
- aas_core_codegen/typescript/aas_common/__init__.py +4 -0
- aas_core_codegen/typescript/aas_common/_generate.py +472 -0
- aas_core_codegen/typescript/common.py +340 -0
- aas_core_codegen/typescript/constants/__init__.py +5 -0
- aas_core_codegen/typescript/constants/_generate.py +347 -0
- aas_core_codegen/typescript/description.py +530 -0
- aas_core_codegen/typescript/jsonization/__init__.py +4 -0
- aas_core_codegen/typescript/jsonization/_generate.py +1510 -0
- aas_core_codegen/typescript/main.py +258 -0
- aas_core_codegen/typescript/naming.py +189 -0
- aas_core_codegen/typescript/stringification/__init__.py +4 -0
- aas_core_codegen/typescript/stringification/_generate.py +367 -0
- aas_core_codegen/typescript/structure/__init__.py +6 -0
- aas_core_codegen/typescript/structure/_generate.py +2500 -0
- aas_core_codegen/typescript/transpilation.py +1051 -0
- aas_core_codegen/typescript/unrolling.py +159 -0
- aas_core_codegen/typescript/verification/__init__.py +6 -0
- aas_core_codegen/typescript/verification/_generate.py +1578 -0
- aas_core_codegen/xsd/__init__.py +1 -0
- aas_core_codegen/xsd/main.py +1187 -0
- aas_core_codegen/xsd/naming.py +83 -0
- aas_core_codegen/yielding/__init__.py +1 -0
- aas_core_codegen/yielding/flow.py +139 -0
- aas_core_codegen/yielding/linear.py +754 -0
- aas_core_codegen-0.0.16.dist-info/METADATA +211 -0
- aas_core_codegen-0.0.16.dist-info/RECORD +604 -0
- aas_core_codegen-0.0.16.dist-info/WHEEL +5 -0
- aas_core_codegen-0.0.16.dist-info/entry_points.txt +3 -0
- aas_core_codegen-0.0.16.dist-info/licenses/AUTHORS +9 -0
- aas_core_codegen-0.0.16.dist-info/licenses/LICENSE +23 -0
- aas_core_codegen-0.0.16.dist-info/top_level.txt +2 -0
- dev/continuous_integration/__init__.py +1 -0
- dev/continuous_integration/check_help_in_readme.py +208 -0
- dev/continuous_integration/check_init_and_pyproject_consistent.py +154 -0
- dev/continuous_integration/precommit.py +400 -0
- dev/dev_scripts/__init__.py +1 -0
- dev/dev_scripts/compare_rendered_regexes_against_source_py.py +42 -0
- dev/dev_scripts/copy_to_aas_core3_cpp.py +100 -0
- dev/dev_scripts/copy_to_aas_core3_java.py +90 -0
- dev/dev_scripts/download_latest_aas_core_meta_v3.py +114 -0
- dev/dev_scripts/draw_bipartite_graph_based_on_lines.py +37 -0
- dev/dev_scripts/run_tests_with_rerecord.py +69 -0
- dev/dev_scripts/update_to_aas_core_meta.py +174 -0
- dev/integration_tests/input/jsonschema/boilerplate/main.py +55 -0
- dev/integration_tests/input/meta_model.py +38 -0
- dev/integration_tests/input/python/boilerplate/main.py +153 -0
- dev/integration_tests/main.py +258 -0
- dev/test_data/csharp/test_structure/concrete_class_with_descendants/meta_model.py +15 -0
- dev/test_data/csharp/test_structure/constructor_without_arguments/all_properties_optional/meta_model.py +9 -0
- dev/test_data/csharp/test_structure/constructor_without_arguments/no_properties/meta_model.py +6 -0
- dev/test_data/csharp/test_verification/builtin_functions/len/on_list/meta_model.py +20 -0
- dev/test_data/csharp/test_verification/builtin_functions/len/on_str/meta_model.py +16 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_prefix/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_suffix/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_group_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_the_middle/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_union/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/single_utf32_literal/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_within_group/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_without_group/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_beginning/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_end/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/in_the_middle/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/multiple/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/mixed_with_non_utf32/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/more_than_two_high_surrogates/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges_mixed_with_non_utf32/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/two_high_surrogates/meta_model.py +8 -0
- dev/test_data/intermediate/expected/class/empty/meta_model.py +6 -0
- dev/test_data/intermediate/expected/class/implementation_specific_method/meta_model.py +8 -0
- dev/test_data/intermediate/expected/class/inheritance/meta_model.py +41 -0
- dev/test_data/intermediate/expected/class/methods_with_contracts/meta_model.py +15 -0
- dev/test_data/intermediate/expected/class/only_method_no_property/meta_model.py +7 -0
- dev/test_data/intermediate/expected/class/only_property_no_method/meta_model.py +9 -0
- dev/test_data/intermediate/expected/constant/constant_set/of_enum/meta_model.py +12 -0
- dev/test_data/intermediate/expected/constant/constant_set/of_str/meta_model.py +4 -0
- dev/test_data/intermediate/expected/constant/constant_set/with_description/meta_model.py +6 -0
- dev/test_data/intermediate/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
- dev/test_data/intermediate/expected/constant/constant_str/only_value/meta_model.py +7 -0
- dev/test_data/intermediate/expected/constant/constant_str/with_description/meta_model.py +5 -0
- dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_in_literal/meta_model.py +20 -0
- dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_outside_literal/meta_model.py +20 -0
- dev/test_data/intermediate/expected/empty/meta_model.py +2 -0
- dev/test_data/intermediate/expected/enumeration/meta_model.py +9 -0
- dev/test_data/intermediate/expected/interface/basic/meta_model.py +14 -0
- dev/test_data/intermediate/expected/interface/empty/meta_model.py +7 -0
- dev/test_data/intermediate/expected/interface/inheritance/meta_model.py +27 -0
- dev/test_data/intermediate/expected/interface/method_signature/meta_model.py +10 -0
- dev/test_data/intermediate/expected/interface/only_constructor/meta_model.py +11 -0
- dev/test_data/intermediate/expected/method/non_mutating/implementation_specific/meta_model.py +12 -0
- dev/test_data/intermediate/expected/method/non_mutating/understood/meta_model.py +11 -0
- dev/test_data/intermediate/expected/type_annotation/atomic/meta_model.py +9 -0
- dev/test_data/intermediate/expected/type_annotation/subscripted/class/meta_model.py +13 -0
- dev/test_data/intermediate/expected/type_annotation/subscripted/primitive/meta_model.py +9 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/enumeration_literals_in_subset_outside_of_superset/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/invalid_literal/meta_model.py +11 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_between_enumeration_and_literal/meta_model.py +30 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_in_enumerations_between_subset_and_superset/meta_model.py +21 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/literals_in_subset_outside_of_superset/meta_model.py +18 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/mismatch_between_type_annotation_and_literals/meta_model.py +10 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/superset_and_subset_mismatch_in_type/meta_model.py +12 -0
- dev/test_data/intermediate/unexpected/constraints/dangling_constraintref/meta_model.py +18 -0
- dev/test_data/intermediate/unexpected/constraints/duplicate_constraints/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/documentation/unexpected_documentation_elements/meta_model.py +34 -0
- dev/test_data/intermediate/unexpected/invariant/class_invariant_uses_re/meta_model.py +10 -0
- dev/test_data/intermediate/unexpected/invariant/invariant_of_constrained_primitive_uses_re/meta_model.py +7 -0
- dev/test_data/intermediate/unexpected/invariant/unexpected_argument_count_to_len/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/invariant/unhandled_built_in_function/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/meta_model.py +7 -0
- dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/default_non_none/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/no_default/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/after_inheritance/meta_model.py +58 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/type_missmatch/meta_model.py +9 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/within_class/meta_model.py +22 -0
- dev/test_data/jsonschema/test_main/regression_when_len_constraints_on_inherited_property/meta_model.py +28 -0
- dev/test_data/opcua/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/opcua/test_main/classes_with_invariants/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_descendant/meta_model.py +27 -0
- dev/test_data/opcua/test_main/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_list_of_instances/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/opcua/test_main/concrete_class_with_string/meta_model.py +13 -0
- dev/test_data/opcua/test_main/constrained_primitive/meta_model.py +20 -0
- dev/test_data/opcua/test_main/multiple_inheritance/meta_model.py +25 -0
- dev/test_data/parse/expected/constant/constant_set/of_enum/meta_model.py +12 -0
- dev/test_data/parse/expected/constant/constant_set/of_str/meta_model.py +4 -0
- dev/test_data/parse/expected/constant/constant_set/with_description/meta_model.py +6 -0
- dev/test_data/parse/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
- dev/test_data/parse/expected/constant/constant_str/only_value/meta_model.py +7 -0
- dev/test_data/parse/expected/constant/constant_str/with_description/meta_model.py +5 -0
- dev/test_data/parse/expected/enum/ok/meta_model.py +15 -0
- dev/test_data/parse/expected/implementation_specific_class/properties_and_methods_in_implementation_specific_class/meta_model.py +17 -0
- dev/test_data/parse/expected/inheritance/basic/meta_model.py +11 -0
- dev/test_data/parse/expected/inheritance/diamond/meta_model.py +26 -0
- dev/test_data/parse/expected/inheritance/inheritance_from_concrete_class/meta_model.py +10 -0
- dev/test_data/parse/expected/invariants/in_relation/meta_model.py +16 -0
- dev/test_data/parse/expected/method/arguments/meta_model.py +7 -0
- dev/test_data/parse/expected/method/basic/meta_model.py +7 -0
- dev/test_data/parse/expected/method/contracts/condition_as_keyword_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/condition_as_positional_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/description_as_keyword_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/description_as_positional_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/multiple_contracts_in_order/meta_model.py +17 -0
- dev/test_data/parse/expected/method/contracts/postcondition/basic/meta_model.py +10 -0
- dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_keyword_arguments/meta_model.py +9 -0
- dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_positional_arguments/meta_model.py +9 -0
- dev/test_data/parse/expected/method/default/meta_model.py +9 -0
- dev/test_data/parse/expected/method/description/meta_model.py +8 -0
- dev/test_data/parse/expected/method/is_implementation_specific/meta_model.py +8 -0
- dev/test_data/parse/expected/method/non_mutating/meta_model.py +11 -0
- dev/test_data/parse/expected/method/returns_none/meta_model.py +7 -0
- dev/test_data/parse/expected/method/returns_something/meta_model.py +7 -0
- dev/test_data/parse/expected/single_class/description/meta_model.py +12 -0
- dev/test_data/parse/expected/single_class/empty/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/description/meta_model.py +14 -0
- dev/test_data/parse/expected/single_class/property/mandatory/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/optional/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/recursion_to_entity/meta_model.py +6 -0
- dev/test_data/parse/unexpected/class_decorators/non_name_decorator/meta_model.py +7 -0
- dev/test_data/parse/unexpected/class_decorators/unknown_decorator/meta_model.py +7 -0
- dev/test_data/parse/unexpected/class_definitions/is_abstract_and_implementation_specific/meta_model.py +8 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_before_a_method/meta_model.py +11 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_for_a_pass/meta_model.py +9 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_double_description_for_a_property/meta_model.py +10 -0
- dev/test_data/parse/unexpected/class_inheritances/inheriting_from_implementation_specific_parent/meta_model.py +20 -0
- dev/test_data/parse/unexpected/class_inheritances/non_name_super_class/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/expression_as_assignment_value/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/non_assignment/meta_model.py +8 -0
- dev/test_data/parse/unexpected/enum/non_string_literal/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/unexpected_inheritance/meta_model.py +6 -0
- dev/test_data/parse/unexpected/method_contracts/contract/non_lambda_condition/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/non_string_literal_description/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/without_any_arguments/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/without_condition/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/postcondition/OLD_in_postcondition_without_snapshot/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/postcondition/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/precondition/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/capture_not_a_lambda/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/invalid_name/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/name_not_a_string_literal/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_capture/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_name/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_constructor/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_verification_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_name_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/unknown_call_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/unknown_name_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_definitions/argument_with_final/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/argument_without_a_type_annotation/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/default_for_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/dunder/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/init_with_return_type/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_keyword_only_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_positional_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_type_annotation_for_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_variable_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_variable_keyword_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_type_annotation_for_result/meta_model.py +7 -0
- dev/test_data/parse/unexpected/property_definitions/final_without_subscript/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/nested_final/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/non_simple/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/unexpected_assignment/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/unexpected_non_name_property/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/without_type_annotation/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/constant_set_with_a_non_set_subset/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_inheritance/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_a_property/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_an_argument/meta_model.py +7 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_constant_set/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_subset_in_constant_set/meta_model.py +4 -0
- dev/test_data/parse/unexpected/symbol_table/inheritance_from_non_class/meta_model.py +10 -0
- dev/test_data/parse_retree/expected/character_set/common_escaping/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/double_caret/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/multiple_ranges/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/suffix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/escape_first_caret/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/literals_which_need_no_escaping_in_characters_set_but_need_escaping_outside/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/multiple_ranges/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/single_literal/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/single_range/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/only_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/prefix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/suffix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/dot/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group_in_a_group/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group_of_union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/regex/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/expected/escaped_literals/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/at_the_beginning/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/at_the_end/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/single_formatted_value/source.py +1 -0
- dev/test_data/parse_retree/expected/literal/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_least_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_least_one/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_most_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/exactly_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/maybe/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/zero_or_more/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_one/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_most_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/exactly_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/maybe/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/zero_or_more/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_character_set/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_formatted_value/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_group/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_literal/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/double_end_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/double_start_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/end_symbol_in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/only_start_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/only_stop_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_at_the_beginning/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/stop_symbol_at_the_end/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_character_sets/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_groups/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_string_literals/source.py +1 -0
- dev/test_data/parse_retree/expected/union/within_group/source.py +1 -0
- dev/test_data/parse_retree/expected/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/Uxxxxxxxx_out_of_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/only_backslash/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_Uxxxxxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_uxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unexpected_escaping/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/Uxxxxxxxx_out_of_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/only_backslash/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_Uxxxxxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_uxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unexpected_escaping/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_character_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/at_least_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/between_3_and_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/exactly_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unhandled_group_directives/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/character_set/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/group/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/group_of_union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_comma/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_number_and_comma/source.py +1 -0
- dev/test_data/proto/test_main/expected/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_descendants/meta_model.py +30 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_list_of_instances/meta_model.py +21 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/expected_output/pbization.py +532 -0
- dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/expected_output/pbization.py +527 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/meta_model.py +27 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_enum/expected_output/pbization.py +290 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/expected_output/pbization.py +328 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/meta_model.py +23 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/expected_output/pbization.py +274 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/rdf_shacl/test_main/expected/regression_when_lang_string_class_is_missing/meta_model.py +29 -0
- dev/test_data/rdf_shacl/test_main/expected/regression_when_len_constraints_on_inherited_property/meta_model.py +27 -0
- dev/test_data/rdf_shacl/test_main/unexpected/regression_len_constraint_on_class_property/meta_model.py +61 -0
- dev/test_data/real_meta_models/aas_core_meta.v3.py +5721 -0
- dev/test_data/smoke/test_main/unexpected/infer_for_schema_error/meta_model.py +12 -0
- dev/test_data/smoke/test_main/unexpected/intermediate_error/meta_model.py +18 -0
- dev/test_data/smoke/test_main/unexpected/parse_error/meta_model.py +5 -0
- dev/test_data/smoke/test_main/unexpected/pattern_verification_unparsable_regex/direct_match/meta_model.py +8 -0
- dev/test_data/smoke/test_main/unexpected/type_error/meta_model.py +18 -0
- dev/tests/__init__.py +1 -0
- dev/tests/common.py +197 -0
- dev/tests/cpp/__init__.py +0 -0
- dev/tests/cpp/test_common.py +32 -0
- dev/tests/cpp/test_main.py +144 -0
- dev/tests/cpp/test_pattern.py +188 -0
- dev/tests/cpp/test_verification.py +189 -0
- dev/tests/cpp/test_yielding.py +225 -0
- dev/tests/csharp/__init__.py +0 -0
- dev/tests/csharp/live_test_main.py +109 -0
- dev/tests/csharp/test_common.py +28 -0
- dev/tests/csharp/test_description.py +684 -0
- dev/tests/csharp/test_main.py +129 -0
- dev/tests/csharp/test_structure.py +93 -0
- dev/tests/csharp/test_verification.py +82 -0
- dev/tests/description.py +29 -0
- dev/tests/golang/__init__.py +0 -0
- dev/tests/golang/test_common.py +78 -0
- dev/tests/golang/test_main.py +128 -0
- dev/tests/infer_for_schema/__init__.py +0 -0
- dev/tests/infer_for_schema/common.py +47 -0
- dev/tests/infer_for_schema/test_len_on_properties.py +955 -0
- dev/tests/infer_for_schema/test_len_on_self.py +580 -0
- dev/tests/infer_for_schema/test_patterns_on_properties.py +686 -0
- dev/tests/infer_for_schema/test_patterns_on_self.py +258 -0
- dev/tests/infer_for_schema/test_property_in_set_of_enumeration_literals.py +600 -0
- dev/tests/infer_for_schema/test_property_in_set_of_primitives.py +549 -0
- dev/tests/intermediate/__init__.py +0 -0
- dev/tests/intermediate/test_constructor.py +719 -0
- dev/tests/intermediate/test_hierarchy.py +221 -0
- dev/tests/intermediate/test_revm.py +134 -0
- dev/tests/intermediate/test_translate.py +337 -0
- dev/tests/intermediate/test_type_inference.py +333 -0
- dev/tests/intermediate/test_types.py +169 -0
- dev/tests/java/__init__.py +0 -0
- dev/tests/java/test_common.py +20 -0
- dev/tests/java/test_description.py +128 -0
- dev/tests/java/test_main.py +234 -0
- dev/tests/jsonld_context/test_main.py +79 -0
- dev/tests/opcua/__init__.py +3 -0
- dev/tests/opcua/test_main.py +110 -0
- dev/tests/our_jsonschema/__init__.py +3 -0
- dev/tests/our_jsonschema/test_main.py +232 -0
- dev/tests/parse/__init__.py +0 -0
- dev/tests/parse/test_parse.py +503 -0
- dev/tests/parse/test_retree.py +272 -0
- dev/tests/proto/__init__.py +0 -0
- dev/tests/proto/test_main.py +112 -0
- dev/tests/python/__init__.py +0 -0
- dev/tests/python/test_common.py +124 -0
- dev/tests/python/test_main.py +126 -0
- dev/tests/python/test_xml_playground.py +254 -0
- dev/tests/python_protobuf/__init__.py +0 -0
- dev/tests/python_protobuf/test_main.py +111 -0
- dev/tests/rdf_shacl/__init__.py +0 -0
- dev/tests/rdf_shacl/test_common.py +32 -0
- dev/tests/rdf_shacl/test_description.py +223 -0
- dev/tests/rdf_shacl/test_main.py +194 -0
- dev/tests/smoke/__init__.py +0 -0
- dev/tests/smoke/test_main.py +83 -0
- dev/tests/test_common.py +94 -0
- dev/tests/typescript/__init__.py +0 -0
- dev/tests/typescript/test_common.py +108 -0
- dev/tests/typescript/test_main.py +125 -0
- dev/tests/xsd/__init__.py +0 -0
- dev/tests/xsd/test_main.py +227 -0
- dev/tests/yielding/__init__.py +0 -0
- dev/tests/yielding/test_linear.py +558 -0
|
@@ -0,0 +1,1457 @@
|
|
|
1
|
+
"""Generate the invariant verifiers from the intermediate representation."""
|
|
2
|
+
import io
|
|
3
|
+
import textwrap
|
|
4
|
+
from typing import (
|
|
5
|
+
Tuple,
|
|
6
|
+
Optional,
|
|
7
|
+
List,
|
|
8
|
+
Sequence,
|
|
9
|
+
Set,
|
|
10
|
+
Mapping,
|
|
11
|
+
Union,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from icontract import ensure, require
|
|
15
|
+
|
|
16
|
+
from aas_core_codegen import intermediate, specific_implementations, naming
|
|
17
|
+
from aas_core_codegen.common import (
|
|
18
|
+
Error,
|
|
19
|
+
Stripped,
|
|
20
|
+
assert_never,
|
|
21
|
+
Identifier,
|
|
22
|
+
indent_but_first_line,
|
|
23
|
+
wrap_text_into_lines,
|
|
24
|
+
)
|
|
25
|
+
from aas_core_codegen.csharp import (
|
|
26
|
+
common as csharp_common,
|
|
27
|
+
naming as csharp_naming,
|
|
28
|
+
description as csharp_description,
|
|
29
|
+
transpilation as csharp_transpilation,
|
|
30
|
+
)
|
|
31
|
+
from aas_core_codegen.csharp.common import (
|
|
32
|
+
INDENT as I,
|
|
33
|
+
INDENT2 as II,
|
|
34
|
+
INDENT3 as III,
|
|
35
|
+
INDENT4 as IIII,
|
|
36
|
+
)
|
|
37
|
+
from aas_core_codegen.intermediate import type_inference as intermediate_type_inference
|
|
38
|
+
from aas_core_codegen.parse import tree as parse_tree, retree as parse_retree
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# region Verify
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def verify(
|
|
45
|
+
spec_impls: specific_implementations.SpecificImplementations,
|
|
46
|
+
verification_functions: Sequence[intermediate.Verification],
|
|
47
|
+
) -> Optional[List[str]]:
|
|
48
|
+
"""Verify all the implementation snippets related to verification."""
|
|
49
|
+
errors = [] # type: List[str]
|
|
50
|
+
|
|
51
|
+
expected_keys = [] # type: List[specific_implementations.ImplementationKey]
|
|
52
|
+
|
|
53
|
+
for func in verification_functions:
|
|
54
|
+
if isinstance(func, intermediate.ImplementationSpecificVerification):
|
|
55
|
+
expected_keys.append(
|
|
56
|
+
specific_implementations.ImplementationKey(
|
|
57
|
+
f"Verification/{func.name}.cs"
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
for key in expected_keys:
|
|
62
|
+
if key not in spec_impls:
|
|
63
|
+
errors.append(f"The implementation snippet is missing for: {key}")
|
|
64
|
+
|
|
65
|
+
if len(errors) == 0:
|
|
66
|
+
return None
|
|
67
|
+
|
|
68
|
+
return errors
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# endregion
|
|
72
|
+
|
|
73
|
+
# region Generate
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class _PatternVerificationTranspiler(
|
|
77
|
+
parse_tree.RestrictedTransformer[Tuple[Optional[Stripped], Optional[Error]]]
|
|
78
|
+
):
|
|
79
|
+
"""Transpile a statement of a pattern verification into C#."""
|
|
80
|
+
|
|
81
|
+
def __init__(self, defined_variables: Set[Identifier]) -> None:
|
|
82
|
+
"""
|
|
83
|
+
Initialize with the given values.
|
|
84
|
+
|
|
85
|
+
The ``defined_variables`` are shared between different statement
|
|
86
|
+
transpilations. It is also mutated when assignments are transpiled. We need to
|
|
87
|
+
keep track of variables so that we know when we have to define them, and when
|
|
88
|
+
we can simply assign them a value, if they have been already defined.
|
|
89
|
+
"""
|
|
90
|
+
self.defined_variables = defined_variables
|
|
91
|
+
|
|
92
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
93
|
+
def _transform_joined_str_values(
|
|
94
|
+
self, values: Sequence[Union[str, parse_tree.FormattedValue]]
|
|
95
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
96
|
+
"""Transform the values of a joined string to a C# string literal."""
|
|
97
|
+
if all(isinstance(value, str) for value in values):
|
|
98
|
+
return (
|
|
99
|
+
Stripped(csharp_common.string_literal("".join(values))), # type: ignore
|
|
100
|
+
None,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
needs_interpolation = False
|
|
104
|
+
|
|
105
|
+
parts = [] # type: List[str]
|
|
106
|
+
for value in values:
|
|
107
|
+
if isinstance(value, str):
|
|
108
|
+
string_literal = csharp_common.string_literal(
|
|
109
|
+
value.replace("{", "{{").replace("}", "}}")
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# We need to remove double-quotes since we are joining everything
|
|
113
|
+
# ourselves later.
|
|
114
|
+
|
|
115
|
+
assert string_literal.startswith('"') and string_literal.endswith('"')
|
|
116
|
+
|
|
117
|
+
string_literal_wo_quotes = string_literal[1:-1]
|
|
118
|
+
parts.append(string_literal_wo_quotes)
|
|
119
|
+
|
|
120
|
+
elif isinstance(value, parse_tree.FormattedValue):
|
|
121
|
+
code, error = self.transform(value.value)
|
|
122
|
+
if error is not None:
|
|
123
|
+
return None, error
|
|
124
|
+
assert code is not None
|
|
125
|
+
|
|
126
|
+
assert (
|
|
127
|
+
"\n" not in code
|
|
128
|
+
), f"New-lines are not expected in formatted values, but got: {code}"
|
|
129
|
+
|
|
130
|
+
needs_interpolation = True
|
|
131
|
+
parts.append(f"{{{code}}}")
|
|
132
|
+
else:
|
|
133
|
+
assert_never(value)
|
|
134
|
+
|
|
135
|
+
writer = io.StringIO()
|
|
136
|
+
|
|
137
|
+
if needs_interpolation:
|
|
138
|
+
writer.write('$"')
|
|
139
|
+
else:
|
|
140
|
+
writer.write('"')
|
|
141
|
+
|
|
142
|
+
for part in parts:
|
|
143
|
+
writer.write(part)
|
|
144
|
+
|
|
145
|
+
writer.write('"')
|
|
146
|
+
|
|
147
|
+
return Stripped(writer.getvalue()), None
|
|
148
|
+
|
|
149
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
150
|
+
def transform_constant(
|
|
151
|
+
self, node: parse_tree.Constant
|
|
152
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
153
|
+
if isinstance(node.value, str):
|
|
154
|
+
# NOTE (mristin, 2022-06-11):
|
|
155
|
+
# We assume that all the string constants are valid regular expressions.
|
|
156
|
+
|
|
157
|
+
regex, parse_error = parse_retree.parse(values=[node.value])
|
|
158
|
+
if parse_error is not None:
|
|
159
|
+
regex_line, pointer_line = parse_retree.render_pointer(
|
|
160
|
+
parse_error.cursor
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
None,
|
|
165
|
+
Error(
|
|
166
|
+
node.original_node,
|
|
167
|
+
f"The string constant could not be parsed "
|
|
168
|
+
f"as a regular expression: \n"
|
|
169
|
+
f"{parse_error.message}\n"
|
|
170
|
+
f"{regex_line}\n"
|
|
171
|
+
f"{pointer_line}",
|
|
172
|
+
),
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
assert regex is not None
|
|
176
|
+
parse_retree.fix_for_utf16_regex_in_place(regex)
|
|
177
|
+
|
|
178
|
+
# NOTE (mristin, 2022-06-11):
|
|
179
|
+
# Strictly speaking, this is a joined string with a single value, a string
|
|
180
|
+
# literal.
|
|
181
|
+
return self._transform_joined_str_values(
|
|
182
|
+
values=parse_retree.render(regex=regex)
|
|
183
|
+
)
|
|
184
|
+
else:
|
|
185
|
+
raise AssertionError(f"Unexpected {node=}")
|
|
186
|
+
|
|
187
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
188
|
+
def transform_name(
|
|
189
|
+
self, node: parse_tree.Name
|
|
190
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
191
|
+
return Stripped(csharp_naming.variable_name(node.identifier)), None
|
|
192
|
+
|
|
193
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
194
|
+
def transform_joined_str(
|
|
195
|
+
self, node: parse_tree.JoinedStr
|
|
196
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
197
|
+
regex, parse_error = parse_retree.parse(values=node.values)
|
|
198
|
+
if parse_error is not None:
|
|
199
|
+
regex_line, pointer_line = parse_retree.render_pointer(parse_error.cursor)
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
None,
|
|
203
|
+
Error(
|
|
204
|
+
node.original_node,
|
|
205
|
+
f"The joined string could not be parsed "
|
|
206
|
+
f"as a regular expression: \n"
|
|
207
|
+
f"{parse_error.message}\n"
|
|
208
|
+
f"{regex_line}\n"
|
|
209
|
+
f"{pointer_line}",
|
|
210
|
+
),
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
assert regex is not None
|
|
214
|
+
parse_retree.fix_for_utf16_regex_in_place(regex)
|
|
215
|
+
|
|
216
|
+
return self._transform_joined_str_values(
|
|
217
|
+
values=parse_retree.render(regex=regex)
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
def transform_assignment(
|
|
221
|
+
self, node: parse_tree.Assignment
|
|
222
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
223
|
+
assert isinstance(node.target, parse_tree.Name)
|
|
224
|
+
variable = csharp_naming.variable_name(node.target.identifier)
|
|
225
|
+
code, error = self.transform(node.value)
|
|
226
|
+
if error is not None:
|
|
227
|
+
return None, error
|
|
228
|
+
assert code is not None
|
|
229
|
+
|
|
230
|
+
if node.target.identifier in self.defined_variables:
|
|
231
|
+
return Stripped(f"{variable} = {code};"), None
|
|
232
|
+
|
|
233
|
+
else:
|
|
234
|
+
self.defined_variables.add(node.target.identifier)
|
|
235
|
+
return Stripped(f"var {variable} = {code};"), None
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
239
|
+
def _transpile_pattern_verification(
|
|
240
|
+
verification: intermediate.PatternVerification,
|
|
241
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
242
|
+
"""Generate the verification function that checks the regular expressions."""
|
|
243
|
+
# NOTE (mristin, 2021-12-19):
|
|
244
|
+
# We assume that we performed all the checks at the intermediate stage.
|
|
245
|
+
|
|
246
|
+
construct_name = csharp_naming.private_method_name(
|
|
247
|
+
Identifier(f"construct_{verification.name}")
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
blocks = [] # type: List[Stripped]
|
|
251
|
+
|
|
252
|
+
# region Construct block
|
|
253
|
+
|
|
254
|
+
writer = io.StringIO()
|
|
255
|
+
writer.write(
|
|
256
|
+
f"""\
|
|
257
|
+
[CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
258
|
+
[CodeAnalysis.SuppressMessageAttribute("ReSharper", "IdentifierTypo")]
|
|
259
|
+
[CodeAnalysis.SuppressMessage("ReSharper", "StringLiteralTypo")]
|
|
260
|
+
private static Regex {construct_name}()
|
|
261
|
+
{{
|
|
262
|
+
"""
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
defined_variables = set() # type: Set[Identifier]
|
|
266
|
+
transpiler = _PatternVerificationTranspiler(defined_variables=defined_variables)
|
|
267
|
+
|
|
268
|
+
for i, stmt in enumerate(verification.parsed.body):
|
|
269
|
+
if i == len(verification.parsed.body) - 1:
|
|
270
|
+
break
|
|
271
|
+
|
|
272
|
+
code, error = transpiler.transform(stmt)
|
|
273
|
+
if error is not None:
|
|
274
|
+
return None, error
|
|
275
|
+
assert code is not None
|
|
276
|
+
|
|
277
|
+
writer.write(textwrap.indent(code, I))
|
|
278
|
+
writer.write("\n")
|
|
279
|
+
|
|
280
|
+
if len(verification.parsed.body) >= 2:
|
|
281
|
+
writer.write("\n")
|
|
282
|
+
|
|
283
|
+
pattern_expr, error = transpiler.transform(verification.pattern_expr)
|
|
284
|
+
if error is not None:
|
|
285
|
+
return None, error
|
|
286
|
+
assert pattern_expr is not None
|
|
287
|
+
|
|
288
|
+
# A pragmatic heuristics for breaking lines
|
|
289
|
+
if len(pattern_expr) < 50:
|
|
290
|
+
writer.write(textwrap.indent(f"return new Regex({pattern_expr});\n", I))
|
|
291
|
+
else:
|
|
292
|
+
writer.write(textwrap.indent(f"return new Regex(\n{I}{pattern_expr});\n", I))
|
|
293
|
+
|
|
294
|
+
writer.write("}")
|
|
295
|
+
|
|
296
|
+
blocks.append(Stripped(writer.getvalue()))
|
|
297
|
+
|
|
298
|
+
# endregion
|
|
299
|
+
|
|
300
|
+
# region Initialize the regex
|
|
301
|
+
|
|
302
|
+
# NOTE (mristin, 2022-05-05):
|
|
303
|
+
# We make this property look "public" since it is static and read-only.
|
|
304
|
+
regex_name = csharp_naming.property_name(Identifier(f"regex_{verification.name}"))
|
|
305
|
+
|
|
306
|
+
blocks.append(
|
|
307
|
+
Stripped(f"private static readonly Regex {regex_name} = {construct_name}();")
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
assert len(verification.arguments) == 1
|
|
311
|
+
assert isinstance(
|
|
312
|
+
verification.arguments[0].type_annotation, intermediate.PrimitiveTypeAnnotation
|
|
313
|
+
)
|
|
314
|
+
# noinspection PyUnresolvedReferences
|
|
315
|
+
assert (
|
|
316
|
+
verification.arguments[0].type_annotation.a_type
|
|
317
|
+
== intermediate.PrimitiveType.STR
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
arg_name = csharp_naming.argument_name(verification.arguments[0].name)
|
|
321
|
+
|
|
322
|
+
writer = io.StringIO()
|
|
323
|
+
if verification.description is not None:
|
|
324
|
+
comment, comment_errors = csharp_description.generate_comment_for_signature(
|
|
325
|
+
verification.description
|
|
326
|
+
)
|
|
327
|
+
if comment_errors is not None:
|
|
328
|
+
return None, Error(
|
|
329
|
+
verification.description.parsed.node,
|
|
330
|
+
"Failed to generate the documentation comment",
|
|
331
|
+
comment_errors,
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
assert comment is not None
|
|
335
|
+
|
|
336
|
+
writer.write(comment)
|
|
337
|
+
writer.write("\n")
|
|
338
|
+
|
|
339
|
+
method_name = csharp_naming.method_name(verification.name)
|
|
340
|
+
|
|
341
|
+
writer.write(
|
|
342
|
+
f"""\
|
|
343
|
+
public static bool {method_name}(string {arg_name})
|
|
344
|
+
{{
|
|
345
|
+
{I}return {regex_name}.IsMatch({arg_name});
|
|
346
|
+
}}"""
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
blocks.append(Stripped(writer.getvalue()))
|
|
350
|
+
|
|
351
|
+
# endregion
|
|
352
|
+
|
|
353
|
+
writer = io.StringIO()
|
|
354
|
+
for i, block in enumerate(blocks):
|
|
355
|
+
if i > 0:
|
|
356
|
+
writer.write("\n\n")
|
|
357
|
+
|
|
358
|
+
writer.write(block)
|
|
359
|
+
|
|
360
|
+
return Stripped(writer.getvalue()), None
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
class _TranspilableVerificationTranspiler(csharp_transpilation.Transpiler):
|
|
364
|
+
"""Transpile the body of a :class:`.TranspilableVerification`."""
|
|
365
|
+
|
|
366
|
+
# fmt: off
|
|
367
|
+
@require(
|
|
368
|
+
lambda environment, verification:
|
|
369
|
+
all(
|
|
370
|
+
environment.find(arg.name) is not None
|
|
371
|
+
for arg in verification.arguments
|
|
372
|
+
),
|
|
373
|
+
"All arguments defined in the environment"
|
|
374
|
+
)
|
|
375
|
+
# fmt: on
|
|
376
|
+
def __init__(
|
|
377
|
+
self,
|
|
378
|
+
type_map: Mapping[
|
|
379
|
+
parse_tree.Node, intermediate_type_inference.TypeAnnotationUnion
|
|
380
|
+
],
|
|
381
|
+
environment: intermediate_type_inference.Environment,
|
|
382
|
+
symbol_table: intermediate.SymbolTable,
|
|
383
|
+
verification: intermediate.TranspilableVerification,
|
|
384
|
+
) -> None:
|
|
385
|
+
"""Initialize with the given values."""
|
|
386
|
+
csharp_transpilation.Transpiler.__init__(
|
|
387
|
+
self, type_map=type_map, environment=environment
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
self._symbol_table = symbol_table
|
|
391
|
+
|
|
392
|
+
self._argument_name_set = frozenset(arg.name for arg in verification.arguments)
|
|
393
|
+
|
|
394
|
+
def transform_name(
|
|
395
|
+
self, node: parse_tree.Name
|
|
396
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
397
|
+
if node.identifier in self._variable_name_set:
|
|
398
|
+
return Stripped(csharp_naming.variable_name(node.identifier)), None
|
|
399
|
+
|
|
400
|
+
if node.identifier in self._argument_name_set:
|
|
401
|
+
return Stripped(csharp_naming.variable_name(node.identifier)), None
|
|
402
|
+
|
|
403
|
+
if node.identifier in self._symbol_table.constants_by_name:
|
|
404
|
+
constant_as_prop = csharp_naming.property_name(node.identifier)
|
|
405
|
+
return Stripped(f"Aas.Constants.{constant_as_prop}"), None
|
|
406
|
+
|
|
407
|
+
if node.identifier in self._symbol_table.verification_functions_by_name:
|
|
408
|
+
return Stripped(csharp_naming.method_name(node.identifier)), None
|
|
409
|
+
|
|
410
|
+
our_type = self._symbol_table.find_our_type(name=node.identifier)
|
|
411
|
+
if isinstance(our_type, intermediate.Enumeration):
|
|
412
|
+
return Stripped(csharp_naming.enum_name(node.identifier)), None
|
|
413
|
+
|
|
414
|
+
return None, Error(
|
|
415
|
+
node.original_node,
|
|
416
|
+
f"We can not determine how to transpile the name {node.identifier!r} "
|
|
417
|
+
f"to C#. We could not find it neither in the constants, nor in "
|
|
418
|
+
f"verification functions, nor as an enumeration. "
|
|
419
|
+
f"If you expect this name to be transpilable, please contact "
|
|
420
|
+
f"the developers.",
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def _transpile_transpilable_verification(
|
|
425
|
+
verification: intermediate.TranspilableVerification,
|
|
426
|
+
symbol_table: intermediate.SymbolTable,
|
|
427
|
+
environment: intermediate_type_inference.Environment,
|
|
428
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
429
|
+
"""Transpile a verification function."""
|
|
430
|
+
# fmt: off
|
|
431
|
+
type_inference, error = (
|
|
432
|
+
intermediate_type_inference.infer_for_verification(
|
|
433
|
+
verification=verification,
|
|
434
|
+
base_environment=environment
|
|
435
|
+
)
|
|
436
|
+
)
|
|
437
|
+
# fmt: on
|
|
438
|
+
|
|
439
|
+
if error is not None:
|
|
440
|
+
return None, error
|
|
441
|
+
|
|
442
|
+
assert type_inference is not None
|
|
443
|
+
|
|
444
|
+
transpiler = _TranspilableVerificationTranspiler(
|
|
445
|
+
type_map=type_inference.type_map,
|
|
446
|
+
environment=type_inference.environment_with_args,
|
|
447
|
+
symbol_table=symbol_table,
|
|
448
|
+
verification=verification,
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
body = [] # type: List[Stripped]
|
|
452
|
+
for node in verification.parsed.body:
|
|
453
|
+
stmt, error = transpiler.transform(node)
|
|
454
|
+
if error is not None:
|
|
455
|
+
return None, Error(
|
|
456
|
+
verification.parsed.node,
|
|
457
|
+
f"Failed to transpile the verification function {verification.name!r}",
|
|
458
|
+
[error],
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
assert stmt is not None
|
|
462
|
+
body.append(stmt)
|
|
463
|
+
|
|
464
|
+
writer = io.StringIO()
|
|
465
|
+
if verification.description is not None:
|
|
466
|
+
comment, comment_errors = csharp_description.generate_comment_for_signature(
|
|
467
|
+
verification.description
|
|
468
|
+
)
|
|
469
|
+
if comment_errors is not None:
|
|
470
|
+
return None, Error(
|
|
471
|
+
verification.description.parsed.node,
|
|
472
|
+
"Failed to generate the documentation comment",
|
|
473
|
+
comment_errors,
|
|
474
|
+
)
|
|
475
|
+
|
|
476
|
+
assert comment is not None
|
|
477
|
+
|
|
478
|
+
writer.write(comment)
|
|
479
|
+
writer.write("\n")
|
|
480
|
+
|
|
481
|
+
method_name = csharp_naming.method_name(verification.name)
|
|
482
|
+
|
|
483
|
+
if verification.returns is None:
|
|
484
|
+
return_type = "void"
|
|
485
|
+
else:
|
|
486
|
+
return_type = csharp_common.generate_type(type_annotation=verification.returns)
|
|
487
|
+
|
|
488
|
+
arg_defs = [] # type: List[Stripped]
|
|
489
|
+
for arg in verification.arguments:
|
|
490
|
+
arg_type = csharp_common.generate_type(arg.type_annotation)
|
|
491
|
+
arg_name = csharp_naming.argument_name(arg.name)
|
|
492
|
+
arg_defs.append(Stripped(f"{arg_type} {arg_name}"))
|
|
493
|
+
|
|
494
|
+
if len(arg_defs) == 0:
|
|
495
|
+
writer.write(
|
|
496
|
+
f"""\
|
|
497
|
+
public static {return_type} {method_name}()
|
|
498
|
+
{{"""
|
|
499
|
+
)
|
|
500
|
+
else:
|
|
501
|
+
writer.write(
|
|
502
|
+
f"""\
|
|
503
|
+
public static {return_type} {method_name}(
|
|
504
|
+
"""
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
for i, arg_def in enumerate(arg_defs):
|
|
508
|
+
if i > 0:
|
|
509
|
+
writer.write(",\n")
|
|
510
|
+
writer.write(textwrap.indent(arg_def, I))
|
|
511
|
+
|
|
512
|
+
writer.write("\n)\n{")
|
|
513
|
+
|
|
514
|
+
for stmt in body:
|
|
515
|
+
writer.write("\n")
|
|
516
|
+
writer.write(textwrap.indent(stmt, I))
|
|
517
|
+
|
|
518
|
+
if len(body) > 0:
|
|
519
|
+
writer.write("\n")
|
|
520
|
+
|
|
521
|
+
writer.write(f"}} // public static {return_type} {method_name}")
|
|
522
|
+
|
|
523
|
+
return Stripped(writer.getvalue()), None
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
class _InvariantTranspiler(csharp_transpilation.Transpiler):
|
|
527
|
+
def __init__(
|
|
528
|
+
self,
|
|
529
|
+
type_map: Mapping[
|
|
530
|
+
parse_tree.Node, intermediate_type_inference.TypeAnnotationUnion
|
|
531
|
+
],
|
|
532
|
+
environment: intermediate_type_inference.Environment,
|
|
533
|
+
symbol_table: intermediate.SymbolTable,
|
|
534
|
+
) -> None:
|
|
535
|
+
"""Initialize with the given values."""
|
|
536
|
+
csharp_transpilation.Transpiler.__init__(
|
|
537
|
+
self, type_map=type_map, environment=environment
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
self._symbol_table = symbol_table
|
|
541
|
+
|
|
542
|
+
def transform_name(
|
|
543
|
+
self, node: parse_tree.Name
|
|
544
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
545
|
+
if node.identifier in self._variable_name_set:
|
|
546
|
+
return Stripped(csharp_naming.variable_name(node.identifier)), None
|
|
547
|
+
|
|
548
|
+
if node.identifier == "self":
|
|
549
|
+
# The ``that`` refers to the argument of the verification function.
|
|
550
|
+
return Stripped("that"), None
|
|
551
|
+
|
|
552
|
+
if node.identifier in self._symbol_table.constants_by_name:
|
|
553
|
+
constant_as_prop = csharp_naming.property_name(node.identifier)
|
|
554
|
+
return Stripped(f"Aas.Constants.{constant_as_prop}"), None
|
|
555
|
+
|
|
556
|
+
if node.identifier in self._symbol_table.verification_functions_by_name:
|
|
557
|
+
return Stripped(csharp_naming.method_name(node.identifier)), None
|
|
558
|
+
|
|
559
|
+
our_type = self._symbol_table.find_our_type(name=node.identifier)
|
|
560
|
+
if isinstance(our_type, intermediate.Enumeration):
|
|
561
|
+
return Stripped(csharp_naming.enum_name(node.identifier)), None
|
|
562
|
+
|
|
563
|
+
return None, Error(
|
|
564
|
+
node.original_node,
|
|
565
|
+
f"We can not determine how to transpile the name {node.identifier!r} "
|
|
566
|
+
f"to C#. We could not find it "
|
|
567
|
+
f"neither in the local variables, "
|
|
568
|
+
f"nor in the global constants, "
|
|
569
|
+
f"nor in verification functions, "
|
|
570
|
+
f"nor as an enumeration. "
|
|
571
|
+
f"If you expect this name to be transpilable, please contact "
|
|
572
|
+
f"the developers.",
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
577
|
+
def _transpile_invariant(
|
|
578
|
+
invariant: intermediate.Invariant,
|
|
579
|
+
symbol_table: intermediate.SymbolTable,
|
|
580
|
+
environment: intermediate_type_inference.Environment,
|
|
581
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
582
|
+
"""Translate the invariant from the meta-model into C# code."""
|
|
583
|
+
# fmt: off
|
|
584
|
+
type_map, inference_error = (
|
|
585
|
+
intermediate_type_inference.infer_for_invariant(
|
|
586
|
+
invariant=invariant,
|
|
587
|
+
environment=environment
|
|
588
|
+
)
|
|
589
|
+
)
|
|
590
|
+
# fmt: on
|
|
591
|
+
|
|
592
|
+
if inference_error is not None:
|
|
593
|
+
return None, inference_error
|
|
594
|
+
|
|
595
|
+
assert type_map is not None
|
|
596
|
+
|
|
597
|
+
transpiler = _InvariantTranspiler(
|
|
598
|
+
type_map=type_map,
|
|
599
|
+
environment=environment,
|
|
600
|
+
symbol_table=symbol_table,
|
|
601
|
+
)
|
|
602
|
+
|
|
603
|
+
expr, error = transpiler.transform(invariant.parsed.body)
|
|
604
|
+
if error is not None:
|
|
605
|
+
return None, error
|
|
606
|
+
|
|
607
|
+
assert expr is not None
|
|
608
|
+
|
|
609
|
+
writer = io.StringIO()
|
|
610
|
+
if len(expr) > 50 or "\n" in expr:
|
|
611
|
+
writer.write("if (!(\n")
|
|
612
|
+
writer.write(textwrap.indent(expr, I))
|
|
613
|
+
writer.write("))\n{\n")
|
|
614
|
+
else:
|
|
615
|
+
no_parenthesis_type_in_this_context = (
|
|
616
|
+
parse_tree.Name,
|
|
617
|
+
parse_tree.Member,
|
|
618
|
+
parse_tree.MethodCall,
|
|
619
|
+
parse_tree.FunctionCall,
|
|
620
|
+
)
|
|
621
|
+
|
|
622
|
+
if isinstance(invariant.parsed.body, no_parenthesis_type_in_this_context):
|
|
623
|
+
not_expr = f"!{expr}"
|
|
624
|
+
else:
|
|
625
|
+
not_expr = f"!({expr})"
|
|
626
|
+
|
|
627
|
+
writer.write(f"if ({not_expr})\n{{\n")
|
|
628
|
+
|
|
629
|
+
writer.write(
|
|
630
|
+
textwrap.indent(
|
|
631
|
+
f"""\
|
|
632
|
+
yield return new Reporting.Error(
|
|
633
|
+
{I}"Invariant violated:\\n" +
|
|
634
|
+
""",
|
|
635
|
+
I,
|
|
636
|
+
)
|
|
637
|
+
)
|
|
638
|
+
|
|
639
|
+
# NOTE (mristin, 2022-04-08):
|
|
640
|
+
# We need to wrap the description in multiple literals as a single long
|
|
641
|
+
# string literal is often too much for the readability.
|
|
642
|
+
invariant_description_lines = wrap_text_into_lines(invariant.description)
|
|
643
|
+
|
|
644
|
+
for i, literal in enumerate(invariant_description_lines):
|
|
645
|
+
if i < len(invariant_description_lines) - 1:
|
|
646
|
+
writer.write(f"{II}{csharp_common.string_literal(literal)} +\n")
|
|
647
|
+
else:
|
|
648
|
+
writer.write(f"{II}{csharp_common.string_literal(literal)});")
|
|
649
|
+
|
|
650
|
+
writer.write("\n}")
|
|
651
|
+
|
|
652
|
+
return Stripped(writer.getvalue()), None
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
def _generate_enum_value_sets(symbol_table: intermediate.SymbolTable) -> Stripped:
|
|
656
|
+
"""Generate a class that pre-computes the sets of allowed enumeration literals."""
|
|
657
|
+
blocks = [] # type: List[Stripped]
|
|
658
|
+
|
|
659
|
+
for enum in symbol_table.enumerations:
|
|
660
|
+
enum_name = csharp_naming.enum_name(enum.name)
|
|
661
|
+
|
|
662
|
+
if len(enum.literals) == 0:
|
|
663
|
+
blocks.append(
|
|
664
|
+
Stripped(
|
|
665
|
+
f"""\
|
|
666
|
+
internal static readonly HashSet<int> For{enum_name} = new HashSet<int>();"""
|
|
667
|
+
)
|
|
668
|
+
)
|
|
669
|
+
else:
|
|
670
|
+
hash_set_writer = io.StringIO()
|
|
671
|
+
hash_set_writer.write(
|
|
672
|
+
f"""\
|
|
673
|
+
internal static readonly HashSet<int> For{enum_name} = new HashSet<int>\n{{\n
|
|
674
|
+
"""
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
for i, literal in enumerate(enum.literals):
|
|
678
|
+
literal_name = csharp_naming.enum_literal_name(literal.name)
|
|
679
|
+
hash_set_writer.write(f"{I}(int)Aas.{enum_name}.{literal_name}")
|
|
680
|
+
if i < len(enum.literals) - 1:
|
|
681
|
+
hash_set_writer.write(",\n")
|
|
682
|
+
else:
|
|
683
|
+
hash_set_writer.write("\n")
|
|
684
|
+
|
|
685
|
+
hash_set_writer.write("};")
|
|
686
|
+
|
|
687
|
+
blocks.append(Stripped(hash_set_writer.getvalue()))
|
|
688
|
+
|
|
689
|
+
writer = io.StringIO()
|
|
690
|
+
writer.write(
|
|
691
|
+
"""\
|
|
692
|
+
/// <summary>
|
|
693
|
+
/// Hash allowed enum values for efficient validation of enums.
|
|
694
|
+
/// </summary>
|
|
695
|
+
internal static class EnumValueSet
|
|
696
|
+
{
|
|
697
|
+
"""
|
|
698
|
+
)
|
|
699
|
+
for i, block in enumerate(blocks):
|
|
700
|
+
if i > 0:
|
|
701
|
+
writer.write("\n\n")
|
|
702
|
+
|
|
703
|
+
writer.write(textwrap.indent(block, I))
|
|
704
|
+
|
|
705
|
+
writer.write("\n} // internal static class EnumValueSet")
|
|
706
|
+
|
|
707
|
+
return Stripped(writer.getvalue())
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
def _generate_verify_method(our_type: intermediate.OurType) -> Stripped:
|
|
711
|
+
"""Generate the name of the ``Verification.Verify*`` method."""
|
|
712
|
+
if isinstance(our_type, intermediate.Enumeration):
|
|
713
|
+
name = csharp_naming.enum_name(our_type.name)
|
|
714
|
+
return Stripped(f"Verification.Verify{name}")
|
|
715
|
+
|
|
716
|
+
elif isinstance(our_type, intermediate.ConstrainedPrimitive):
|
|
717
|
+
name = csharp_naming.class_name(our_type.name)
|
|
718
|
+
return Stripped(f"Verification.Verify{name}")
|
|
719
|
+
|
|
720
|
+
elif isinstance(our_type, (intermediate.AbstractClass, intermediate.ConcreteClass)):
|
|
721
|
+
return Stripped("Verification.Verify")
|
|
722
|
+
else:
|
|
723
|
+
assert_never(our_type)
|
|
724
|
+
|
|
725
|
+
raise AssertionError("Unexpected execution path")
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
729
|
+
def _generate_transform_property(
|
|
730
|
+
prop: intermediate.Property,
|
|
731
|
+
) -> Tuple[Optional[Stripped], Optional[Error]]:
|
|
732
|
+
"""Generate the snippet to transform a property to errors."""
|
|
733
|
+
# NOTE (mristin, 2022-03-10):
|
|
734
|
+
# Instead of writing here a complex but general solution with unrolling we choose
|
|
735
|
+
# to provide a simple, but limited, solution. First, the meta-model is quite
|
|
736
|
+
# limited itself at the moment, so the complexity of the general solution is not
|
|
737
|
+
# warranted. Second, we hope that there will be fewer bugs in the simple solution
|
|
738
|
+
# which is particularly important at this early adoption stage.
|
|
739
|
+
#
|
|
740
|
+
# We anticipate that in the future we will indeed need a general and complex
|
|
741
|
+
# solution. Here are just some thoughts on how to approach it:
|
|
742
|
+
# * Leave the pattern matching to produce more readable code for simple cases,
|
|
743
|
+
# * Unroll only in case of composite types and optional composite types.
|
|
744
|
+
|
|
745
|
+
type_anno = (
|
|
746
|
+
prop.type_annotation
|
|
747
|
+
if not isinstance(prop.type_annotation, intermediate.OptionalTypeAnnotation)
|
|
748
|
+
else prop.type_annotation.value
|
|
749
|
+
)
|
|
750
|
+
|
|
751
|
+
if isinstance(type_anno, intermediate.OptionalTypeAnnotation):
|
|
752
|
+
return None, Error(
|
|
753
|
+
prop.parsed.node,
|
|
754
|
+
"We currently implemented verification based on a very limited "
|
|
755
|
+
"pattern matching due to code simplicity. We did not handle "
|
|
756
|
+
"the case of nested optional values. Please contact "
|
|
757
|
+
"the developers if you need this functionality.",
|
|
758
|
+
)
|
|
759
|
+
elif isinstance(type_anno, intermediate.ListTypeAnnotation):
|
|
760
|
+
if isinstance(type_anno.items, intermediate.OptionalTypeAnnotation):
|
|
761
|
+
return None, Error(
|
|
762
|
+
prop.parsed.node,
|
|
763
|
+
"We currently implemented verification based on a very limited "
|
|
764
|
+
"pattern matching due to code simplicity. We did not handle "
|
|
765
|
+
"the case of lists of optional values. Please contact "
|
|
766
|
+
"the developers if you need this functionality.",
|
|
767
|
+
)
|
|
768
|
+
elif isinstance(type_anno.items, intermediate.ListTypeAnnotation):
|
|
769
|
+
return None, Error(
|
|
770
|
+
prop.parsed.node,
|
|
771
|
+
"We currently implemented verification based on a very limited "
|
|
772
|
+
"pattern matching due to code simplicity. We did not handle "
|
|
773
|
+
"the case of lists of lists. Please contact "
|
|
774
|
+
"the developers if you need this functionality.",
|
|
775
|
+
)
|
|
776
|
+
else:
|
|
777
|
+
pass
|
|
778
|
+
else:
|
|
779
|
+
pass
|
|
780
|
+
|
|
781
|
+
stmts = [] # type: List[Stripped]
|
|
782
|
+
|
|
783
|
+
prop_name = csharp_naming.property_name(prop.name)
|
|
784
|
+
prop_literal = csharp_common.string_literal(naming.json_property(prop.name))
|
|
785
|
+
|
|
786
|
+
# NOTE (mristin, 2022-03-12):
|
|
787
|
+
# For some unexplainable reason, C# compiler can not infer that properties which
|
|
788
|
+
# are enumerations are not null after an ``if (that.someProperty != null)``.
|
|
789
|
+
# Hence, we need to add a null-coalescing for these particular cases.
|
|
790
|
+
# Otherwise, we can just stick to ``that.someProperty``.
|
|
791
|
+
|
|
792
|
+
needs_null_coalescing = (
|
|
793
|
+
isinstance(prop.type_annotation, intermediate.OptionalTypeAnnotation)
|
|
794
|
+
and isinstance(prop.type_annotation.value, intermediate.OurTypeAnnotation)
|
|
795
|
+
and isinstance(prop.type_annotation.value.our_type, intermediate.Enumeration)
|
|
796
|
+
)
|
|
797
|
+
if needs_null_coalescing:
|
|
798
|
+
source_expr = Stripped("value")
|
|
799
|
+
else:
|
|
800
|
+
source_expr = Stripped(f"that.{prop_name}")
|
|
801
|
+
|
|
802
|
+
if isinstance(type_anno, intermediate.PrimitiveTypeAnnotation):
|
|
803
|
+
# There is nothing that we check for primitive types.
|
|
804
|
+
return Stripped(""), None
|
|
805
|
+
elif isinstance(type_anno, intermediate.OurTypeAnnotation):
|
|
806
|
+
verify_method = _generate_verify_method(our_type=type_anno.our_type)
|
|
807
|
+
|
|
808
|
+
foreach_error_in_verify = (
|
|
809
|
+
f"foreach (var error in {verify_method}({source_expr}))"
|
|
810
|
+
)
|
|
811
|
+
# Heuristic to break the lines, very rudimentary
|
|
812
|
+
if len(foreach_error_in_verify) > 80:
|
|
813
|
+
foreach_error_in_verify = textwrap.dedent(
|
|
814
|
+
f"""\
|
|
815
|
+
foreach (
|
|
816
|
+
{I}var error in {verify_method}(
|
|
817
|
+
{II}{source_expr}))"""
|
|
818
|
+
)
|
|
819
|
+
|
|
820
|
+
# We can't use textwrap.dedent due to foreach_snippet.
|
|
821
|
+
stmts.append(
|
|
822
|
+
Stripped(
|
|
823
|
+
f"""\
|
|
824
|
+
{foreach_error_in_verify}
|
|
825
|
+
{{
|
|
826
|
+
{I}error.PrependSegment(
|
|
827
|
+
{II}new Reporting.NameSegment(
|
|
828
|
+
{III}{prop_literal}));
|
|
829
|
+
{I}yield return error;
|
|
830
|
+
}}"""
|
|
831
|
+
)
|
|
832
|
+
)
|
|
833
|
+
|
|
834
|
+
elif isinstance(type_anno, intermediate.ListTypeAnnotation):
|
|
835
|
+
assert not isinstance(
|
|
836
|
+
type_anno.items,
|
|
837
|
+
(intermediate.OptionalTypeAnnotation, intermediate.ListTypeAnnotation),
|
|
838
|
+
), (
|
|
839
|
+
"We chose to implement only a very limited pattern matching; "
|
|
840
|
+
"see the note above in the code."
|
|
841
|
+
)
|
|
842
|
+
|
|
843
|
+
# NOTE (mristin, 2022-03-16):
|
|
844
|
+
# We only descend into our classes here.
|
|
845
|
+
if not isinstance(type_anno.items, intermediate.OurTypeAnnotation):
|
|
846
|
+
return Stripped(""), None
|
|
847
|
+
|
|
848
|
+
index_var = csharp_naming.variable_name(Identifier(f"index_{prop.name}"))
|
|
849
|
+
verify_method = _generate_verify_method(type_anno.items.our_type)
|
|
850
|
+
|
|
851
|
+
foreach_item_in_source_expr = f"foreach (var item in {source_expr})"
|
|
852
|
+
# Rudimentary heuristics for line breaking
|
|
853
|
+
if len(foreach_item_in_source_expr) > 80:
|
|
854
|
+
foreach_item_in_source_expr = textwrap.dedent(
|
|
855
|
+
f"""\
|
|
856
|
+
foreach(
|
|
857
|
+
{I}var item in {source_expr})"""
|
|
858
|
+
)
|
|
859
|
+
|
|
860
|
+
foreach_error_in_verify_item = f"foreach (var error in {verify_method}(item))"
|
|
861
|
+
if len(foreach_error_in_verify_item) > 70:
|
|
862
|
+
foreach_error_in_verify_item = textwrap.dedent(
|
|
863
|
+
f"""\
|
|
864
|
+
foreach (
|
|
865
|
+
{I}var error in {verify_method}(item))"""
|
|
866
|
+
)
|
|
867
|
+
|
|
868
|
+
stmts.append(
|
|
869
|
+
Stripped(
|
|
870
|
+
f"""\
|
|
871
|
+
int {index_var} = 0;
|
|
872
|
+
{foreach_item_in_source_expr}
|
|
873
|
+
{{
|
|
874
|
+
{I}{indent_but_first_line(foreach_error_in_verify_item, I)}
|
|
875
|
+
{I}{{
|
|
876
|
+
{II}error.PrependSegment(
|
|
877
|
+
{III}new Reporting.IndexSegment(
|
|
878
|
+
{IIII}{index_var}));
|
|
879
|
+
{II}error.PrependSegment(
|
|
880
|
+
{III}new Reporting.NameSegment(
|
|
881
|
+
{IIII}{prop_literal}));
|
|
882
|
+
{II}yield return error;
|
|
883
|
+
{I}}}
|
|
884
|
+
{I}{index_var}++;
|
|
885
|
+
}}"""
|
|
886
|
+
)
|
|
887
|
+
)
|
|
888
|
+
|
|
889
|
+
else:
|
|
890
|
+
assert_never(type_anno)
|
|
891
|
+
|
|
892
|
+
verify_block = Stripped("\n".join(stmts))
|
|
893
|
+
if isinstance(prop.type_annotation, intermediate.OptionalTypeAnnotation):
|
|
894
|
+
if needs_null_coalescing:
|
|
895
|
+
value_type = csharp_common.generate_type(prop.type_annotation.value)
|
|
896
|
+
if isinstance(prop.type_annotation.value, intermediate.OurTypeAnnotation):
|
|
897
|
+
our_type = prop.type_annotation.value.our_type
|
|
898
|
+
if isinstance(
|
|
899
|
+
our_type,
|
|
900
|
+
(
|
|
901
|
+
intermediate.Enumeration,
|
|
902
|
+
intermediate.AbstractClass,
|
|
903
|
+
intermediate.ConcreteClass,
|
|
904
|
+
),
|
|
905
|
+
):
|
|
906
|
+
value_type = Stripped(f"Aas.{value_type}")
|
|
907
|
+
|
|
908
|
+
return (
|
|
909
|
+
Stripped(
|
|
910
|
+
f"""\
|
|
911
|
+
if (that.{prop_name} != null)
|
|
912
|
+
{{
|
|
913
|
+
{I}// We need to help the static analyzer with a null coalescing.
|
|
914
|
+
{I}{value_type} value = that.{prop_name}
|
|
915
|
+
{II}?? throw new System.InvalidOperationException();
|
|
916
|
+
{I}{indent_but_first_line(verify_block, I)}
|
|
917
|
+
}}"""
|
|
918
|
+
),
|
|
919
|
+
None,
|
|
920
|
+
)
|
|
921
|
+
|
|
922
|
+
else:
|
|
923
|
+
return (
|
|
924
|
+
Stripped(
|
|
925
|
+
f"""\
|
|
926
|
+
if (that.{prop_name} != null)
|
|
927
|
+
{{
|
|
928
|
+
{I}{indent_but_first_line(verify_block, I)}
|
|
929
|
+
}}"""
|
|
930
|
+
),
|
|
931
|
+
None,
|
|
932
|
+
)
|
|
933
|
+
else:
|
|
934
|
+
return verify_block, None
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
938
|
+
def _generate_transform_for_class(
|
|
939
|
+
cls: intermediate.ConcreteClass,
|
|
940
|
+
symbol_table: intermediate.SymbolTable,
|
|
941
|
+
base_environment: intermediate_type_inference.Environment,
|
|
942
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
943
|
+
"""Generate the transform method to errors for the given concrete class."""
|
|
944
|
+
errors = [] # type: List[Error]
|
|
945
|
+
blocks = [] # type: List[Stripped]
|
|
946
|
+
|
|
947
|
+
name = csharp_naming.class_name(cls.name)
|
|
948
|
+
|
|
949
|
+
environment = intermediate_type_inference.MutableEnvironment(
|
|
950
|
+
parent=base_environment
|
|
951
|
+
)
|
|
952
|
+
|
|
953
|
+
assert environment.find(Identifier("self")) is None
|
|
954
|
+
environment.set(
|
|
955
|
+
identifier=Identifier("self"),
|
|
956
|
+
type_annotation=intermediate_type_inference.OurTypeAnnotation(our_type=cls),
|
|
957
|
+
)
|
|
958
|
+
|
|
959
|
+
for invariant in cls.invariants:
|
|
960
|
+
invariant_code, error = _transpile_invariant(
|
|
961
|
+
invariant=invariant, symbol_table=symbol_table, environment=environment
|
|
962
|
+
)
|
|
963
|
+
if error is not None:
|
|
964
|
+
errors.append(
|
|
965
|
+
Error(
|
|
966
|
+
cls.parsed.node,
|
|
967
|
+
f"Failed to transpile the invariant of the class {cls.name!r}",
|
|
968
|
+
[error],
|
|
969
|
+
)
|
|
970
|
+
)
|
|
971
|
+
continue
|
|
972
|
+
|
|
973
|
+
assert invariant_code is not None
|
|
974
|
+
|
|
975
|
+
blocks.append(invariant_code)
|
|
976
|
+
|
|
977
|
+
if len(errors) > 0:
|
|
978
|
+
return None, errors
|
|
979
|
+
|
|
980
|
+
for prop in cls.properties:
|
|
981
|
+
block, error = _generate_transform_property(prop=prop)
|
|
982
|
+
if error is not None:
|
|
983
|
+
errors.append(error)
|
|
984
|
+
else:
|
|
985
|
+
assert block is not None
|
|
986
|
+
if block != "":
|
|
987
|
+
blocks.append(block)
|
|
988
|
+
|
|
989
|
+
if len(errors) > 0:
|
|
990
|
+
return None, errors
|
|
991
|
+
|
|
992
|
+
if len(blocks) == 0:
|
|
993
|
+
blocks.append(
|
|
994
|
+
Stripped(
|
|
995
|
+
f"""\
|
|
996
|
+
// No verification has been defined for {name}.
|
|
997
|
+
yield break;"""
|
|
998
|
+
)
|
|
999
|
+
)
|
|
1000
|
+
|
|
1001
|
+
writer = io.StringIO()
|
|
1002
|
+
|
|
1003
|
+
interface_name = csharp_naming.interface_name(cls.name)
|
|
1004
|
+
transform_name = csharp_naming.method_name(Identifier(f"transform_{cls.name}"))
|
|
1005
|
+
|
|
1006
|
+
writer.write(
|
|
1007
|
+
f"""\
|
|
1008
|
+
[CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")]
|
|
1009
|
+
public override IEnumerable<Reporting.Error> {transform_name}(
|
|
1010
|
+
{I}Aas.{interface_name} that
|
|
1011
|
+
)
|
|
1012
|
+
{{
|
|
1013
|
+
"""
|
|
1014
|
+
)
|
|
1015
|
+
|
|
1016
|
+
for i, stmt in enumerate(blocks):
|
|
1017
|
+
if i > 0:
|
|
1018
|
+
writer.write("\n\n")
|
|
1019
|
+
writer.write(textwrap.indent(stmt, I))
|
|
1020
|
+
|
|
1021
|
+
writer.write("\n}")
|
|
1022
|
+
|
|
1023
|
+
return Stripped(writer.getvalue()), None
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
def _generate_transformer(
|
|
1027
|
+
symbol_table: intermediate.SymbolTable,
|
|
1028
|
+
base_environment: intermediate_type_inference.Environment,
|
|
1029
|
+
spec_impls: specific_implementations.SpecificImplementations,
|
|
1030
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
1031
|
+
"""Generate a transformer to double-dispatch an instance to errors."""
|
|
1032
|
+
errors = [] # type: List[Error]
|
|
1033
|
+
|
|
1034
|
+
blocks = [] # type: List[Stripped]
|
|
1035
|
+
|
|
1036
|
+
for our_type in symbol_table.our_types:
|
|
1037
|
+
if isinstance(our_type, intermediate.Enumeration):
|
|
1038
|
+
continue
|
|
1039
|
+
|
|
1040
|
+
elif isinstance(our_type, intermediate.ConstrainedPrimitive):
|
|
1041
|
+
continue
|
|
1042
|
+
|
|
1043
|
+
elif isinstance(our_type, intermediate.AbstractClass):
|
|
1044
|
+
# The abstract classes are directly dispatched by the transformer,
|
|
1045
|
+
# so we do not need to handle them separately.
|
|
1046
|
+
pass
|
|
1047
|
+
|
|
1048
|
+
elif isinstance(our_type, intermediate.ConcreteClass):
|
|
1049
|
+
if our_type.is_implementation_specific:
|
|
1050
|
+
transform_key = specific_implementations.ImplementationKey(
|
|
1051
|
+
f"Verification/transform_{our_type.name}.cs"
|
|
1052
|
+
)
|
|
1053
|
+
|
|
1054
|
+
implementation = spec_impls.get(transform_key, None)
|
|
1055
|
+
if implementation is None:
|
|
1056
|
+
errors.append(
|
|
1057
|
+
Error(
|
|
1058
|
+
our_type.parsed.node,
|
|
1059
|
+
f"The transformation snippet is missing "
|
|
1060
|
+
f"for the implementation-specific "
|
|
1061
|
+
f"class {our_type.name}: {transform_key}",
|
|
1062
|
+
)
|
|
1063
|
+
)
|
|
1064
|
+
continue
|
|
1065
|
+
|
|
1066
|
+
blocks.append(spec_impls[transform_key])
|
|
1067
|
+
else:
|
|
1068
|
+
block, cls_errors = _generate_transform_for_class(
|
|
1069
|
+
cls=our_type,
|
|
1070
|
+
symbol_table=symbol_table,
|
|
1071
|
+
base_environment=base_environment,
|
|
1072
|
+
)
|
|
1073
|
+
if cls_errors is not None:
|
|
1074
|
+
errors.extend(cls_errors)
|
|
1075
|
+
else:
|
|
1076
|
+
assert block is not None
|
|
1077
|
+
blocks.append(block)
|
|
1078
|
+
else:
|
|
1079
|
+
assert_never(our_type)
|
|
1080
|
+
|
|
1081
|
+
if len(errors) > 0:
|
|
1082
|
+
return None, errors
|
|
1083
|
+
|
|
1084
|
+
writer = io.StringIO()
|
|
1085
|
+
writer.write(
|
|
1086
|
+
f"""\
|
|
1087
|
+
private class Transformer
|
|
1088
|
+
{I}: Visitation.AbstractTransformer<IEnumerable<Reporting.Error>>
|
|
1089
|
+
{{
|
|
1090
|
+
"""
|
|
1091
|
+
)
|
|
1092
|
+
|
|
1093
|
+
for i, block in enumerate(blocks):
|
|
1094
|
+
if i > 0:
|
|
1095
|
+
writer.write("\n\n")
|
|
1096
|
+
writer.write(textwrap.indent(block, I))
|
|
1097
|
+
|
|
1098
|
+
writer.write("\n} // private class Transformer")
|
|
1099
|
+
|
|
1100
|
+
return Stripped(writer.getvalue()), None
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
def _generate_verify_enumeration(enumeration: intermediate.Enumeration) -> Stripped:
|
|
1104
|
+
"""Generate the verify method to check that an enum is valid."""
|
|
1105
|
+
name = csharp_naming.enum_name(enumeration.name)
|
|
1106
|
+
|
|
1107
|
+
return Stripped(
|
|
1108
|
+
f"""\
|
|
1109
|
+
/// <summary>
|
|
1110
|
+
/// Verify that <paramref name="that" /> is a valid enumeration value.
|
|
1111
|
+
/// </summary>
|
|
1112
|
+
public static IEnumerable<Reporting.Error> Verify{name}(
|
|
1113
|
+
{I}Aas.{name} that)
|
|
1114
|
+
{{
|
|
1115
|
+
{I}if (!EnumValueSet.For{name}.Contains(
|
|
1116
|
+
{II}(int)that))
|
|
1117
|
+
{I}{{
|
|
1118
|
+
{II}yield return new Reporting.Error(
|
|
1119
|
+
{III}$"Invalid {name}: {{that}}");
|
|
1120
|
+
{I}}}
|
|
1121
|
+
}}"""
|
|
1122
|
+
)
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
def _generate_verify_constrained_primitive(
|
|
1126
|
+
constrained_primitive: intermediate.ConstrainedPrimitive,
|
|
1127
|
+
symbol_table: intermediate.SymbolTable,
|
|
1128
|
+
base_environment: intermediate_type_inference.Environment,
|
|
1129
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
1130
|
+
"""Generate the verify function for the constrained primitives."""
|
|
1131
|
+
errors = [] # type: List[Error]
|
|
1132
|
+
blocks = [] # type: List[Stripped]
|
|
1133
|
+
|
|
1134
|
+
environment = intermediate_type_inference.MutableEnvironment(
|
|
1135
|
+
parent=base_environment
|
|
1136
|
+
)
|
|
1137
|
+
|
|
1138
|
+
assert environment.find(Identifier("self")) is None
|
|
1139
|
+
environment.set(
|
|
1140
|
+
identifier=Identifier("self"),
|
|
1141
|
+
type_annotation=intermediate_type_inference.OurTypeAnnotation(
|
|
1142
|
+
our_type=constrained_primitive
|
|
1143
|
+
),
|
|
1144
|
+
)
|
|
1145
|
+
|
|
1146
|
+
for invariant in constrained_primitive.invariants:
|
|
1147
|
+
invariant_code, error = _transpile_invariant(
|
|
1148
|
+
invariant=invariant, symbol_table=symbol_table, environment=environment
|
|
1149
|
+
)
|
|
1150
|
+
if error is not None:
|
|
1151
|
+
errors.append(
|
|
1152
|
+
Error(
|
|
1153
|
+
constrained_primitive.parsed.node,
|
|
1154
|
+
f"Failed to transpile the invariant of "
|
|
1155
|
+
f"the constrained primitive {constrained_primitive.name!r}",
|
|
1156
|
+
[error],
|
|
1157
|
+
)
|
|
1158
|
+
)
|
|
1159
|
+
continue
|
|
1160
|
+
|
|
1161
|
+
assert invariant_code is not None
|
|
1162
|
+
|
|
1163
|
+
blocks.append(invariant_code)
|
|
1164
|
+
|
|
1165
|
+
if len(errors) > 0:
|
|
1166
|
+
return None, errors
|
|
1167
|
+
|
|
1168
|
+
if len(blocks) == 0:
|
|
1169
|
+
blocks.append(
|
|
1170
|
+
Stripped(
|
|
1171
|
+
"""\
|
|
1172
|
+
// There is no verification specified.
|
|
1173
|
+
yield break;"""
|
|
1174
|
+
)
|
|
1175
|
+
)
|
|
1176
|
+
|
|
1177
|
+
# NOTE (mristin, 2022-03-16):
|
|
1178
|
+
# Constrained primitives are not really classes, but we simply use the naming
|
|
1179
|
+
# for classes here since we need to pick *something*.
|
|
1180
|
+
name = csharp_naming.class_name(constrained_primitive.name)
|
|
1181
|
+
|
|
1182
|
+
that_type = csharp_common.PRIMITIVE_TYPE_MAP[constrained_primitive.constrainee]
|
|
1183
|
+
|
|
1184
|
+
writer = io.StringIO()
|
|
1185
|
+
writer.write(
|
|
1186
|
+
f"""\
|
|
1187
|
+
/// <summary>
|
|
1188
|
+
/// Verify the constraints of <paramref name="that" />.
|
|
1189
|
+
/// </summary>
|
|
1190
|
+
public static IEnumerable<Reporting.Error> Verify{name} (
|
|
1191
|
+
{I}{that_type} that)
|
|
1192
|
+
{{
|
|
1193
|
+
"""
|
|
1194
|
+
)
|
|
1195
|
+
|
|
1196
|
+
for i, block in enumerate(blocks):
|
|
1197
|
+
if i > 0:
|
|
1198
|
+
writer.write("\n\n")
|
|
1199
|
+
writer.write(textwrap.indent(block, I))
|
|
1200
|
+
|
|
1201
|
+
writer.write("\n}")
|
|
1202
|
+
|
|
1203
|
+
assert len(errors) == 0
|
|
1204
|
+
return Stripped(writer.getvalue()), None
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
# fmt: off
|
|
1208
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
1209
|
+
@ensure(
|
|
1210
|
+
lambda result:
|
|
1211
|
+
not (result[0] is not None) or result[0].endswith('\n'),
|
|
1212
|
+
"Trailing newline mandatory for valid end-of-files"
|
|
1213
|
+
)
|
|
1214
|
+
# fmt: on
|
|
1215
|
+
def generate(
|
|
1216
|
+
symbol_table: intermediate.SymbolTable,
|
|
1217
|
+
namespace: csharp_common.NamespaceIdentifier,
|
|
1218
|
+
spec_impls: specific_implementations.SpecificImplementations,
|
|
1219
|
+
) -> Tuple[Optional[str], Optional[List[Error]]]:
|
|
1220
|
+
"""
|
|
1221
|
+
Generate the C# code of the structures based on the symbol table.
|
|
1222
|
+
|
|
1223
|
+
The ``namespace`` defines the AAS C# namespace.
|
|
1224
|
+
"""
|
|
1225
|
+
using_directives = [] # type: List[Stripped]
|
|
1226
|
+
using_directives.extend(
|
|
1227
|
+
csharp_common.generate_using_aas_directive_if_necessary(namespace)
|
|
1228
|
+
)
|
|
1229
|
+
|
|
1230
|
+
using_directives.append(
|
|
1231
|
+
Stripped(
|
|
1232
|
+
"""\
|
|
1233
|
+
using CodeAnalysis = System.Diagnostics.CodeAnalysis;
|
|
1234
|
+
using Regex = System.Text.RegularExpressions.Regex;
|
|
1235
|
+
|
|
1236
|
+
using System.Collections.Generic; // can't alias
|
|
1237
|
+
using System.Linq; // can't alias"""
|
|
1238
|
+
)
|
|
1239
|
+
)
|
|
1240
|
+
|
|
1241
|
+
blocks = [
|
|
1242
|
+
csharp_common.WARNING,
|
|
1243
|
+
Stripped("\n".join(using_directives)),
|
|
1244
|
+
] # type: List[Stripped]
|
|
1245
|
+
|
|
1246
|
+
verification_blocks = [] # type: List[Stripped]
|
|
1247
|
+
errors = [] # type: List[Error]
|
|
1248
|
+
|
|
1249
|
+
base_environment = intermediate_type_inference.populate_base_environment(
|
|
1250
|
+
symbol_table=symbol_table
|
|
1251
|
+
)
|
|
1252
|
+
|
|
1253
|
+
for verification in symbol_table.verification_functions:
|
|
1254
|
+
if isinstance(verification, intermediate.ImplementationSpecificVerification):
|
|
1255
|
+
implementation_key = specific_implementations.ImplementationKey(
|
|
1256
|
+
f"Verification/{verification.name}.cs"
|
|
1257
|
+
)
|
|
1258
|
+
|
|
1259
|
+
implementation = spec_impls.get(implementation_key, None)
|
|
1260
|
+
if implementation is None:
|
|
1261
|
+
errors.append(
|
|
1262
|
+
Error(
|
|
1263
|
+
None,
|
|
1264
|
+
f"The snippet for the verification function "
|
|
1265
|
+
f"{verification.name!r} is missing: {implementation_key}",
|
|
1266
|
+
)
|
|
1267
|
+
)
|
|
1268
|
+
else:
|
|
1269
|
+
verification_blocks.append(implementation)
|
|
1270
|
+
|
|
1271
|
+
elif isinstance(verification, intermediate.PatternVerification):
|
|
1272
|
+
implementation, error = _transpile_pattern_verification(
|
|
1273
|
+
verification=verification
|
|
1274
|
+
)
|
|
1275
|
+
|
|
1276
|
+
if error is not None:
|
|
1277
|
+
errors.append(error)
|
|
1278
|
+
else:
|
|
1279
|
+
assert implementation is not None
|
|
1280
|
+
verification_blocks.append(implementation)
|
|
1281
|
+
|
|
1282
|
+
elif isinstance(verification, intermediate.TranspilableVerification):
|
|
1283
|
+
implementation, error = _transpile_transpilable_verification(
|
|
1284
|
+
verification=verification,
|
|
1285
|
+
symbol_table=symbol_table,
|
|
1286
|
+
environment=base_environment,
|
|
1287
|
+
)
|
|
1288
|
+
|
|
1289
|
+
if error is not None:
|
|
1290
|
+
errors.append(error)
|
|
1291
|
+
else:
|
|
1292
|
+
assert implementation is not None
|
|
1293
|
+
verification_blocks.append(implementation)
|
|
1294
|
+
|
|
1295
|
+
else:
|
|
1296
|
+
assert_never(verification)
|
|
1297
|
+
|
|
1298
|
+
verification_blocks.append(_generate_enum_value_sets(symbol_table=symbol_table))
|
|
1299
|
+
|
|
1300
|
+
verification_blocks.append(
|
|
1301
|
+
Stripped(
|
|
1302
|
+
f"""\
|
|
1303
|
+
[CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
1304
|
+
private static readonly Verification.Transformer _transformer = (
|
|
1305
|
+
{I}new Verification.Transformer());"""
|
|
1306
|
+
)
|
|
1307
|
+
)
|
|
1308
|
+
|
|
1309
|
+
transformer_block, transformer_errors = _generate_transformer(
|
|
1310
|
+
symbol_table=symbol_table,
|
|
1311
|
+
base_environment=base_environment,
|
|
1312
|
+
spec_impls=spec_impls,
|
|
1313
|
+
)
|
|
1314
|
+
if transformer_errors is not None:
|
|
1315
|
+
errors.extend(transformer_errors)
|
|
1316
|
+
else:
|
|
1317
|
+
assert transformer_block is not None
|
|
1318
|
+
verification_blocks.append(transformer_block)
|
|
1319
|
+
|
|
1320
|
+
verification_blocks.append(
|
|
1321
|
+
Stripped(
|
|
1322
|
+
f"""\
|
|
1323
|
+
/// <summary>
|
|
1324
|
+
/// Verify the constraints of <paramref name="that" /> recursively.
|
|
1325
|
+
/// </summary>
|
|
1326
|
+
/// <param name="that">
|
|
1327
|
+
/// The instance of the meta-model to be verified
|
|
1328
|
+
/// </param>
|
|
1329
|
+
public static IEnumerable<Reporting.Error> Verify(Aas.IClass that)
|
|
1330
|
+
{{
|
|
1331
|
+
{I}foreach (var error in _transformer.Transform(that))
|
|
1332
|
+
{I}{{
|
|
1333
|
+
{II}yield return error;
|
|
1334
|
+
{I}}}
|
|
1335
|
+
}}"""
|
|
1336
|
+
)
|
|
1337
|
+
)
|
|
1338
|
+
|
|
1339
|
+
for our_type in symbol_table.our_types:
|
|
1340
|
+
if isinstance(our_type, intermediate.Enumeration):
|
|
1341
|
+
verification_blocks.append(
|
|
1342
|
+
_generate_verify_enumeration(enumeration=our_type)
|
|
1343
|
+
)
|
|
1344
|
+
elif isinstance(our_type, intermediate.ConstrainedPrimitive):
|
|
1345
|
+
(
|
|
1346
|
+
constrained_primitive_block,
|
|
1347
|
+
constrained_primitive_errors,
|
|
1348
|
+
) = _generate_verify_constrained_primitive(
|
|
1349
|
+
constrained_primitive=our_type,
|
|
1350
|
+
symbol_table=symbol_table,
|
|
1351
|
+
base_environment=base_environment,
|
|
1352
|
+
)
|
|
1353
|
+
|
|
1354
|
+
if constrained_primitive_errors is not None:
|
|
1355
|
+
errors.extend(constrained_primitive_errors)
|
|
1356
|
+
else:
|
|
1357
|
+
assert constrained_primitive_block is not None
|
|
1358
|
+
verification_blocks.append(constrained_primitive_block)
|
|
1359
|
+
|
|
1360
|
+
elif isinstance(
|
|
1361
|
+
our_type, (intermediate.AbstractClass, intermediate.ConcreteClass)
|
|
1362
|
+
):
|
|
1363
|
+
# We provide a general dispatch function.
|
|
1364
|
+
pass
|
|
1365
|
+
else:
|
|
1366
|
+
assert_never(our_type)
|
|
1367
|
+
|
|
1368
|
+
if len(errors) > 0:
|
|
1369
|
+
return None, errors
|
|
1370
|
+
|
|
1371
|
+
verification_writer = io.StringIO()
|
|
1372
|
+
verification_writer.write(
|
|
1373
|
+
f"""\
|
|
1374
|
+
namespace {namespace}
|
|
1375
|
+
{{
|
|
1376
|
+
{I}/// <summary>
|
|
1377
|
+
{I}/// Verify that the instances of the meta-model satisfy the invariants.
|
|
1378
|
+
{I}/// </summary>
|
|
1379
|
+
"""
|
|
1380
|
+
)
|
|
1381
|
+
|
|
1382
|
+
# region Write an example usage
|
|
1383
|
+
|
|
1384
|
+
first_cls = (
|
|
1385
|
+
symbol_table.classes[0] if len(symbol_table.classes) > 0 else None
|
|
1386
|
+
) # type: Optional[intermediate.ClassUnion]
|
|
1387
|
+
|
|
1388
|
+
if first_cls is not None:
|
|
1389
|
+
cls_name: str
|
|
1390
|
+
|
|
1391
|
+
if isinstance(first_cls, intermediate.AbstractClass):
|
|
1392
|
+
cls_name = csharp_naming.interface_name(first_cls.name)
|
|
1393
|
+
elif isinstance(first_cls, intermediate.ConcreteClass):
|
|
1394
|
+
cls_name = csharp_naming.class_name(first_cls.name)
|
|
1395
|
+
else:
|
|
1396
|
+
assert_never(first_cls)
|
|
1397
|
+
|
|
1398
|
+
an_instance_variable = csharp_naming.variable_name(Identifier("an_instance"))
|
|
1399
|
+
|
|
1400
|
+
verification_writer.write(
|
|
1401
|
+
# We can not use textwrap.dedent since we indent everything including the
|
|
1402
|
+
# first line.
|
|
1403
|
+
f"""\
|
|
1404
|
+
{I}/// <example>
|
|
1405
|
+
{I}/// Here is an example how to verify an instance of {cls_name}:
|
|
1406
|
+
{I}/// <code>
|
|
1407
|
+
{I}/// var {an_instance_variable} = new Aas.{cls_name}(
|
|
1408
|
+
{I}/// // ... some constructor arguments ...
|
|
1409
|
+
{I}/// );
|
|
1410
|
+
{I}/// foreach (var error in Verification.Verify({an_instance_variable}))
|
|
1411
|
+
{I}/// {{
|
|
1412
|
+
{I}/// {I}System.Console.Writeln(
|
|
1413
|
+
{I}/// {II}$"{{error.Cause}} at: " +
|
|
1414
|
+
{I}/// {II}Reporting.GenerateJsonPath(error.PathSegments));
|
|
1415
|
+
{I}/// }}
|
|
1416
|
+
{I}/// </code>
|
|
1417
|
+
{I}/// </example>
|
|
1418
|
+
"""
|
|
1419
|
+
)
|
|
1420
|
+
|
|
1421
|
+
# endregion
|
|
1422
|
+
|
|
1423
|
+
verification_writer.write(
|
|
1424
|
+
f"""\
|
|
1425
|
+
{I}public static class Verification
|
|
1426
|
+
{I}{{
|
|
1427
|
+
"""
|
|
1428
|
+
)
|
|
1429
|
+
|
|
1430
|
+
for i, verification_block in enumerate(verification_blocks):
|
|
1431
|
+
if i > 0:
|
|
1432
|
+
verification_writer.write("\n\n")
|
|
1433
|
+
|
|
1434
|
+
verification_writer.write(textwrap.indent(verification_block, II))
|
|
1435
|
+
|
|
1436
|
+
verification_writer.write(f"\n{I}}} // public static class Verification")
|
|
1437
|
+
verification_writer.write(f"\n}} // namespace {namespace}")
|
|
1438
|
+
|
|
1439
|
+
blocks.append(Stripped(verification_writer.getvalue()))
|
|
1440
|
+
|
|
1441
|
+
blocks.append(csharp_common.WARNING)
|
|
1442
|
+
|
|
1443
|
+
out = io.StringIO()
|
|
1444
|
+
for i, block in enumerate(blocks):
|
|
1445
|
+
if i > 0:
|
|
1446
|
+
out.write("\n\n")
|
|
1447
|
+
|
|
1448
|
+
assert not block.startswith("\n")
|
|
1449
|
+
assert not block.endswith("\n")
|
|
1450
|
+
out.write(block)
|
|
1451
|
+
|
|
1452
|
+
out.write("\n")
|
|
1453
|
+
|
|
1454
|
+
return out.getvalue(), None
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
# endregion
|