@alloy-js/csharp 0.20.0-dev.1 → 0.20.0-dev.10
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.
- package/dist/src/components/Declaration.d.ts +2 -2
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +5 -14
- package/dist/src/components/Declaration.js.map +1 -0
- package/dist/src/components/Name.js +2 -1
- package/dist/src/components/Name.js.map +1 -0
- package/dist/src/components/ProjectDirectory.js +2 -1
- package/dist/src/components/ProjectDirectory.js.map +1 -0
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +7 -2
- package/dist/src/components/Reference.js.map +1 -0
- package/dist/src/components/UsingDirective.d.ts +5 -1
- package/dist/src/components/UsingDirective.d.ts.map +1 -1
- package/dist/src/components/UsingDirective.js +5 -2
- package/dist/src/components/UsingDirective.js.map +1 -0
- package/dist/src/components/access-expression/access-expression.d.ts +54 -0
- package/dist/src/components/access-expression/access-expression.d.ts.map +1 -0
- package/dist/src/components/access-expression/access-expression.js +277 -0
- package/dist/src/components/access-expression/access-expression.js.map +1 -0
- package/dist/src/components/access-expression/access-expression.test.d.ts +2 -0
- package/dist/src/components/access-expression/access-expression.test.d.ts.map +1 -0
- package/dist/src/components/access-expression/access-expression.test.js +336 -0
- package/dist/src/components/access-expression/access-expression.test.js.map +1 -0
- package/dist/src/components/access-expression/part-descriptors.d.ts +32 -0
- package/dist/src/components/access-expression/part-descriptors.d.ts.map +1 -0
- package/dist/src/components/access-expression/part-descriptors.js +99 -0
- package/dist/src/components/access-expression/part-descriptors.js.map +1 -0
- package/dist/src/components/attributes/attributes.js +2 -1
- package/dist/src/components/attributes/attributes.js.map +1 -0
- package/dist/src/components/attributes/attributes.test.js +2 -1
- package/dist/src/components/attributes/attributes.test.js.map +1 -0
- package/dist/src/components/class/declaration.d.ts +2 -2
- package/dist/src/components/class/declaration.d.ts.map +1 -1
- package/dist/src/components/class/declaration.js +21 -34
- package/dist/src/components/class/declaration.js.map +1 -0
- package/dist/src/components/class/declaration.test.js +199 -200
- package/dist/src/components/class/declaration.test.js.map +1 -0
- package/dist/src/components/constructor/constructor.d.ts.map +1 -1
- package/dist/src/components/constructor/constructor.js +13 -20
- package/dist/src/components/constructor/constructor.js.map +1 -0
- package/dist/src/components/constructor/constructor.test.js +12 -20
- package/dist/src/components/constructor/constructor.test.js.map +1 -0
- package/dist/src/components/doc/comment.js +2 -1
- package/dist/src/components/doc/comment.js.map +1 -0
- package/dist/src/components/doc/comment.test.js +2 -1
- package/dist/src/components/doc/comment.test.js.map +1 -0
- package/dist/src/components/doc/from-markdown.js +2 -1
- package/dist/src/components/doc/from-markdown.js.map +1 -0
- package/dist/src/components/doc/from-markdown.test.js +2 -1
- package/dist/src/components/doc/from-markdown.test.js.map +1 -0
- package/dist/src/components/{EnumDeclaration.d.ts → enum/declaration.d.ts} +6 -11
- package/dist/src/components/enum/declaration.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.js +55 -0
- package/dist/src/components/enum/declaration.js.map +1 -0
- package/dist/src/components/enum/declaration.ref.test.d.ts +2 -0
- package/dist/src/components/enum/declaration.ref.test.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.ref.test.js +121 -0
- package/dist/src/components/enum/declaration.ref.test.js.map +1 -0
- package/dist/src/components/enum/declaration.test.d.ts +2 -0
- package/dist/src/components/enum/declaration.test.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.test.js +40 -0
- package/dist/src/components/enum/declaration.test.js.map +1 -0
- package/dist/src/components/enum/member.d.ts +7 -0
- package/dist/src/components/enum/member.d.ts.map +1 -0
- package/dist/src/components/enum/member.js +30 -0
- package/dist/src/components/enum/member.js.map +1 -0
- package/dist/src/components/enum/member.test.d.ts +2 -0
- package/dist/src/components/enum/member.test.d.ts.map +1 -0
- package/dist/src/components/enum/member.test.js +29 -0
- package/dist/src/components/enum/member.test.js.map +1 -0
- package/dist/src/components/field/field.d.ts.map +1 -1
- package/dist/src/components/field/field.js +11 -18
- package/dist/src/components/field/field.js.map +1 -0
- package/dist/src/components/field/field.test.js +9 -8
- package/dist/src/components/field/field.test.js.map +1 -0
- package/dist/src/components/index.d.ts +7 -3
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +9 -4
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/interface/declaration.d.ts.map +1 -1
- package/dist/src/components/interface/declaration.js +21 -22
- package/dist/src/components/interface/declaration.js.map +1 -0
- package/dist/src/components/interface/declaration.test.js +28 -36
- package/dist/src/components/interface/declaration.test.js.map +1 -0
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +9 -19
- package/dist/src/components/interface/method.js.map +1 -0
- package/dist/src/components/interface/method.test.js +40 -48
- package/dist/src/components/interface/method.test.js.map +1 -0
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +23 -40
- package/dist/src/components/interface/property.js.map +1 -0
- package/dist/src/components/interface/property.test.js +13 -12
- package/dist/src/components/interface/property.test.js.map +1 -0
- package/dist/src/components/invocation-expression/invocation-expression.d.ts +29 -0
- package/dist/src/components/invocation-expression/invocation-expression.d.ts.map +1 -0
- package/dist/src/components/invocation-expression/invocation-expression.js +70 -0
- package/dist/src/components/invocation-expression/invocation-expression.js.map +1 -0
- package/dist/src/components/invocation-expression/invocation-expression.test.d.ts +2 -0
- package/dist/src/components/invocation-expression/invocation-expression.test.d.ts.map +1 -0
- package/dist/src/components/invocation-expression/invocation-expression.test.js +105 -0
- package/dist/src/components/invocation-expression/invocation-expression.test.js.map +1 -0
- package/dist/src/components/lexical-scope.d.ts +8 -0
- package/dist/src/components/lexical-scope.d.ts.map +1 -0
- package/dist/src/components/lexical-scope.js +25 -0
- package/dist/src/components/lexical-scope.js.map +1 -0
- package/dist/src/components/method/method.d.ts +5 -2
- package/dist/src/components/method/method.d.ts.map +1 -1
- package/dist/src/components/method/method.js +9 -17
- package/dist/src/components/method/method.js.map +1 -0
- package/dist/src/components/method/method.test.js +13 -12
- package/dist/src/components/method/method.test.js.map +1 -0
- package/dist/src/components/method-scope.d.ts +8 -0
- package/dist/src/components/method-scope.d.ts.map +1 -0
- package/dist/src/components/method-scope.js +25 -0
- package/dist/src/components/method-scope.js.map +1 -0
- package/dist/src/components/namespace-scopes.d.ts +13 -0
- package/dist/src/components/namespace-scopes.d.ts.map +1 -0
- package/dist/src/components/namespace-scopes.js +45 -0
- package/dist/src/components/namespace-scopes.js.map +1 -0
- package/dist/src/components/namespace.d.ts +7 -0
- package/dist/src/components/namespace.d.ts.map +1 -0
- package/dist/src/components/namespace.js +47 -0
- package/dist/src/components/namespace.js.map +1 -0
- package/dist/src/components/namespace.ref.test.d.ts +2 -0
- package/dist/src/components/namespace.ref.test.d.ts.map +1 -0
- package/dist/src/components/namespace.ref.test.js +182 -0
- package/dist/src/components/namespace.ref.test.js.map +1 -0
- package/dist/src/components/namespace.test.d.ts.map +1 -0
- package/dist/src/components/namespace.test.js +79 -0
- package/dist/src/components/namespace.test.js.map +1 -0
- package/dist/src/components/parameters/parameters.d.ts +2 -3
- package/dist/src/components/parameters/parameters.d.ts.map +1 -1
- package/dist/src/components/parameters/parameters.js +15 -15
- package/dist/src/components/parameters/parameters.js.map +1 -0
- package/dist/src/components/parameters/parameters.test.d.ts +2 -0
- package/dist/src/components/parameters/parameters.test.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.test.js +154 -0
- package/dist/src/components/parameters/parameters.test.js.map +1 -0
- package/dist/src/components/property/property.d.ts +2 -2
- package/dist/src/components/property/property.d.ts.map +1 -1
- package/dist/src/components/property/property.js +30 -40
- package/dist/src/components/property/property.js.map +1 -0
- package/dist/src/components/property/property.test.js +16 -15
- package/dist/src/components/property/property.test.js.map +1 -0
- package/dist/src/components/record/declaration.d.ts +18 -0
- package/dist/src/components/record/declaration.d.ts.map +1 -1
- package/dist/src/components/record/declaration.js +21 -14
- package/dist/src/components/record/declaration.js.map +1 -0
- package/dist/src/components/record/declaration.test.js +52 -4
- package/dist/src/components/record/declaration.test.js.map +1 -0
- package/dist/src/components/source-file/source-file.d.ts +19 -0
- package/dist/src/components/source-file/source-file.d.ts.map +1 -0
- package/dist/src/components/source-file/source-file.js +59 -0
- package/dist/src/components/source-file/source-file.js.map +1 -0
- package/dist/src/components/source-file/source-file.test.d.ts +2 -0
- package/dist/src/components/source-file/source-file.test.d.ts.map +1 -0
- package/dist/src/components/source-file/source-file.test.js +136 -0
- package/dist/src/components/source-file/source-file.test.js.map +1 -0
- package/dist/src/components/stc/index.js +2 -1
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/components/struct/declaration.d.ts.map +1 -1
- package/dist/src/components/struct/declaration.js +6 -7
- package/dist/src/components/struct/declaration.js.map +1 -0
- package/dist/src/components/struct/declaration.test.js +32 -40
- package/dist/src/components/struct/declaration.test.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.js +2 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js +2 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -1
- package/dist/src/components/type-parameters/type-parameter.js +9 -11
- package/dist/src/components/type-parameters/type-parameter.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.js +2 -1
- package/dist/src/components/type-parameters/type-parameters.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.test.js +5 -4
- package/dist/src/components/type-parameters/type-parameters.test.js.map +1 -0
- package/dist/src/components/var/declaration.d.ts.map +1 -1
- package/dist/src/components/var/declaration.js +8 -9
- package/dist/src/components/var/declaration.js.map +1 -0
- package/dist/src/components/var/declaration.test.js +13 -21
- package/dist/src/components/var/declaration.test.js.map +1 -0
- package/dist/src/contexts/format-options.d.ts +5 -0
- package/dist/src/contexts/format-options.d.ts.map +1 -0
- package/dist/src/contexts/format-options.js +9 -0
- package/dist/src/contexts/format-options.js.map +1 -0
- package/dist/src/contexts/global-namespace.d.ts +5 -0
- package/dist/src/contexts/global-namespace.d.ts.map +1 -0
- package/dist/src/contexts/global-namespace.js +25 -0
- package/dist/src/contexts/global-namespace.js.map +1 -0
- package/dist/src/contexts/namespace.d.ts +8 -0
- package/dist/src/contexts/namespace.d.ts.map +1 -0
- package/dist/src/contexts/namespace.js +6 -0
- package/dist/src/contexts/namespace.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/modifiers.d.ts +11 -0
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/modifiers.js +2 -1
- package/dist/src/modifiers.js.map +1 -0
- package/dist/src/name-policy.js +2 -1
- package/dist/src/name-policy.js.map +1 -0
- package/dist/src/scopes/class.d.ts +10 -0
- package/dist/src/scopes/class.d.ts.map +1 -0
- package/dist/src/scopes/class.js +11 -0
- package/dist/src/scopes/class.js.map +1 -0
- package/dist/src/scopes/contexts.d.ts +9 -0
- package/dist/src/scopes/contexts.d.ts.map +1 -0
- package/dist/src/scopes/contexts.js +34 -0
- package/dist/src/scopes/contexts.js.map +1 -0
- package/dist/src/scopes/csharp.d.ts +10 -0
- package/dist/src/scopes/csharp.d.ts.map +1 -0
- package/dist/src/scopes/csharp.js +15 -0
- package/dist/src/scopes/csharp.js.map +1 -0
- package/dist/src/scopes/factories.d.ts +9 -0
- package/dist/src/scopes/factories.d.ts.map +1 -0
- package/dist/src/scopes/factories.js +24 -0
- package/dist/src/scopes/factories.js.map +1 -0
- package/dist/src/scopes/index.d.ts +10 -0
- package/dist/src/scopes/index.d.ts.map +1 -0
- package/dist/src/scopes/index.js +10 -0
- package/dist/src/scopes/index.js.map +1 -0
- package/dist/src/scopes/lexical.d.ts +7 -0
- package/dist/src/scopes/lexical.d.ts.map +1 -0
- package/dist/src/scopes/lexical.js +8 -0
- package/dist/src/scopes/lexical.js.map +1 -0
- package/dist/src/scopes/method.d.ts +9 -0
- package/dist/src/scopes/method.d.ts.map +1 -0
- package/dist/src/scopes/method.js +14 -0
- package/dist/src/scopes/method.js.map +1 -0
- package/dist/src/scopes/named-type.d.ts +22 -0
- package/dist/src/scopes/named-type.d.ts.map +1 -0
- package/dist/src/scopes/named-type.js +33 -0
- package/dist/src/scopes/named-type.js.map +1 -0
- package/dist/src/scopes/namespace.d.ts +11 -0
- package/dist/src/scopes/namespace.d.ts.map +1 -0
- package/dist/src/scopes/namespace.js +39 -0
- package/dist/src/scopes/namespace.js.map +1 -0
- package/dist/src/scopes/source-file.d.ts +16 -0
- package/dist/src/scopes/source-file.d.ts.map +1 -0
- package/dist/src/scopes/source-file.js +44 -0
- package/dist/src/scopes/source-file.js.map +1 -0
- package/dist/src/symbols/csharp.d.ts +87 -0
- package/dist/src/symbols/csharp.d.ts.map +1 -0
- package/dist/src/symbols/csharp.js +246 -0
- package/dist/src/symbols/csharp.js.map +1 -0
- package/dist/src/symbols/factories.d.ts +25 -0
- package/dist/src/symbols/factories.d.ts.map +1 -0
- package/dist/src/symbols/factories.js +93 -0
- package/dist/src/symbols/factories.js.map +1 -0
- package/dist/src/symbols/index.d.ts +5 -2
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +6 -2
- package/dist/src/symbols/index.js.map +1 -0
- package/dist/src/symbols/method.d.ts +13 -0
- package/dist/src/symbols/method.d.ts.map +1 -0
- package/dist/src/symbols/method.js +16 -0
- package/dist/src/symbols/method.js.map +1 -0
- package/dist/src/symbols/named-type.d.ts +19 -0
- package/dist/src/symbols/named-type.d.ts.map +1 -0
- package/dist/src/symbols/named-type.js +31 -0
- package/dist/src/symbols/named-type.js.map +1 -0
- package/dist/src/symbols/namespace.d.ts +22 -0
- package/dist/src/symbols/namespace.d.ts.map +1 -0
- package/dist/src/symbols/namespace.js +45 -0
- package/dist/src/symbols/namespace.js.map +1 -0
- package/dist/src/symbols/reference.d.ts +2 -2
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +50 -44
- package/dist/src/symbols/reference.js.map +1 -0
- package/dist/test/project-directory.test.js +20 -19
- package/dist/test/project-directory.test.js.map +1 -0
- package/dist/test/using.test.js +23 -21
- package/dist/test/using.test.js.map +1 -0
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +7 -4
- package/dist/test/utils.js.map +1 -0
- package/dist/test/vitest.setup.js +2 -1
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -6
- package/src/components/Declaration.tsx +3 -6
- package/src/components/Reference.tsx +3 -1
- package/src/components/UsingDirective.tsx +12 -2
- package/src/components/access-expression/access-expression.test.tsx +284 -0
- package/src/components/access-expression/access-expression.tsx +375 -0
- package/src/components/access-expression/part-descriptors.ts +175 -0
- package/src/components/class/declaration.test.tsx +142 -150
- package/src/components/class/declaration.tsx +20 -32
- package/src/components/constructor/constructor.test.tsx +10 -16
- package/src/components/constructor/constructor.tsx +13 -32
- package/src/components/enum/declaration.ref.test.tsx +93 -0
- package/src/components/enum/declaration.test.tsx +34 -0
- package/src/components/enum/declaration.tsx +65 -0
- package/src/components/enum/member.test.tsx +24 -0
- package/src/components/enum/member.tsx +36 -0
- package/src/components/field/field.test.tsx +7 -7
- package/src/components/field/field.tsx +12 -22
- package/src/components/index.ts +7 -3
- package/src/components/interface/declaration.test.tsx +26 -32
- package/src/components/interface/declaration.tsx +16 -18
- package/src/components/interface/method.test.tsx +38 -44
- package/src/components/interface/method.tsx +7 -20
- package/src/components/interface/property.test.tsx +11 -11
- package/src/components/interface/property.tsx +15 -34
- package/src/components/invocation-expression/invocation-expression.test.tsx +101 -0
- package/src/components/invocation-expression/invocation-expression.tsx +60 -0
- package/src/components/lexical-scope.tsx +29 -0
- package/src/components/method/method.test.tsx +11 -11
- package/src/components/method/method.tsx +12 -23
- package/src/components/method-scope.tsx +27 -0
- package/src/components/namespace-scopes.tsx +44 -0
- package/src/components/namespace.ref.test.tsx +139 -0
- package/src/components/namespace.test.tsx +52 -0
- package/src/components/namespace.tsx +45 -0
- package/src/components/parameters/parameters.test.tsx +117 -0
- package/src/components/parameters/parameters.tsx +11 -23
- package/src/components/property/property.test.tsx +14 -14
- package/src/components/property/property.tsx +23 -41
- package/src/components/record/declaration.test.tsx +47 -3
- package/src/components/record/declaration.tsx +34 -11
- package/src/components/source-file/source-file.test.tsx +96 -0
- package/src/components/source-file/source-file.tsx +98 -0
- package/src/components/struct/declaration.test.tsx +16 -22
- package/src/components/struct/declaration.tsx +4 -6
- package/src/components/type-parameters/type-parameter.tsx +14 -11
- package/src/components/type-parameters/type-parameters.test.tsx +4 -4
- package/src/components/var/declaration.test.tsx +8 -14
- package/src/components/var/declaration.tsx +12 -6
- package/src/contexts/format-options.ts +14 -0
- package/src/contexts/global-namespace.ts +29 -0
- package/src/contexts/namespace.ts +13 -0
- package/src/index.ts +2 -0
- package/src/modifiers.ts +14 -0
- package/src/scopes/class.ts +12 -0
- package/src/scopes/contexts.ts +45 -0
- package/src/scopes/csharp.ts +23 -0
- package/src/scopes/factories.ts +45 -0
- package/src/scopes/index.ts +9 -0
- package/src/scopes/lexical.ts +10 -0
- package/src/scopes/method.ts +22 -0
- package/src/scopes/named-type.ts +44 -0
- package/src/scopes/namespace.ts +59 -0
- package/src/scopes/source-file.ts +67 -0
- package/src/symbols/csharp.ts +339 -0
- package/src/symbols/factories.ts +215 -0
- package/src/symbols/index.ts +5 -2
- package/src/symbols/method.ts +26 -0
- package/src/symbols/named-type.ts +54 -0
- package/src/symbols/namespace.ts +62 -0
- package/src/symbols/reference.tsx +64 -0
- package/temp/api.json +6919 -2532
- package/test/project-directory.test.tsx +14 -16
- package/test/using.test.tsx +21 -21
- package/test/utils.tsx +2 -1
- package/tsconfig.json +4 -1
- package/tsdoc-metadata.json +1 -1
- package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
- package/dist/src/components/EnumDeclaration.js +0 -85
- package/dist/src/components/Namespace.d.ts +0 -11
- package/dist/src/components/Namespace.d.ts.map +0 -1
- package/dist/src/components/Namespace.js +0 -33
- package/dist/src/components/SourceFile.d.ts +0 -14
- package/dist/src/components/SourceFile.d.ts.map +0 -1
- package/dist/src/components/SourceFile.js +0 -69
- package/dist/src/symbols/csharp-output-symbol.d.ts +0 -8
- package/dist/src/symbols/csharp-output-symbol.d.ts.map +0 -1
- package/dist/src/symbols/csharp-output-symbol.js +0 -19
- package/dist/src/symbols/scopes.d.ts +0 -14
- package/dist/src/symbols/scopes.d.ts.map +0 -1
- package/dist/src/symbols/scopes.js +0 -31
- package/dist/test/enum.test.d.ts +0 -2
- package/dist/test/enum.test.d.ts.map +0 -1
- package/dist/test/enum.test.js +0 -178
- package/dist/test/namespace.test.d.ts.map +0 -1
- package/dist/test/namespace.test.js +0 -81
- package/dist/test/sourcefile.test.d.ts +0 -2
- package/dist/test/sourcefile.test.d.ts.map +0 -1
- package/dist/test/sourcefile.test.js +0 -58
- package/src/components/EnumDeclaration.tsx +0 -99
- package/src/components/Namespace.tsx +0 -35
- package/src/components/SourceFile.tsx +0 -78
- package/src/symbols/csharp-output-symbol.ts +0 -22
- package/src/symbols/reference.ts +0 -65
- package/src/symbols/scopes.ts +0 -41
- package/test/enum.test.tsx +0 -149
- package/test/namespace.test.tsx +0 -55
- package/test/sourcefile.test.tsx +0 -47
- /package/dist/{test → src/components}/namespace.test.d.ts +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Constructor } from "#components/constructor/constructor.jsx";
|
|
2
|
+
import { EnumDeclaration } from "#components/enum/declaration.jsx";
|
|
3
|
+
import { EnumMember } from "#components/enum/member.jsx";
|
|
1
4
|
import {
|
|
2
5
|
Children,
|
|
3
6
|
code,
|
|
@@ -6,28 +9,21 @@ import {
|
|
|
6
9
|
NamePolicyContext,
|
|
7
10
|
Output,
|
|
8
11
|
refkey,
|
|
9
|
-
render,
|
|
10
12
|
} from "@alloy-js/core";
|
|
11
13
|
import * as coretest from "@alloy-js/core/testing";
|
|
12
14
|
import { describe, expect, it } from "vitest";
|
|
13
|
-
import {
|
|
15
|
+
import { TestNamespace, toSourceText } from "../../../test/utils.jsx";
|
|
14
16
|
import { createCSharpNamePolicy } from "../../name-policy.js";
|
|
15
17
|
import { Attribute } from "../attributes/attributes.jsx";
|
|
16
18
|
import { Field } from "../field/field.jsx";
|
|
17
19
|
import { Method } from "../method/method.jsx";
|
|
18
|
-
import { Namespace } from "../Namespace.jsx";
|
|
19
20
|
import { Property } from "../property/property.jsx";
|
|
20
|
-
import { SourceFile } from "../
|
|
21
|
-
import { Constructor, EnumDeclaration, EnumMember } from "../stc/index.js";
|
|
21
|
+
import { SourceFile } from "../source-file/source-file.jsx";
|
|
22
22
|
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
23
23
|
import { ClassDeclaration } from "./declaration.jsx";
|
|
24
24
|
|
|
25
25
|
function Wrapper({ children }: { children: Children }) {
|
|
26
|
-
return
|
|
27
|
-
<TestNamespace>
|
|
28
|
-
<SourceFile path="Test.cs">{children}</SourceFile>
|
|
29
|
-
</TestNamespace>
|
|
30
|
-
);
|
|
26
|
+
return <TestNamespace>{children}</TestNamespace>;
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
it("declares class with no members", () => {
|
|
@@ -70,6 +66,24 @@ describe("modifiers", () => {
|
|
|
70
66
|
public abstract partial class TestClass;
|
|
71
67
|
`);
|
|
72
68
|
});
|
|
69
|
+
|
|
70
|
+
it("places visibility, attributes, and modifiers in the correct order", () => {
|
|
71
|
+
expect(
|
|
72
|
+
<TestNamespace>
|
|
73
|
+
<ClassDeclaration
|
|
74
|
+
partial
|
|
75
|
+
public
|
|
76
|
+
abstract
|
|
77
|
+
sealed
|
|
78
|
+
name="TestClass"
|
|
79
|
+
attributes={[<Attribute name="Test" />]}
|
|
80
|
+
/>
|
|
81
|
+
</TestNamespace>,
|
|
82
|
+
).toRenderTo(`
|
|
83
|
+
[Test]
|
|
84
|
+
public abstract sealed partial class TestClass;
|
|
85
|
+
`);
|
|
86
|
+
});
|
|
73
87
|
});
|
|
74
88
|
|
|
75
89
|
describe("base", () => {
|
|
@@ -109,45 +123,43 @@ describe("base", () => {
|
|
|
109
123
|
});
|
|
110
124
|
|
|
111
125
|
it("declares class with some members", () => {
|
|
112
|
-
const
|
|
113
|
-
<
|
|
114
|
-
<
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
const tree = (
|
|
127
|
+
<TestNamespace>
|
|
128
|
+
<ClassDeclaration public name="TestClass">
|
|
129
|
+
<List>
|
|
130
|
+
<Field public name="MemberOne" type="string" />
|
|
131
|
+
<Field public name="MemberTwo" type="int" />
|
|
132
|
+
</List>
|
|
133
|
+
</ClassDeclaration>
|
|
134
|
+
</TestNamespace>
|
|
119
135
|
);
|
|
120
136
|
|
|
121
|
-
expect(
|
|
122
|
-
|
|
137
|
+
expect(tree).toRenderTo(coretest.d`
|
|
138
|
+
public class TestClass
|
|
123
139
|
{
|
|
124
|
-
public
|
|
125
|
-
|
|
126
|
-
public string MemberOne;
|
|
127
|
-
public int MemberTwo;
|
|
128
|
-
}
|
|
140
|
+
public string MemberOne;
|
|
141
|
+
public int MemberTwo;
|
|
129
142
|
}
|
|
130
143
|
`);
|
|
131
144
|
});
|
|
132
145
|
|
|
133
146
|
it("declares class with some methods", () => {
|
|
134
|
-
const
|
|
135
|
-
<
|
|
136
|
-
<
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
const tree = (
|
|
148
|
+
<TestNamespace>
|
|
149
|
+
<ClassDeclaration public name="TestClass">
|
|
150
|
+
<List>
|
|
151
|
+
<Method public name="MethodOne" />
|
|
152
|
+
<Method private virtual name="MethodTwo" />
|
|
153
|
+
</List>
|
|
154
|
+
</ClassDeclaration>
|
|
155
|
+
</TestNamespace>
|
|
141
156
|
);
|
|
142
157
|
|
|
143
|
-
expect(
|
|
144
|
-
|
|
158
|
+
expect(tree).toRenderTo(coretest.d`
|
|
159
|
+
public class TestClass
|
|
145
160
|
{
|
|
146
|
-
public
|
|
147
|
-
{
|
|
148
|
-
public void MethodOne() {}
|
|
149
|
-
private virtual void MethodTwo() {}
|
|
150
|
-
}
|
|
161
|
+
public void MethodOne() {}
|
|
162
|
+
private virtual void MethodTwo() {}
|
|
151
163
|
}
|
|
152
164
|
`);
|
|
153
165
|
});
|
|
@@ -168,59 +180,52 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
168
180
|
},
|
|
169
181
|
];
|
|
170
182
|
|
|
171
|
-
|
|
183
|
+
expect(
|
|
172
184
|
<Output namePolicy={createCSharpNamePolicy()}>
|
|
173
|
-
<
|
|
174
|
-
<
|
|
175
|
-
<
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
<SourceFile path="Test.cs">
|
|
186
|
+
<EnumDeclaration public name="TestEnum" refkey={enumTypeRefkey}>
|
|
187
|
+
<List comma hardline>
|
|
188
|
+
<EnumMember name="One" />
|
|
189
|
+
<EnumMember name="Two" />
|
|
190
|
+
</List>
|
|
191
|
+
</EnumDeclaration>
|
|
192
|
+
<hbr />
|
|
193
|
+
<ClassDeclaration public name="TestInput" refkey={inputTypeRefkey} />
|
|
194
|
+
<hbr />
|
|
195
|
+
<ClassDeclaration
|
|
196
|
+
public
|
|
197
|
+
name="TestResult"
|
|
198
|
+
refkey={testResultTypeRefkey}
|
|
199
|
+
/>
|
|
200
|
+
<hbr />
|
|
201
|
+
<ClassDeclaration public name="TestClass">
|
|
202
|
+
<Field private name="MemberOne" type={enumTypeRefkey} />
|
|
183
203
|
<hbr />
|
|
184
|
-
<
|
|
204
|
+
<Method
|
|
185
205
|
public
|
|
186
|
-
name="
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
public
|
|
195
|
-
name="MethodOne"
|
|
196
|
-
parameters={params}
|
|
197
|
-
returns={testResultTypeRefkey}
|
|
198
|
-
>
|
|
199
|
-
return new {testResultTypeRefkey}();
|
|
200
|
-
</Method>
|
|
201
|
-
</ClassDeclaration>
|
|
202
|
-
</SourceFile>
|
|
203
|
-
</Namespace>
|
|
206
|
+
name="MethodOne"
|
|
207
|
+
parameters={params}
|
|
208
|
+
returns={testResultTypeRefkey}
|
|
209
|
+
>
|
|
210
|
+
return new {testResultTypeRefkey}();
|
|
211
|
+
</Method>
|
|
212
|
+
</ClassDeclaration>
|
|
213
|
+
</SourceFile>
|
|
204
214
|
</Output>,
|
|
205
|
-
)
|
|
206
|
-
|
|
207
|
-
expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
|
|
208
|
-
namespace TestCode
|
|
215
|
+
).toRenderTo(`
|
|
216
|
+
public enum TestEnum
|
|
209
217
|
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
+
One,
|
|
219
|
+
Two
|
|
220
|
+
}
|
|
221
|
+
public class TestInput;
|
|
222
|
+
public class TestResult;
|
|
223
|
+
public class TestClass
|
|
224
|
+
{
|
|
225
|
+
private TestEnum _memberOne;
|
|
226
|
+
public TestResult MethodOne(int intParam, TestInput bodyParam)
|
|
218
227
|
{
|
|
219
|
-
|
|
220
|
-
public TestResult MethodOne(int intParam, TestInput bodyParam)
|
|
221
|
-
{
|
|
222
|
-
return new TestResult();
|
|
223
|
-
}
|
|
228
|
+
return new TestResult();
|
|
224
229
|
}
|
|
225
230
|
}
|
|
226
231
|
`);
|
|
@@ -241,27 +246,22 @@ describe("with type parameters", () => {
|
|
|
241
246
|
|
|
242
247
|
expect(
|
|
243
248
|
<TestNamespace>
|
|
244
|
-
<
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
>
|
|
250
|
-
<
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
</ClassDeclaration>
|
|
255
|
-
</SourceFile>
|
|
249
|
+
<ClassDeclaration
|
|
250
|
+
public
|
|
251
|
+
name="TestClass"
|
|
252
|
+
typeParameters={typeParameters}
|
|
253
|
+
>
|
|
254
|
+
<List>
|
|
255
|
+
<Property name="PropA" type={typeParameters[0].refkey} get set />
|
|
256
|
+
<Property name="PropB" type={typeParameters[1].refkey} get set />
|
|
257
|
+
</List>
|
|
258
|
+
</ClassDeclaration>
|
|
256
259
|
</TestNamespace>,
|
|
257
260
|
).toRenderTo(`
|
|
258
|
-
|
|
261
|
+
public class TestClass<T, U>
|
|
259
262
|
{
|
|
260
|
-
|
|
261
|
-
{
|
|
262
|
-
T PropA { get; set; }
|
|
263
|
-
U PropB { get; set; }
|
|
264
|
-
}
|
|
263
|
+
T PropA { get; set; }
|
|
264
|
+
U PropB { get; set; }
|
|
265
265
|
}
|
|
266
266
|
`);
|
|
267
267
|
});
|
|
@@ -290,10 +290,10 @@ describe("with type parameters", () => {
|
|
|
290
290
|
</TestNamespace>,
|
|
291
291
|
).toRenderTo(`
|
|
292
292
|
public class TestClass<T, U>
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
where T : IFoo
|
|
294
|
+
where U : IBar
|
|
295
295
|
{
|
|
296
|
-
|
|
296
|
+
// Body
|
|
297
297
|
}
|
|
298
298
|
`);
|
|
299
299
|
});
|
|
@@ -308,25 +308,24 @@ it("declares class with invalid members", () => {
|
|
|
308
308
|
);
|
|
309
309
|
|
|
310
310
|
expect(() => toSourceText(decl)).toThrow(
|
|
311
|
-
"
|
|
311
|
+
"EnumMember must be used within an EnumDeclaration.",
|
|
312
312
|
);
|
|
313
313
|
});
|
|
314
314
|
|
|
315
315
|
describe("constructor", () => {
|
|
316
316
|
it("declares with constructor", () => {
|
|
317
|
-
const
|
|
318
|
-
<
|
|
319
|
-
<
|
|
320
|
-
|
|
317
|
+
const tree = (
|
|
318
|
+
<TestNamespace>
|
|
319
|
+
<ClassDeclaration public name="TestClass">
|
|
320
|
+
<Constructor public />
|
|
321
|
+
</ClassDeclaration>
|
|
322
|
+
</TestNamespace>
|
|
321
323
|
);
|
|
322
324
|
|
|
323
|
-
expect(
|
|
324
|
-
|
|
325
|
+
expect(tree).toRenderTo(coretest.d`
|
|
326
|
+
public class TestClass
|
|
325
327
|
{
|
|
326
|
-
public
|
|
327
|
-
{
|
|
328
|
-
public TestClass() {}
|
|
329
|
-
}
|
|
328
|
+
public TestClass() {}
|
|
330
329
|
}
|
|
331
330
|
`);
|
|
332
331
|
});
|
|
@@ -350,33 +349,32 @@ describe("constructor", () => {
|
|
|
350
349
|
},
|
|
351
350
|
];
|
|
352
351
|
|
|
353
|
-
const
|
|
354
|
-
<
|
|
355
|
-
<
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
352
|
+
const tree = (
|
|
353
|
+
<TestNamespace>
|
|
354
|
+
<ClassDeclaration public name="TestClass">
|
|
355
|
+
<Field private name="name" type="string" refkey={thisNameRefkey} />
|
|
356
|
+
<hbr />
|
|
357
|
+
<Field private name="size" type="int" refkey={thisSizeRefkey} />
|
|
358
|
+
<hbr />
|
|
359
|
+
<Constructor public parameters={ctorParams}>
|
|
360
|
+
{thisNameRefkey} = {paramNameRefkey};<hbr />
|
|
361
|
+
{thisSizeRefkey} = {paramSizeRefkey};
|
|
362
|
+
</Constructor>
|
|
363
|
+
</ClassDeclaration>
|
|
364
|
+
</TestNamespace>
|
|
364
365
|
);
|
|
365
366
|
|
|
366
367
|
// TODO: assignments to members should have this. prefix
|
|
367
368
|
// e.g. this.name = name;
|
|
368
|
-
expect(
|
|
369
|
-
|
|
369
|
+
expect(tree).toRenderTo(coretest.d`
|
|
370
|
+
public class TestClass
|
|
370
371
|
{
|
|
371
|
-
|
|
372
|
+
private string _name;
|
|
373
|
+
private int _size;
|
|
374
|
+
public TestClass(string name, int size)
|
|
372
375
|
{
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
public TestClass(string name, int size)
|
|
376
|
-
{
|
|
377
|
-
_name = name;
|
|
378
|
-
_size = size;
|
|
379
|
-
}
|
|
376
|
+
_name = name;
|
|
377
|
+
_size = size;
|
|
380
378
|
}
|
|
381
379
|
}
|
|
382
380
|
`);
|
|
@@ -415,12 +413,9 @@ describe("constructor", () => {
|
|
|
415
413
|
</ClassDeclaration>
|
|
416
414
|
</Wrapper>,
|
|
417
415
|
).toRenderTo(`
|
|
418
|
-
|
|
416
|
+
public class TestClass(string name, int size)
|
|
419
417
|
{
|
|
420
|
-
|
|
421
|
-
{
|
|
422
|
-
string PrettyName { get; } = $"{name} {size}";
|
|
423
|
-
}
|
|
418
|
+
string PrettyName { get; } = $"{name} {size}";
|
|
424
419
|
}
|
|
425
420
|
`);
|
|
426
421
|
});
|
|
@@ -441,12 +436,9 @@ describe("constructor", () => {
|
|
|
441
436
|
</NamePolicyContext.Provider>
|
|
442
437
|
</Wrapper>,
|
|
443
438
|
).toRenderTo(`
|
|
444
|
-
|
|
439
|
+
public class TestClass(string name)
|
|
445
440
|
{
|
|
446
|
-
|
|
447
|
-
{
|
|
448
|
-
string name_2;
|
|
449
|
-
}
|
|
441
|
+
string name_2;
|
|
450
442
|
}
|
|
451
443
|
`);
|
|
452
444
|
});
|
|
@@ -474,8 +466,8 @@ it("supports class member doc comments", () => {
|
|
|
474
466
|
/// This is a test
|
|
475
467
|
class Test
|
|
476
468
|
{
|
|
477
|
-
|
|
478
|
-
|
|
469
|
+
/// This is a member
|
|
470
|
+
public int Member;
|
|
479
471
|
}
|
|
480
472
|
`);
|
|
481
473
|
});
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
DeclarationProps,
|
|
6
6
|
join,
|
|
7
7
|
Name,
|
|
8
|
+
Namekey,
|
|
8
9
|
Refkey,
|
|
9
10
|
Scope,
|
|
10
11
|
} from "@alloy-js/core";
|
|
@@ -14,9 +15,8 @@ import {
|
|
|
14
15
|
getAccessModifier,
|
|
15
16
|
makeModifiers,
|
|
16
17
|
} from "../../modifiers.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { CSharpMemberScope } from "../../symbols/scopes.js";
|
|
18
|
+
import { createClassScope } from "../../scopes/factories.js";
|
|
19
|
+
import { createNamedTypeSymbol } from "../../symbols/factories.js";
|
|
20
20
|
import { AttributeList, AttributesProp } from "../attributes/attributes.jsx";
|
|
21
21
|
import { DocWhen } from "../doc/comment.jsx";
|
|
22
22
|
import { ParameterProps, Parameters } from "../parameters/parameters.jsx";
|
|
@@ -33,9 +33,9 @@ export interface ClassModifiers {
|
|
|
33
33
|
|
|
34
34
|
const getClassModifiers = makeModifiers<ClassModifiers>([
|
|
35
35
|
"abstract",
|
|
36
|
-
"partial",
|
|
37
36
|
"sealed",
|
|
38
37
|
"static",
|
|
38
|
+
"partial",
|
|
39
39
|
]);
|
|
40
40
|
|
|
41
41
|
// properties for creating a class
|
|
@@ -43,7 +43,7 @@ export interface ClassDeclarationProps
|
|
|
43
43
|
extends Omit<DeclarationProps, "nameKind">,
|
|
44
44
|
AccessModifiers,
|
|
45
45
|
ClassModifiers {
|
|
46
|
-
name: string;
|
|
46
|
+
name: string | Namekey;
|
|
47
47
|
/** Doc comment */
|
|
48
48
|
doc?: Children;
|
|
49
49
|
refkey?: Refkey;
|
|
@@ -130,19 +130,11 @@ export interface ClassDeclarationProps
|
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
132
132
|
export function ClassDeclaration(props: ClassDeclarationProps) {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
const thisClassSymbol = new CSharpOutputSymbol(name, {
|
|
133
|
+
const thisClassSymbol = createNamedTypeSymbol(props.name, "class", {
|
|
136
134
|
refkeys: props.refkey,
|
|
137
135
|
});
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
// members will automatically "inherit" this scope so
|
|
141
|
-
// that refkeys to them will produce the fully-qualified
|
|
142
|
-
// name e.g. Foo.Bar.
|
|
143
|
-
const thisClassScope = new CSharpMemberScope("class-decl", {
|
|
144
|
-
owner: thisClassSymbol,
|
|
145
|
-
});
|
|
137
|
+
const thisClassScope = createClassScope(thisClassSymbol);
|
|
146
138
|
|
|
147
139
|
const bases = [
|
|
148
140
|
...(props.baseType ? [props.baseType] : []),
|
|
@@ -159,24 +151,20 @@ export function ClassDeclaration(props: ClassDeclarationProps) {
|
|
|
159
151
|
<DocWhen doc={props.doc} />
|
|
160
152
|
<AttributeList attributes={props.attributes} endline />
|
|
161
153
|
{modifiers}class <Name />
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
<Scope value={thisClassScope}>
|
|
155
|
+
{props.typeParameters && (
|
|
156
|
+
<TypeParameters parameters={props.typeParameters} />
|
|
157
|
+
)}
|
|
158
|
+
{props.primaryConstructor && (
|
|
167
159
|
<Parameters parameters={props.primaryConstructor} />
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
<Block newline>
|
|
177
|
-
<Scope value={thisClassScope}>{props.children}</Scope>
|
|
178
|
-
</Block>
|
|
179
|
-
)}
|
|
160
|
+
)}
|
|
161
|
+
{base}
|
|
162
|
+
{props.typeParameters && (
|
|
163
|
+
<TypeParameterConstraints parameters={props.typeParameters} />
|
|
164
|
+
)}
|
|
165
|
+
{!props.children && ";"}
|
|
166
|
+
{props.children && <Block newline>{props.children}</Block>}
|
|
167
|
+
</Scope>
|
|
180
168
|
</Declaration>
|
|
181
169
|
);
|
|
182
170
|
}
|
|
@@ -2,7 +2,6 @@ import { refkey } from "@alloy-js/core";
|
|
|
2
2
|
import { expect, it } from "vitest";
|
|
3
3
|
import { TestNamespace } from "../../../test/utils.jsx";
|
|
4
4
|
import { ClassDeclaration } from "../class/declaration.jsx";
|
|
5
|
-
import { SourceFile } from "../SourceFile.jsx";
|
|
6
5
|
import { Constructor } from "./constructor.jsx";
|
|
7
6
|
|
|
8
7
|
it("reference constructor parameters in body", () => {
|
|
@@ -16,25 +15,20 @@ it("reference constructor parameters in body", () => {
|
|
|
16
15
|
|
|
17
16
|
expect(
|
|
18
17
|
<TestNamespace>
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</ClassDeclaration>
|
|
26
|
-
</SourceFile>
|
|
18
|
+
<ClassDeclaration public name="TestClass">
|
|
19
|
+
<Constructor public parameters={ctorParams}>
|
|
20
|
+
{paramNameRefkey};<hbr />
|
|
21
|
+
{paramSizeRefkey};
|
|
22
|
+
</Constructor>
|
|
23
|
+
</ClassDeclaration>
|
|
27
24
|
</TestNamespace>,
|
|
28
25
|
).toRenderTo(`
|
|
29
|
-
|
|
26
|
+
public class TestClass
|
|
30
27
|
{
|
|
31
|
-
public
|
|
28
|
+
public TestClass(string name, int size)
|
|
32
29
|
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
name;
|
|
36
|
-
size;
|
|
37
|
-
}
|
|
30
|
+
name;
|
|
31
|
+
size;
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
`);
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Declaration,
|
|
4
|
-
Name,
|
|
5
|
-
Refkey,
|
|
6
|
-
refkey,
|
|
7
|
-
Scope,
|
|
8
|
-
} from "@alloy-js/core";
|
|
1
|
+
import { MethodScope } from "#components/method-scope.jsx";
|
|
2
|
+
import { Block, MemberDeclaration, MemberName, Refkey } from "@alloy-js/core";
|
|
9
3
|
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
10
4
|
import {
|
|
11
5
|
AccessModifiers,
|
|
12
6
|
computeModifiersPrefix,
|
|
13
7
|
getAccessModifier,
|
|
14
8
|
} from "../../modifiers.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
|
|
9
|
+
import { useNamedTypeScope } from "../../scopes/contexts.js";
|
|
10
|
+
import { MethodSymbol } from "../../symbols/method.js";
|
|
18
11
|
import { ParameterProps, Parameters } from "../parameters/parameters.jsx";
|
|
19
12
|
|
|
20
13
|
/**
|
|
@@ -32,36 +25,24 @@ export interface ConstructorProps extends AccessModifiers {
|
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
export function Constructor(props: ConstructorProps) {
|
|
35
|
-
const scope =
|
|
36
|
-
if (
|
|
37
|
-
scope.kind !== "member" ||
|
|
38
|
-
(scope.name !== "class-decl" && scope.name !== "struct-decl")
|
|
39
|
-
) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
"can't define a class method outside of a class or struct scope",
|
|
42
|
-
);
|
|
43
|
-
}
|
|
28
|
+
const scope = useNamedTypeScope();
|
|
44
29
|
|
|
45
|
-
const name =
|
|
46
|
-
const ctorSymbol = new CSharpOutputSymbol(name, {
|
|
47
|
-
scope,
|
|
48
|
-
refkeys: props.refkey ?? refkey(name),
|
|
49
|
-
});
|
|
30
|
+
const name = scope.ownerSymbol.name;
|
|
50
31
|
|
|
51
|
-
const
|
|
52
|
-
|
|
32
|
+
const ctorSymbol = new MethodSymbol(name, scope.members, "constructor", {
|
|
33
|
+
refkeys: props.refkey,
|
|
53
34
|
});
|
|
54
35
|
|
|
55
36
|
const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
|
|
56
37
|
|
|
57
38
|
return (
|
|
58
|
-
<
|
|
59
|
-
<
|
|
39
|
+
<MemberDeclaration symbol={ctorSymbol}>
|
|
40
|
+
<MethodScope>
|
|
60
41
|
{modifiers}
|
|
61
|
-
<
|
|
42
|
+
<MemberName />
|
|
62
43
|
<Parameters parameters={props.parameters} />
|
|
63
44
|
<Block newline>{props.children}</Block>
|
|
64
|
-
</
|
|
65
|
-
</
|
|
45
|
+
</MethodScope>
|
|
46
|
+
</MemberDeclaration>
|
|
66
47
|
);
|
|
67
48
|
}
|