@alloy-js/csharp 0.19.0-dev.0 → 0.19.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/src/components/ClassMethod.d.ts +14 -0
  2. package/dist/src/components/ClassMethod.d.ts.map +1 -1
  3. package/dist/src/components/ClassMethod.js +1 -1
  4. package/dist/src/components/index.d.ts +1 -0
  5. package/dist/src/components/index.d.ts.map +1 -1
  6. package/dist/src/components/index.js +1 -0
  7. package/dist/src/components/interface/declaration.test.js +5 -5
  8. package/dist/src/components/interface/method.test.js +4 -4
  9. package/dist/src/components/property/property.d.ts.map +1 -1
  10. package/dist/src/components/property/property.js +1 -1
  11. package/dist/src/components/stc/index.d.ts +1 -0
  12. package/dist/src/components/stc/index.d.ts.map +1 -1
  13. package/dist/src/components/stc/index.js +2 -1
  14. package/dist/src/components/struct/declaration.d.ts +68 -0
  15. package/dist/src/components/struct/declaration.d.ts.map +1 -0
  16. package/dist/src/components/struct/declaration.js +78 -0
  17. package/dist/src/components/struct/declaration.test.d.ts +2 -0
  18. package/dist/src/components/struct/declaration.test.d.ts.map +1 -0
  19. package/dist/src/components/struct/declaration.test.js +171 -0
  20. package/dist/src/components/var/declaration.test.js +2 -2
  21. package/dist/src/name-policy.d.ts +1 -1
  22. package/dist/src/name-policy.d.ts.map +1 -1
  23. package/dist/src/name-policy.js +1 -0
  24. package/dist/test/class-declaration.test.js +5 -5
  25. package/dist/test/class-method.test.js +23 -0
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +3 -3
  28. package/src/components/ClassMethod.tsx +23 -1
  29. package/src/components/index.ts +1 -0
  30. package/src/components/interface/declaration.test.tsx +5 -5
  31. package/src/components/interface/method.test.tsx +4 -4
  32. package/src/components/property/property.tsx +3 -1
  33. package/src/components/stc/index.ts +1 -0
  34. package/src/components/struct/declaration.test.tsx +137 -0
  35. package/src/components/struct/declaration.tsx +129 -0
  36. package/src/components/var/declaration.test.tsx +2 -2
  37. package/src/name-policy.ts +2 -0
  38. package/temp/api.json +419 -1
  39. package/test/class-declaration.test.tsx +5 -5
  40. package/test/class-method.test.tsx +18 -0
package/temp/api.json CHANGED
@@ -1789,6 +1789,33 @@
1789
1789
  "endIndex": 2
1790
1790
  }
1791
1791
  },
1792
+ {
1793
+ "kind": "PropertySignature",
1794
+ "canonicalReference": "@alloy-js/csharp!ClassMethodProps#expression:member",
1795
+ "docComment": "/**\n * Use expression syntax for the method.\n *\n * @example\n * ```tsx\n * <ClassMethod name=\"MyMethod\" lambda>\n * this.MyProperty.Value;\n * </ClassMethod>\n * ```\n *\n * This will produce:\n * ```csharp\n * public void MyMethod() => this.MyProperty.Value;\n * ```\n *\n */\n",
1796
+ "excerptTokens": [
1797
+ {
1798
+ "kind": "Content",
1799
+ "text": "expression?: "
1800
+ },
1801
+ {
1802
+ "kind": "Content",
1803
+ "text": "boolean"
1804
+ },
1805
+ {
1806
+ "kind": "Content",
1807
+ "text": ";"
1808
+ }
1809
+ ],
1810
+ "isReadonly": false,
1811
+ "isOptional": true,
1812
+ "releaseTag": "Public",
1813
+ "name": "expression",
1814
+ "propertyTypeTokenRange": {
1815
+ "startIndex": 1,
1816
+ "endIndex": 2
1817
+ }
1818
+ },
1792
1819
  {
1793
1820
  "kind": "PropertySignature",
1794
1821
  "canonicalReference": "@alloy-js/csharp!ClassMethodProps#name:member",
@@ -2190,7 +2217,7 @@
2190
2217
  },
2191
2218
  {
2192
2219
  "kind": "Content",
2193
- "text": "\"class\" | \"constant\" | \"variable\" | \"enum\" | \"enum-member\" | \"function\" | \"interface\" | \"record\" | \"class-member-private\" | \"class-member-public\" | \"class-method\" | \"class-property\" | \"parameter\" | \"type-parameter\""
2220
+ "text": "\"class\" | \"constant\" | \"variable\" | \"struct\" | \"enum\" | \"enum-member\" | \"function\" | \"interface\" | \"record\" | \"class-member-private\" | \"class-member-public\" | \"class-method\" | \"class-property\" | \"parameter\" | \"type-parameter\""
2194
2221
  },
2195
2222
  {
2196
2223
  "kind": "Content",
@@ -8122,6 +8149,397 @@
8122
8149
  ],
8123
8150
  "extendsTokenRanges": []
8124
8151
  },
8152
+ {
8153
+ "kind": "Function",
8154
+ "canonicalReference": "@alloy-js/csharp!StructDeclaration:function(1)",
8155
+ "docComment": "/**\n * CSharp struct declaration.\n *\n * @example\n * ```tsx\n * <StructDeclaration public name=\"IMyStruct\">\n * <StructMember public name=\"MyProperty\" type=\"int\" />\n * <StructMethod public name=\"MyMethod\" returnType=\"void\">\n * <Parameter name=\"value\" type=\"int\" />\n * </StructMethod>\n * </StructDeclaration>\n * ```\n *\n * This will produce:\n * ```csharp\n * public struct MyIface\n * {\n * public int MyProperty { get; set; }\n * public void MyMethod(int value);\n * }\n * ```\n *\n */\n",
8156
+ "excerptTokens": [
8157
+ {
8158
+ "kind": "Content",
8159
+ "text": "export declare function StructDeclaration(props: "
8160
+ },
8161
+ {
8162
+ "kind": "Reference",
8163
+ "text": "StructDeclarationProps",
8164
+ "canonicalReference": "@alloy-js/csharp!StructDeclarationProps:interface"
8165
+ },
8166
+ {
8167
+ "kind": "Content",
8168
+ "text": "): "
8169
+ },
8170
+ {
8171
+ "kind": "Reference",
8172
+ "text": "core.Children",
8173
+ "canonicalReference": "@alloy-js/core!Children:type"
8174
+ },
8175
+ {
8176
+ "kind": "Content",
8177
+ "text": ";"
8178
+ }
8179
+ ],
8180
+ "fileUrlPath": "src/components/struct/declaration.tsx",
8181
+ "returnTypeTokenRange": {
8182
+ "startIndex": 3,
8183
+ "endIndex": 4
8184
+ },
8185
+ "releaseTag": "Public",
8186
+ "overloadIndex": 1,
8187
+ "parameters": [
8188
+ {
8189
+ "parameterName": "props",
8190
+ "parameterTypeTokenRange": {
8191
+ "startIndex": 1,
8192
+ "endIndex": 2
8193
+ },
8194
+ "isOptional": false
8195
+ }
8196
+ ],
8197
+ "name": "StructDeclaration"
8198
+ },
8199
+ {
8200
+ "kind": "Interface",
8201
+ "canonicalReference": "@alloy-js/csharp!StructDeclarationProps:interface",
8202
+ "docComment": "",
8203
+ "excerptTokens": [
8204
+ {
8205
+ "kind": "Content",
8206
+ "text": "export interface StructDeclarationProps extends "
8207
+ },
8208
+ {
8209
+ "kind": "Reference",
8210
+ "text": "Omit",
8211
+ "canonicalReference": "!Omit:type"
8212
+ },
8213
+ {
8214
+ "kind": "Content",
8215
+ "text": "<"
8216
+ },
8217
+ {
8218
+ "kind": "Reference",
8219
+ "text": "core.DeclarationProps",
8220
+ "canonicalReference": "@alloy-js/core!DeclarationProps:type"
8221
+ },
8222
+ {
8223
+ "kind": "Content",
8224
+ "text": ", \"nameKind\">"
8225
+ },
8226
+ {
8227
+ "kind": "Content",
8228
+ "text": ", "
8229
+ },
8230
+ {
8231
+ "kind": "Reference",
8232
+ "text": "AccessModifiers",
8233
+ "canonicalReference": "@alloy-js/csharp!AccessModifiers:interface"
8234
+ },
8235
+ {
8236
+ "kind": "Content",
8237
+ "text": ", "
8238
+ },
8239
+ {
8240
+ "kind": "Reference",
8241
+ "text": "StructModifiers",
8242
+ "canonicalReference": "@alloy-js/csharp!StructModifiers:interface"
8243
+ },
8244
+ {
8245
+ "kind": "Content",
8246
+ "text": " "
8247
+ }
8248
+ ],
8249
+ "fileUrlPath": "src/components/struct/declaration.tsx",
8250
+ "releaseTag": "Public",
8251
+ "name": "StructDeclarationProps",
8252
+ "preserveMemberOrder": false,
8253
+ "members": [
8254
+ {
8255
+ "kind": "PropertySignature",
8256
+ "canonicalReference": "@alloy-js/csharp!StructDeclarationProps#attributes:member",
8257
+ "docComment": "/**\n * Define attributes to attach\n *\n * @example\n * ```tsx\n * <StructDeclaration name=\"MyStruct\" attributes={[\n * <Attribute name=\"Test\" />\n * <Attribute name=\"Test2\" args={[\"arg1\", \"arg2\"]} />\n * ]} />\n * ```\n *\n * This will produce:\n * ```csharp\n * [Test]\n * [Test2(\"arg1\", \"arg2\")]\n * public struct MyStruct\n * ```\n *\n */\n",
8258
+ "excerptTokens": [
8259
+ {
8260
+ "kind": "Content",
8261
+ "text": "attributes?: "
8262
+ },
8263
+ {
8264
+ "kind": "Reference",
8265
+ "text": "AttributesProp",
8266
+ "canonicalReference": "@alloy-js/csharp!AttributesProp:type"
8267
+ },
8268
+ {
8269
+ "kind": "Content",
8270
+ "text": ";"
8271
+ }
8272
+ ],
8273
+ "isReadonly": false,
8274
+ "isOptional": true,
8275
+ "releaseTag": "Public",
8276
+ "name": "attributes",
8277
+ "propertyTypeTokenRange": {
8278
+ "startIndex": 1,
8279
+ "endIndex": 2
8280
+ }
8281
+ },
8282
+ {
8283
+ "kind": "PropertySignature",
8284
+ "canonicalReference": "@alloy-js/csharp!StructDeclarationProps#doc:member",
8285
+ "docComment": "/**\n * Doc comment\n */\n",
8286
+ "excerptTokens": [
8287
+ {
8288
+ "kind": "Content",
8289
+ "text": "doc?: "
8290
+ },
8291
+ {
8292
+ "kind": "Reference",
8293
+ "text": "core.Children",
8294
+ "canonicalReference": "@alloy-js/core!Children:type"
8295
+ },
8296
+ {
8297
+ "kind": "Content",
8298
+ "text": ";"
8299
+ }
8300
+ ],
8301
+ "isReadonly": false,
8302
+ "isOptional": true,
8303
+ "releaseTag": "Public",
8304
+ "name": "doc",
8305
+ "propertyTypeTokenRange": {
8306
+ "startIndex": 1,
8307
+ "endIndex": 2
8308
+ }
8309
+ },
8310
+ {
8311
+ "kind": "PropertySignature",
8312
+ "canonicalReference": "@alloy-js/csharp!StructDeclarationProps#name:member",
8313
+ "docComment": "",
8314
+ "excerptTokens": [
8315
+ {
8316
+ "kind": "Content",
8317
+ "text": "name: "
8318
+ },
8319
+ {
8320
+ "kind": "Content",
8321
+ "text": "string"
8322
+ },
8323
+ {
8324
+ "kind": "Content",
8325
+ "text": ";"
8326
+ }
8327
+ ],
8328
+ "isReadonly": false,
8329
+ "isOptional": false,
8330
+ "releaseTag": "Public",
8331
+ "name": "name",
8332
+ "propertyTypeTokenRange": {
8333
+ "startIndex": 1,
8334
+ "endIndex": 2
8335
+ }
8336
+ },
8337
+ {
8338
+ "kind": "PropertySignature",
8339
+ "canonicalReference": "@alloy-js/csharp!StructDeclarationProps#refkey:member",
8340
+ "docComment": "",
8341
+ "excerptTokens": [
8342
+ {
8343
+ "kind": "Content",
8344
+ "text": "refkey?: "
8345
+ },
8346
+ {
8347
+ "kind": "Reference",
8348
+ "text": "core.Refkey",
8349
+ "canonicalReference": "@alloy-js/core!Refkey:type"
8350
+ },
8351
+ {
8352
+ "kind": "Content",
8353
+ "text": ";"
8354
+ }
8355
+ ],
8356
+ "isReadonly": false,
8357
+ "isOptional": true,
8358
+ "releaseTag": "Public",
8359
+ "name": "refkey",
8360
+ "propertyTypeTokenRange": {
8361
+ "startIndex": 1,
8362
+ "endIndex": 2
8363
+ }
8364
+ },
8365
+ {
8366
+ "kind": "PropertySignature",
8367
+ "canonicalReference": "@alloy-js/csharp!StructDeclarationProps#typeParameters:member",
8368
+ "docComment": "/**\n * Type parameters for the struct\n *\n * @example\n * ```tsx\n * <StructDeclaration name=\"IList\" typeParameters={[\"T\"]} />\n * ```\n *\n * This will produce:\n * ```csharp\n * public struct IList<T>\n * ```\n *\n */\n",
8369
+ "excerptTokens": [
8370
+ {
8371
+ "kind": "Content",
8372
+ "text": "typeParameters?: "
8373
+ },
8374
+ {
8375
+ "kind": "Content",
8376
+ "text": "("
8377
+ },
8378
+ {
8379
+ "kind": "Reference",
8380
+ "text": "TypeParameterProps",
8381
+ "canonicalReference": "@alloy-js/csharp!TypeParameterProps:interface"
8382
+ },
8383
+ {
8384
+ "kind": "Content",
8385
+ "text": " | string)[]"
8386
+ },
8387
+ {
8388
+ "kind": "Content",
8389
+ "text": ";"
8390
+ }
8391
+ ],
8392
+ "isReadonly": false,
8393
+ "isOptional": true,
8394
+ "releaseTag": "Public",
8395
+ "name": "typeParameters",
8396
+ "propertyTypeTokenRange": {
8397
+ "startIndex": 1,
8398
+ "endIndex": 4
8399
+ }
8400
+ }
8401
+ ],
8402
+ "extendsTokenRanges": [
8403
+ {
8404
+ "startIndex": 1,
8405
+ "endIndex": 5
8406
+ },
8407
+ {
8408
+ "startIndex": 6,
8409
+ "endIndex": 7
8410
+ },
8411
+ {
8412
+ "startIndex": 8,
8413
+ "endIndex": 9
8414
+ }
8415
+ ]
8416
+ },
8417
+ {
8418
+ "kind": "Interface",
8419
+ "canonicalReference": "@alloy-js/csharp!StructModifiers:interface",
8420
+ "docComment": "",
8421
+ "excerptTokens": [
8422
+ {
8423
+ "kind": "Content",
8424
+ "text": "export interface StructModifiers "
8425
+ }
8426
+ ],
8427
+ "fileUrlPath": "src/components/struct/declaration.tsx",
8428
+ "releaseTag": "Public",
8429
+ "name": "StructModifiers",
8430
+ "preserveMemberOrder": false,
8431
+ "members": [
8432
+ {
8433
+ "kind": "PropertySignature",
8434
+ "canonicalReference": "@alloy-js/csharp!StructModifiers#new:member",
8435
+ "docComment": "",
8436
+ "excerptTokens": [
8437
+ {
8438
+ "kind": "Content",
8439
+ "text": "readonly new?: "
8440
+ },
8441
+ {
8442
+ "kind": "Content",
8443
+ "text": "boolean"
8444
+ },
8445
+ {
8446
+ "kind": "Content",
8447
+ "text": ";"
8448
+ }
8449
+ ],
8450
+ "isReadonly": true,
8451
+ "isOptional": true,
8452
+ "releaseTag": "Public",
8453
+ "name": "new",
8454
+ "propertyTypeTokenRange": {
8455
+ "startIndex": 1,
8456
+ "endIndex": 2
8457
+ }
8458
+ },
8459
+ {
8460
+ "kind": "PropertySignature",
8461
+ "canonicalReference": "@alloy-js/csharp!StructModifiers#partial:member",
8462
+ "docComment": "",
8463
+ "excerptTokens": [
8464
+ {
8465
+ "kind": "Content",
8466
+ "text": "readonly partial?: "
8467
+ },
8468
+ {
8469
+ "kind": "Content",
8470
+ "text": "boolean"
8471
+ },
8472
+ {
8473
+ "kind": "Content",
8474
+ "text": ";"
8475
+ }
8476
+ ],
8477
+ "isReadonly": true,
8478
+ "isOptional": true,
8479
+ "releaseTag": "Public",
8480
+ "name": "partial",
8481
+ "propertyTypeTokenRange": {
8482
+ "startIndex": 1,
8483
+ "endIndex": 2
8484
+ }
8485
+ },
8486
+ {
8487
+ "kind": "PropertySignature",
8488
+ "canonicalReference": "@alloy-js/csharp!StructModifiers#readonly:member",
8489
+ "docComment": "",
8490
+ "excerptTokens": [
8491
+ {
8492
+ "kind": "Content",
8493
+ "text": "readonly readonly?: "
8494
+ },
8495
+ {
8496
+ "kind": "Content",
8497
+ "text": "boolean"
8498
+ },
8499
+ {
8500
+ "kind": "Content",
8501
+ "text": ";"
8502
+ }
8503
+ ],
8504
+ "isReadonly": true,
8505
+ "isOptional": true,
8506
+ "releaseTag": "Public",
8507
+ "name": "readonly",
8508
+ "propertyTypeTokenRange": {
8509
+ "startIndex": 1,
8510
+ "endIndex": 2
8511
+ }
8512
+ },
8513
+ {
8514
+ "kind": "PropertySignature",
8515
+ "canonicalReference": "@alloy-js/csharp!StructModifiers#ref:member",
8516
+ "docComment": "",
8517
+ "excerptTokens": [
8518
+ {
8519
+ "kind": "Content",
8520
+ "text": "readonly ref?: "
8521
+ },
8522
+ {
8523
+ "kind": "Content",
8524
+ "text": "boolean"
8525
+ },
8526
+ {
8527
+ "kind": "Content",
8528
+ "text": ";"
8529
+ }
8530
+ ],
8531
+ "isReadonly": true,
8532
+ "isOptional": true,
8533
+ "releaseTag": "Public",
8534
+ "name": "ref",
8535
+ "propertyTypeTokenRange": {
8536
+ "startIndex": 1,
8537
+ "endIndex": 2
8538
+ }
8539
+ }
8540
+ ],
8541
+ "extendsTokenRanges": []
8542
+ },
8125
8543
  {
8126
8544
  "kind": "Interface",
8127
8545
  "canonicalReference": "@alloy-js/csharp!TypeParameterProps:interface",
@@ -256,11 +256,11 @@ describe("with type parameters", () => {
256
256
  ).toRenderTo(`
257
257
  namespace TestCode
258
258
  {
259
- public class TestClass<T, U>
260
- {
261
- T PropA { get; set; }
262
- U PropB { get; set; }
263
- }
259
+ public class TestClass<T, U>
260
+ {
261
+ T PropA { get; set; }
262
+ U PropB { get; set; }
263
+ }
264
264
  }
265
265
  `);
266
266
  });
@@ -145,3 +145,21 @@ it("specify doc comment", () => {
145
145
  }
146
146
  `);
147
147
  });
148
+
149
+ it("use expression body form", () => {
150
+ expect(
151
+ <TestNamespace>
152
+ <ClassDeclaration name="Test">
153
+ <ClassMethod name="Method" doc="This is a test" expression>
154
+ this.MyProperty.Value;
155
+ </ClassMethod>
156
+ </ClassDeclaration>
157
+ </TestNamespace>,
158
+ ).toRenderTo(`
159
+ class Test
160
+ {
161
+ /// This is a test
162
+ void Method() => this.MyProperty.Value;
163
+ }
164
+ `);
165
+ });