@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
|
@@ -3,7 +3,6 @@ import { Children } from "@alloy-js/core/jsx-runtime";
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import { TestNamespace } from "../../../test/utils.jsx";
|
|
5
5
|
import { Attribute } from "../attributes/attributes.jsx";
|
|
6
|
-
import { SourceFile } from "../SourceFile.jsx";
|
|
7
6
|
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
8
7
|
import { InterfaceDeclaration } from "./declaration.jsx";
|
|
9
8
|
import { InterfaceMethod } from "./method.jsx";
|
|
@@ -28,7 +27,7 @@ describe("modifiers", () => {
|
|
|
28
27
|
).toRenderTo(`
|
|
29
28
|
public interface TestInterface
|
|
30
29
|
{
|
|
31
|
-
|
|
30
|
+
${accessModifier} void MethodOne();
|
|
32
31
|
}
|
|
33
32
|
`);
|
|
34
33
|
},
|
|
@@ -44,7 +43,7 @@ describe("modifiers", () => {
|
|
|
44
43
|
).toRenderTo(`
|
|
45
44
|
public interface TestInterface
|
|
46
45
|
{
|
|
47
|
-
|
|
46
|
+
${methodModifier} void MethodOne();
|
|
48
47
|
}
|
|
49
48
|
`);
|
|
50
49
|
});
|
|
@@ -58,7 +57,7 @@ describe("modifiers", () => {
|
|
|
58
57
|
).toRenderTo(`
|
|
59
58
|
public interface TestInterface
|
|
60
59
|
{
|
|
61
|
-
|
|
60
|
+
public new Task MethodOne();
|
|
62
61
|
}
|
|
63
62
|
`);
|
|
64
63
|
});
|
|
@@ -72,7 +71,7 @@ it("applies PascalCase naming policy", () => {
|
|
|
72
71
|
).toRenderTo(`
|
|
73
72
|
public interface TestInterface
|
|
74
73
|
{
|
|
75
|
-
|
|
74
|
+
void MethodOne();
|
|
76
75
|
}
|
|
77
76
|
`);
|
|
78
77
|
});
|
|
@@ -102,7 +101,7 @@ it("defines params and return type", () => {
|
|
|
102
101
|
expect(res).toRenderTo(`
|
|
103
102
|
public interface TestInterface
|
|
104
103
|
{
|
|
105
|
-
|
|
104
|
+
public string MethodOne(int intParam, string stringParam);
|
|
106
105
|
}
|
|
107
106
|
`);
|
|
108
107
|
});
|
|
@@ -128,7 +127,7 @@ it("defines optional param", () => {
|
|
|
128
127
|
expect(res).toRenderTo(`
|
|
129
128
|
public interface TestInterface
|
|
130
129
|
{
|
|
131
|
-
|
|
130
|
+
public string MethodOne(int? intParam);
|
|
132
131
|
}
|
|
133
132
|
`);
|
|
134
133
|
});
|
|
@@ -154,7 +153,7 @@ it("defines optional param with default", () => {
|
|
|
154
153
|
expect(res).toRenderTo(`
|
|
155
154
|
public interface TestInterface
|
|
156
155
|
{
|
|
157
|
-
|
|
156
|
+
public string MethodOne(int intParam = 12);
|
|
158
157
|
}
|
|
159
158
|
`);
|
|
160
159
|
});
|
|
@@ -169,8 +168,8 @@ it("specify doc comment", () => {
|
|
|
169
168
|
).toRenderTo(`
|
|
170
169
|
interface Test
|
|
171
170
|
{
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
/// This is a test
|
|
172
|
+
void Method();
|
|
174
173
|
}
|
|
175
174
|
`);
|
|
176
175
|
});
|
|
@@ -183,8 +182,8 @@ it("specify attributes", () => {
|
|
|
183
182
|
).toRenderTo(`
|
|
184
183
|
public interface TestInterface
|
|
185
184
|
{
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
[Test]
|
|
186
|
+
void Test();
|
|
188
187
|
}
|
|
189
188
|
`);
|
|
190
189
|
});
|
|
@@ -204,30 +203,25 @@ describe("with type parameters", () => {
|
|
|
204
203
|
|
|
205
204
|
expect(
|
|
206
205
|
<TestNamespace>
|
|
207
|
-
<
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
</InterfaceDeclaration>
|
|
222
|
-
</SourceFile>
|
|
206
|
+
<InterfaceDeclaration public name="TestInterface">
|
|
207
|
+
<InterfaceMethod
|
|
208
|
+
name="Test"
|
|
209
|
+
public
|
|
210
|
+
typeParameters={typeParameters}
|
|
211
|
+
parameters={[
|
|
212
|
+
{
|
|
213
|
+
name: "paramA",
|
|
214
|
+
type: typeParameters[0].refkey,
|
|
215
|
+
},
|
|
216
|
+
]}
|
|
217
|
+
returns={typeParameters[0].refkey}
|
|
218
|
+
/>
|
|
219
|
+
</InterfaceDeclaration>
|
|
223
220
|
</TestNamespace>,
|
|
224
221
|
).toRenderTo(`
|
|
225
|
-
|
|
222
|
+
public interface TestInterface
|
|
226
223
|
{
|
|
227
|
-
public
|
|
228
|
-
{
|
|
229
|
-
public T Test<T, U>(T paramA);
|
|
230
|
-
}
|
|
224
|
+
public T Test<T, U>(T paramA);
|
|
231
225
|
}
|
|
232
226
|
`);
|
|
233
227
|
});
|
|
@@ -253,12 +247,12 @@ describe("with type parameters", () => {
|
|
|
253
247
|
).toRenderTo(`
|
|
254
248
|
public interface TestInterface
|
|
255
249
|
{
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
250
|
+
public void Test<T, U>()
|
|
251
|
+
where T : IFoo
|
|
252
|
+
where U : IBar
|
|
253
|
+
{
|
|
254
|
+
// Body
|
|
255
|
+
}
|
|
262
256
|
}
|
|
263
257
|
`);
|
|
264
258
|
});
|
|
@@ -274,19 +268,19 @@ describe("formatting", () => {
|
|
|
274
268
|
parameters={[
|
|
275
269
|
{
|
|
276
270
|
name: "message",
|
|
277
|
-
type: "Some.Quite.Long.Type.That.Will.Split",
|
|
271
|
+
type: "Some.Quite.Long.Type.That.Will.Split.At.One.Hundred.Chars.Line.Width",
|
|
278
272
|
},
|
|
279
273
|
]}
|
|
280
274
|
typeParameters={["T"]}
|
|
281
|
-
returns="Some.Quite.Long.Type.That.Will.Split"
|
|
275
|
+
returns="Some.Quite.Long.Type.That.Will.Split.At.One.Hundred.Chars.Line.Width"
|
|
282
276
|
/>
|
|
283
277
|
</Wrapper>,
|
|
284
278
|
).toRenderTo(`
|
|
285
279
|
public interface TestInterface
|
|
286
280
|
{
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
281
|
+
public Some.Quite.Long.Type.That.Will.Split.At.One.Hundred.Chars.Line.Width Handle<T>(
|
|
282
|
+
Some.Quite.Long.Type.That.Will.Split.At.One.Hundred.Chars.Line.Width message
|
|
283
|
+
);
|
|
290
284
|
}
|
|
291
285
|
`);
|
|
292
286
|
});
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Block,
|
|
3
3
|
Children,
|
|
4
4
|
MemberDeclaration,
|
|
5
|
-
|
|
5
|
+
MemberName,
|
|
6
6
|
Refkey,
|
|
7
7
|
Scope,
|
|
8
8
|
} from "@alloy-js/core";
|
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
getAccessModifier,
|
|
13
13
|
makeModifiers,
|
|
14
14
|
} from "../../modifiers.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
|
|
15
|
+
import { createMethodScope } from "../../scopes/factories.js";
|
|
16
|
+
import { createMethodSymbol } from "../../symbols/factories.js";
|
|
18
17
|
import { AttributeList, AttributesProp } from "../attributes/attributes.jsx";
|
|
19
18
|
import { DocWhen } from "../doc/comment.jsx";
|
|
20
19
|
import { ParameterProps, Parameters } from "../parameters/parameters.jsx";
|
|
@@ -76,23 +75,11 @@ export interface InterfaceMethodProps
|
|
|
76
75
|
|
|
77
76
|
// a C# interface method
|
|
78
77
|
export function InterfaceMethod(props: InterfaceMethodProps) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
if (scope.kind !== "member" || scope.name !== "interface-decl") {
|
|
82
|
-
throw new Error(
|
|
83
|
-
"can't define an interface method outside of an interface scope",
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const methodSymbol = new CSharpOutputSymbol(name, {
|
|
88
|
-
scope,
|
|
89
|
-
refkeys: props.refkey ?? refkey(props.name),
|
|
78
|
+
const methodSymbol = createMethodSymbol(props.name, {
|
|
79
|
+
refkeys: props.refkey,
|
|
90
80
|
});
|
|
91
81
|
|
|
92
|
-
|
|
93
|
-
const methodScope = new CSharpMemberScope("method-decl", {
|
|
94
|
-
owner: methodSymbol,
|
|
95
|
-
});
|
|
82
|
+
const methodScope = createMethodScope();
|
|
96
83
|
|
|
97
84
|
const modifiers = computeModifiersPrefix([
|
|
98
85
|
getAccessModifier(props),
|
|
@@ -105,7 +92,7 @@ export function InterfaceMethod(props: InterfaceMethodProps) {
|
|
|
105
92
|
<DocWhen doc={props.doc} />
|
|
106
93
|
<AttributeList attributes={props.attributes} endline />
|
|
107
94
|
{modifiers}
|
|
108
|
-
{props.returns ?? "void"}
|
|
95
|
+
{props.returns ?? "void"} <MemberName />
|
|
109
96
|
{props.typeParameters && (
|
|
110
97
|
<TypeParameters parameters={props.typeParameters} />
|
|
111
98
|
)}
|
|
@@ -30,7 +30,7 @@ describe("modifiers", () => {
|
|
|
30
30
|
).toRenderTo(`
|
|
31
31
|
public interface TestInterface
|
|
32
32
|
{
|
|
33
|
-
|
|
33
|
+
${accessModifier} string TestProp { get; }
|
|
34
34
|
}
|
|
35
35
|
`);
|
|
36
36
|
},
|
|
@@ -51,7 +51,7 @@ describe("modifiers", () => {
|
|
|
51
51
|
).toRenderTo(`
|
|
52
52
|
public interface TestInterface
|
|
53
53
|
{
|
|
54
|
-
|
|
54
|
+
${methodModifier} string TestProp { get; }
|
|
55
55
|
}
|
|
56
56
|
`);
|
|
57
57
|
});
|
|
@@ -65,7 +65,7 @@ describe("modifiers", () => {
|
|
|
65
65
|
).toRenderTo(`
|
|
66
66
|
public interface TestInterface
|
|
67
67
|
{
|
|
68
|
-
|
|
68
|
+
public new string TestProp { get; }
|
|
69
69
|
}
|
|
70
70
|
`);
|
|
71
71
|
});
|
|
@@ -79,7 +79,7 @@ it("applies PascalCase naming policy", () => {
|
|
|
79
79
|
).toRenderTo(`
|
|
80
80
|
public interface TestInterface
|
|
81
81
|
{
|
|
82
|
-
|
|
82
|
+
string TestProp { get; }
|
|
83
83
|
}
|
|
84
84
|
`);
|
|
85
85
|
});
|
|
@@ -92,7 +92,7 @@ it("has getter only", () => {
|
|
|
92
92
|
).toRenderTo(`
|
|
93
93
|
public interface TestInterface
|
|
94
94
|
{
|
|
95
|
-
|
|
95
|
+
string TestProp { get; }
|
|
96
96
|
}
|
|
97
97
|
`);
|
|
98
98
|
});
|
|
@@ -105,7 +105,7 @@ it("has setter only", () => {
|
|
|
105
105
|
).toRenderTo(`
|
|
106
106
|
public interface TestInterface
|
|
107
107
|
{
|
|
108
|
-
|
|
108
|
+
string TestProp { set; }
|
|
109
109
|
}
|
|
110
110
|
`);
|
|
111
111
|
});
|
|
@@ -117,7 +117,7 @@ it("has getter and setter", () => {
|
|
|
117
117
|
).toRenderTo(`
|
|
118
118
|
public interface TestInterface
|
|
119
119
|
{
|
|
120
|
-
|
|
120
|
+
string TestProp { get; set; }
|
|
121
121
|
}
|
|
122
122
|
`);
|
|
123
123
|
});
|
|
@@ -138,8 +138,8 @@ it("specify doc comment", () => {
|
|
|
138
138
|
).toRenderTo(`
|
|
139
139
|
interface Test
|
|
140
140
|
{
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
/// This is a test
|
|
142
|
+
string Method { get; set; }
|
|
143
143
|
}
|
|
144
144
|
`);
|
|
145
145
|
});
|
|
@@ -158,8 +158,8 @@ it("specify attributes", () => {
|
|
|
158
158
|
).toRenderTo(`
|
|
159
159
|
public interface TestInterface
|
|
160
160
|
{
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
[Test]
|
|
162
|
+
int Test { get; set; }
|
|
163
163
|
}
|
|
164
164
|
`);
|
|
165
165
|
});
|
|
@@ -3,9 +3,8 @@ import {
|
|
|
3
3
|
Children,
|
|
4
4
|
List,
|
|
5
5
|
MemberDeclaration,
|
|
6
|
-
|
|
6
|
+
MemberName,
|
|
7
7
|
Refkey,
|
|
8
|
-
Scope,
|
|
9
8
|
} from "@alloy-js/core";
|
|
10
9
|
import {
|
|
11
10
|
AccessModifiers,
|
|
@@ -13,9 +12,7 @@ import {
|
|
|
13
12
|
getAccessModifier,
|
|
14
13
|
makeModifiers,
|
|
15
14
|
} from "../../modifiers.js";
|
|
16
|
-
import {
|
|
17
|
-
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
18
|
-
import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
|
|
15
|
+
import { createPropertySymbol } from "../../symbols/factories.js";
|
|
19
16
|
import { AttributeList, AttributesProp } from "../attributes/attributes.jsx";
|
|
20
17
|
import { DocWhen } from "../doc/comment.jsx";
|
|
21
18
|
|
|
@@ -84,22 +81,8 @@ export interface InterfacePropertyProps
|
|
|
84
81
|
* ```
|
|
85
82
|
*/
|
|
86
83
|
export function InterfaceProperty(props: InterfacePropertyProps) {
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
if (scope.kind !== "member" || scope.name !== "interface-decl") {
|
|
90
|
-
throw new Error(
|
|
91
|
-
"can't define an interface method outside of an interface scope",
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const propertySymbol = new CSharpOutputSymbol(name, {
|
|
96
|
-
scope,
|
|
97
|
-
refkeys: props.refkey ?? refkey(props.name),
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// scope for property declaration
|
|
101
|
-
const propertyScope = new CSharpMemberScope("property-decl", {
|
|
102
|
-
owner: propertySymbol,
|
|
84
|
+
const propertySymbol = createPropertySymbol(props.name, {
|
|
85
|
+
refkeys: props.refkey,
|
|
103
86
|
});
|
|
104
87
|
|
|
105
88
|
const modifiers = computeModifiersPrefix([
|
|
@@ -109,19 +92,17 @@ export function InterfaceProperty(props: InterfacePropertyProps) {
|
|
|
109
92
|
// note that scope wraps the method decl so that the params get the correct scope
|
|
110
93
|
return (
|
|
111
94
|
<MemberDeclaration symbol={propertySymbol}>
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
</Block>
|
|
124
|
-
</Scope>
|
|
95
|
+
<DocWhen doc={props.doc} />
|
|
96
|
+
<AttributeList attributes={props.attributes} endline />
|
|
97
|
+
{modifiers}
|
|
98
|
+
{props.type}
|
|
99
|
+
{props.nullable && "?"} <MemberName />{" "}
|
|
100
|
+
<Block newline inline>
|
|
101
|
+
<List joiner=" ">
|
|
102
|
+
{props.get && "get;"}
|
|
103
|
+
{props.set && "set;"}
|
|
104
|
+
</List>
|
|
105
|
+
</Block>
|
|
125
106
|
</MemberDeclaration>
|
|
126
107
|
);
|
|
127
108
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ClassDeclaration } from "#components/class/declaration.jsx";
|
|
2
|
+
import { Method } from "#components/method/method.jsx";
|
|
3
|
+
import { TestNamespace } from "#test/utils.jsx";
|
|
4
|
+
import { namekey } from "@alloy-js/core";
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { InvocationExpression } from "./invocation-expression.jsx";
|
|
7
|
+
|
|
8
|
+
it("makes a call with no arguments", () => {
|
|
9
|
+
const template = <InvocationExpression target="Foo" />;
|
|
10
|
+
expect(template).toRenderTo(`Foo()`);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("makes a call with arguments", () => {
|
|
14
|
+
const template = (
|
|
15
|
+
<InvocationExpression target="Foo" args={["42", `"string"`]} />
|
|
16
|
+
);
|
|
17
|
+
expect(template).toRenderTo(`Foo(42, "string")`);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("makes a call with type parameters", () => {
|
|
21
|
+
const template = (
|
|
22
|
+
<InvocationExpression target="Foo" typeArgs={["Bar", "Baz"]} />
|
|
23
|
+
);
|
|
24
|
+
expect(template).toRenderTo(`Foo<Bar, Baz>()`);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("makes a call to a method", () => {
|
|
28
|
+
const cls = namekey("TestClass");
|
|
29
|
+
const method = namekey("Method");
|
|
30
|
+
const template = (
|
|
31
|
+
<TestNamespace>
|
|
32
|
+
<ClassDeclaration name={cls}>
|
|
33
|
+
<Method name={method}>return 1;</Method>
|
|
34
|
+
</ClassDeclaration>
|
|
35
|
+
<hbr />
|
|
36
|
+
<InvocationExpression target={method} />;
|
|
37
|
+
</TestNamespace>
|
|
38
|
+
);
|
|
39
|
+
expect(template).toRenderTo(`
|
|
40
|
+
class TestClass
|
|
41
|
+
{
|
|
42
|
+
void Method()
|
|
43
|
+
{
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
TestClass.Method();
|
|
48
|
+
`);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("formatting", () => {
|
|
52
|
+
it("doesn't break one long argument", () => {
|
|
53
|
+
const template = (
|
|
54
|
+
<InvocationExpression target="Foo" args={["oneLongArgument"]} />
|
|
55
|
+
);
|
|
56
|
+
expect(template).toRenderTo(`Foo(oneLongArgument)`, { printWidth: 10 });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("breaks multiple arguments", () => {
|
|
60
|
+
const template = (
|
|
61
|
+
<InvocationExpression
|
|
62
|
+
target="Foo"
|
|
63
|
+
args={["oneLongArgument", "anotherLongArgument"]}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
expect(template).toRenderTo(
|
|
67
|
+
`
|
|
68
|
+
Foo(
|
|
69
|
+
oneLongArgument,
|
|
70
|
+
anotherLongArgument
|
|
71
|
+
)
|
|
72
|
+
`,
|
|
73
|
+
{ printWidth: 10 },
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("doesn't break one long type argument", () => {
|
|
78
|
+
const template = (
|
|
79
|
+
<InvocationExpression target="Foo" typeArgs={["oneLongArgument"]} />
|
|
80
|
+
);
|
|
81
|
+
expect(template).toRenderTo(`Foo<oneLongArgument>()`, { printWidth: 10 });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("breaks multiple type arguments", () => {
|
|
85
|
+
const template = (
|
|
86
|
+
<InvocationExpression
|
|
87
|
+
target="Foo"
|
|
88
|
+
typeArgs={["oneLongArgument", "anotherLongArgument"]}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
expect(template).toRenderTo(
|
|
92
|
+
`
|
|
93
|
+
Foo<
|
|
94
|
+
oneLongArgument,
|
|
95
|
+
anotherLongArgument
|
|
96
|
+
>()
|
|
97
|
+
`,
|
|
98
|
+
{ printWidth: 10 },
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Children, For, Indent, Show, Wrap } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
export interface InvocationExpressionProps {
|
|
4
|
+
target: Children;
|
|
5
|
+
/**
|
|
6
|
+
* Arguments to pass to the invocation.
|
|
7
|
+
*/
|
|
8
|
+
args?: Children[];
|
|
9
|
+
/**
|
|
10
|
+
* Generic type arguments for the invocation.
|
|
11
|
+
*/
|
|
12
|
+
typeArgs?: Children[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A call to a function or method.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* ```jsx
|
|
21
|
+
* <InvocationExpression target="Foo" typeArgs={["T"]} args={["x"]} />
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Renders to:
|
|
25
|
+
*
|
|
26
|
+
* ```csharp
|
|
27
|
+
* Foo<T>("x");
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function InvocationExpression(props: InvocationExpressionProps) {
|
|
31
|
+
return (
|
|
32
|
+
<group>
|
|
33
|
+
{props.target}
|
|
34
|
+
<Show when={!!props.typeArgs && props.typeArgs.length > 0}>
|
|
35
|
+
{"<"}
|
|
36
|
+
<Wrap
|
|
37
|
+
when={props.typeArgs!.length > 1}
|
|
38
|
+
with={Indent}
|
|
39
|
+
props={{ softline: true, trailingBreak: true }}
|
|
40
|
+
>
|
|
41
|
+
<For each={props.typeArgs ?? []} comma line>
|
|
42
|
+
{(typeArg) => typeArg}
|
|
43
|
+
</For>
|
|
44
|
+
</Wrap>
|
|
45
|
+
{">"}
|
|
46
|
+
</Show>
|
|
47
|
+
(
|
|
48
|
+
<Wrap
|
|
49
|
+
when={!!props.args && props.args.length > 1}
|
|
50
|
+
with={Indent}
|
|
51
|
+
props={{ softline: true, trailingBreak: true }}
|
|
52
|
+
>
|
|
53
|
+
<For each={props.args ?? []} comma line>
|
|
54
|
+
{(arg) => arg}
|
|
55
|
+
</For>
|
|
56
|
+
</Wrap>
|
|
57
|
+
)
|
|
58
|
+
</group>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Scope, ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
|
|
2
|
+
import { useCSharpScope } from "../scopes/contexts.js";
|
|
3
|
+
import { CSharpLexicalScope } from "../scopes/lexical.js";
|
|
4
|
+
|
|
5
|
+
export interface LexicalScopePropsWithScopeValue extends ScopePropsWithValue {}
|
|
6
|
+
export interface LeixcalScopePropsWithScopeInfo extends ScopePropsWithInfo {}
|
|
7
|
+
|
|
8
|
+
export type LexicalScopeProps =
|
|
9
|
+
| LexicalScopePropsWithScopeValue
|
|
10
|
+
| LeixcalScopePropsWithScopeInfo;
|
|
11
|
+
|
|
12
|
+
export function LexicalScope(props: LexicalScopeProps) {
|
|
13
|
+
let scope;
|
|
14
|
+
if ("value" in props) {
|
|
15
|
+
if (!(props.value instanceof CSharpLexicalScope)) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"LexicalScope value must be a CSharpLexicalScope instance",
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
scope = props.value;
|
|
21
|
+
} else {
|
|
22
|
+
const parentScope = useCSharpScope();
|
|
23
|
+
scope = new CSharpLexicalScope(props.name ?? "lexical scope", parentScope, {
|
|
24
|
+
...props,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return <Scope value={scope}>{props.children}</Scope>;
|
|
29
|
+
}
|
|
@@ -23,7 +23,7 @@ describe("modifiers", () => {
|
|
|
23
23
|
).toRenderTo(`
|
|
24
24
|
public class TestClass
|
|
25
25
|
{
|
|
26
|
-
|
|
26
|
+
${accessModifier} void MethodOne() {}
|
|
27
27
|
}
|
|
28
28
|
`);
|
|
29
29
|
},
|
|
@@ -41,7 +41,7 @@ describe("modifiers", () => {
|
|
|
41
41
|
).toRenderTo(`
|
|
42
42
|
public class TestClass
|
|
43
43
|
{
|
|
44
|
-
|
|
44
|
+
${methodModifier} void MethodOne() {}
|
|
45
45
|
}
|
|
46
46
|
`);
|
|
47
47
|
},
|
|
@@ -55,7 +55,7 @@ describe("modifiers", () => {
|
|
|
55
55
|
).toRenderTo(`
|
|
56
56
|
public class TestClass
|
|
57
57
|
{
|
|
58
|
-
|
|
58
|
+
abstract void MethodOne();
|
|
59
59
|
}
|
|
60
60
|
`);
|
|
61
61
|
});
|
|
@@ -69,7 +69,7 @@ describe("modifiers", () => {
|
|
|
69
69
|
).toRenderTo(`
|
|
70
70
|
public class TestClass
|
|
71
71
|
{
|
|
72
|
-
|
|
72
|
+
async Task MethodOne() {}
|
|
73
73
|
}
|
|
74
74
|
`);
|
|
75
75
|
});
|
|
@@ -82,7 +82,7 @@ describe("modifiers", () => {
|
|
|
82
82
|
).toRenderTo(`
|
|
83
83
|
public class TestClass
|
|
84
84
|
{
|
|
85
|
-
|
|
85
|
+
public abstract async Task MethodOne();
|
|
86
86
|
}
|
|
87
87
|
`);
|
|
88
88
|
});
|
|
@@ -96,7 +96,7 @@ it("applies PascalCase naming policy", () => {
|
|
|
96
96
|
).toRenderTo(`
|
|
97
97
|
public class TestClass
|
|
98
98
|
{
|
|
99
|
-
|
|
99
|
+
void MethodOne() {}
|
|
100
100
|
}
|
|
101
101
|
`);
|
|
102
102
|
});
|
|
@@ -120,7 +120,7 @@ it("defines params and return type", () => {
|
|
|
120
120
|
expect(res).toRenderTo(`
|
|
121
121
|
public class TestClass
|
|
122
122
|
{
|
|
123
|
-
|
|
123
|
+
public string MethodOne(int intParam, string stringParam) {}
|
|
124
124
|
}
|
|
125
125
|
`);
|
|
126
126
|
});
|
|
@@ -135,8 +135,8 @@ it("specify doc comment", () => {
|
|
|
135
135
|
).toRenderTo(`
|
|
136
136
|
class Test
|
|
137
137
|
{
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
/// This is a test
|
|
139
|
+
void Method() {}
|
|
140
140
|
}
|
|
141
141
|
`);
|
|
142
142
|
});
|
|
@@ -153,8 +153,8 @@ it("use expression body form", () => {
|
|
|
153
153
|
).toRenderTo(`
|
|
154
154
|
class Test
|
|
155
155
|
{
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
/// This is a test
|
|
157
|
+
void Method() => this.MyProperty.Value;
|
|
158
158
|
}
|
|
159
159
|
`);
|
|
160
160
|
});
|