@alloy-js/csharp 0.23.0-dev.8 → 0.23.0

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 (89) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/dev/src/components/method/method.test.js +64 -0
  3. package/dist/dev/src/components/method/method.test.js.map +1 -1
  4. package/dist/dev/src/components/namespace/namespace.js +2 -1
  5. package/dist/dev/src/components/namespace/namespace.js.map +1 -1
  6. package/dist/dev/src/components/namespace/namespace.test.js +13 -10
  7. package/dist/dev/src/components/namespace/namespace.test.js.map +1 -1
  8. package/dist/dev/src/components/namespace.ref.test.js +54 -42
  9. package/dist/dev/src/components/namespace.ref.test.js.map +1 -1
  10. package/dist/dev/src/components/property/property.js +101 -24
  11. package/dist/dev/src/components/property/property.js.map +1 -1
  12. package/dist/dev/src/components/property/property.test.js +140 -0
  13. package/dist/dev/src/components/property/property.test.js.map +1 -1
  14. package/dist/dev/src/components/source-file/source-file.js +12 -11
  15. package/dist/dev/src/components/source-file/source-file.js.map +1 -1
  16. package/dist/dev/src/identifier-utils.js +45 -0
  17. package/dist/dev/src/identifier-utils.js.map +1 -0
  18. package/dist/dev/src/index.js +2 -0
  19. package/dist/dev/src/index.js.map +1 -1
  20. package/dist/dev/src/keywords.js +39 -0
  21. package/dist/dev/src/keywords.js.map +1 -0
  22. package/dist/dev/src/name-policy.js +29 -6
  23. package/dist/dev/src/name-policy.js.map +1 -1
  24. package/dist/dev/src/name-policy.test.js +167 -0
  25. package/dist/dev/src/name-policy.test.js.map +1 -0
  26. package/dist/src/components/method/method.test.js +48 -0
  27. package/dist/src/components/method/method.test.js.map +1 -1
  28. package/dist/src/components/namespace/namespace.js +2 -1
  29. package/dist/src/components/namespace/namespace.js.map +1 -1
  30. package/dist/src/components/namespace/namespace.test.js +6 -3
  31. package/dist/src/components/namespace/namespace.test.js.map +1 -1
  32. package/dist/src/components/namespace.ref.test.js +24 -12
  33. package/dist/src/components/namespace.ref.test.js.map +1 -1
  34. package/dist/src/components/property/property.d.ts +42 -4
  35. package/dist/src/components/property/property.d.ts.map +1 -1
  36. package/dist/src/components/property/property.js +64 -11
  37. package/dist/src/components/property/property.js.map +1 -1
  38. package/dist/src/components/property/property.test.js +104 -0
  39. package/dist/src/components/property/property.test.js.map +1 -1
  40. package/dist/src/components/source-file/source-file.d.ts.map +1 -1
  41. package/dist/src/components/source-file/source-file.js +3 -2
  42. package/dist/src/components/source-file/source-file.js.map +1 -1
  43. package/dist/src/identifier-utils.d.ts +22 -0
  44. package/dist/src/identifier-utils.d.ts.map +1 -0
  45. package/dist/src/identifier-utils.js +45 -0
  46. package/dist/src/identifier-utils.js.map +1 -0
  47. package/dist/src/index.d.ts +2 -0
  48. package/dist/src/index.d.ts.map +1 -1
  49. package/dist/src/index.js +2 -0
  50. package/dist/src/index.js.map +1 -1
  51. package/dist/src/keywords.d.ts +32 -0
  52. package/dist/src/keywords.d.ts.map +1 -0
  53. package/dist/src/keywords.js +39 -0
  54. package/dist/src/keywords.js.map +1 -0
  55. package/dist/src/name-policy.d.ts +7 -0
  56. package/dist/src/name-policy.d.ts.map +1 -1
  57. package/dist/src/name-policy.js +29 -6
  58. package/dist/src/name-policy.js.map +1 -1
  59. package/dist/src/name-policy.test.d.ts +2 -0
  60. package/dist/src/name-policy.test.d.ts.map +1 -0
  61. package/dist/src/name-policy.test.js +167 -0
  62. package/dist/src/name-policy.test.js.map +1 -0
  63. package/dist/tsconfig.tsbuildinfo +1 -1
  64. package/docs/api/components/Property.md +30 -30
  65. package/docs/api/contexts/csharp-context.md +21 -0
  66. package/docs/api/contexts/index.md +3 -0
  67. package/docs/api/functions/createCSharpNamePolicy.md +4 -0
  68. package/docs/api/functions/index.md +5 -1
  69. package/docs/api/functions/isCSharpContextualKeyword.md +20 -0
  70. package/docs/api/functions/isCSharpKeyword.md +22 -0
  71. package/docs/api/functions/isValidCSharpIdentifier.md +20 -0
  72. package/docs/api/functions/sanitizeCSharpIdentifier.md +24 -0
  73. package/docs/api/index.md +3 -2
  74. package/docs/api/variables/csharpKeywords.md +11 -0
  75. package/docs/api/variables/index.md +1 -0
  76. package/package.json +8 -8
  77. package/src/components/method/method.test.tsx +36 -0
  78. package/src/components/namespace/namespace.test.tsx +6 -3
  79. package/src/components/namespace/namespace.tsx +2 -2
  80. package/src/components/namespace.ref.test.tsx +24 -12
  81. package/src/components/property/property.test.tsx +89 -0
  82. package/src/components/property/property.tsx +111 -16
  83. package/src/components/source-file/source-file.tsx +1 -4
  84. package/src/identifier-utils.ts +45 -0
  85. package/src/index.ts +2 -0
  86. package/src/keywords.ts +162 -0
  87. package/src/name-policy.test.ts +210 -0
  88. package/src/name-policy.ts +30 -6
  89. package/temp/api.json +253 -7
package/temp/api.json CHANGED
@@ -2560,7 +2560,7 @@
2560
2560
  {
2561
2561
  "kind": "Function",
2562
2562
  "canonicalReference": "@alloy-js/csharp!createCSharpNamePolicy:function(1)",
2563
- "docComment": "",
2563
+ "docComment": "/**\n * Creates the C# naming policy with case conversion and keyword escaping.\n *\n * After applying the appropriate case conversion for each element kind,\n * the resulting name is checked against C# reserved and contextual keywords.\n * If it matches (case-sensitively), the name is prefixed with `@`.\n */\n",
2564
2564
  "excerptTokens": [
2565
2565
  {
2566
2566
  "kind": "Content",
@@ -3624,6 +3624,34 @@
3624
3624
  },
3625
3625
  "implementsTokenRanges": []
3626
3626
  },
3627
+ {
3628
+ "kind": "Variable",
3629
+ "canonicalReference": "@alloy-js/csharp!csharpContextualKeywords:var",
3630
+ "docComment": "/**\n * C# contextual keywords that are reserved in certain contexts.\n * While not always reserved, treating them as keywords in generated code\n * avoids subtle context-dependent issues.\n *\n * @see\n *\n * https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/#contextual-keywords\n */\n",
3631
+ "excerptTokens": [
3632
+ {
3633
+ "kind": "Content",
3634
+ "text": "csharpContextualKeywords: "
3635
+ },
3636
+ {
3637
+ "kind": "Reference",
3638
+ "text": "ReadonlySet",
3639
+ "canonicalReference": "!ReadonlySet:interface"
3640
+ },
3641
+ {
3642
+ "kind": "Content",
3643
+ "text": "<string>"
3644
+ }
3645
+ ],
3646
+ "fileUrlPath": "src/keywords.ts",
3647
+ "isReadonly": true,
3648
+ "releaseTag": "Public",
3649
+ "name": "csharpContextualKeywords",
3650
+ "variableTypeTokenRange": {
3651
+ "startIndex": 1,
3652
+ "endIndex": 3
3653
+ }
3654
+ },
3627
3655
  {
3628
3656
  "kind": "TypeAlias",
3629
3657
  "canonicalReference": "@alloy-js/csharp!CSharpElements:type",
@@ -3731,6 +3759,34 @@
3731
3759
  "endIndex": 8
3732
3760
  }
3733
3761
  },
3762
+ {
3763
+ "kind": "Variable",
3764
+ "canonicalReference": "@alloy-js/csharp!csharpKeywords:var",
3765
+ "docComment": "/**\n * C# reserved keywords that cannot be used as identifiers without `@` prefix.\n * These are case-sensitive in C#.\n *\n * @see\n *\n * https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/\n */\n",
3766
+ "excerptTokens": [
3767
+ {
3768
+ "kind": "Content",
3769
+ "text": "csharpKeywords: "
3770
+ },
3771
+ {
3772
+ "kind": "Reference",
3773
+ "text": "ReadonlySet",
3774
+ "canonicalReference": "!ReadonlySet:interface"
3775
+ },
3776
+ {
3777
+ "kind": "Content",
3778
+ "text": "<string>"
3779
+ }
3780
+ ],
3781
+ "fileUrlPath": "src/keywords.ts",
3782
+ "isReadonly": true,
3783
+ "releaseTag": "Public",
3784
+ "name": "csharpKeywords",
3785
+ "variableTypeTokenRange": {
3786
+ "startIndex": 1,
3787
+ "endIndex": 3
3788
+ }
3789
+ },
3734
3790
  {
3735
3791
  "kind": "Class",
3736
3792
  "canonicalReference": "@alloy-js/csharp!CSharpLexicalScope:class",
@@ -10556,6 +10612,141 @@
10556
10612
  ],
10557
10613
  "extendsTokenRanges": []
10558
10614
  },
10615
+ {
10616
+ "kind": "Function",
10617
+ "canonicalReference": "@alloy-js/csharp!isCSharpContextualKeyword:function(1)",
10618
+ "docComment": "/**\n * Returns true if the given name is a C# contextual keyword.\n * Contextual keywords are only reserved in specific language contexts\n * and are generally valid as identifiers.\n */\n",
10619
+ "excerptTokens": [
10620
+ {
10621
+ "kind": "Content",
10622
+ "text": "export declare function isCSharpContextualKeyword(name: "
10623
+ },
10624
+ {
10625
+ "kind": "Content",
10626
+ "text": "string"
10627
+ },
10628
+ {
10629
+ "kind": "Content",
10630
+ "text": "): "
10631
+ },
10632
+ {
10633
+ "kind": "Content",
10634
+ "text": "boolean"
10635
+ },
10636
+ {
10637
+ "kind": "Content",
10638
+ "text": ";"
10639
+ }
10640
+ ],
10641
+ "fileUrlPath": "src/keywords.ts",
10642
+ "returnTypeTokenRange": {
10643
+ "startIndex": 3,
10644
+ "endIndex": 4
10645
+ },
10646
+ "releaseTag": "Public",
10647
+ "overloadIndex": 1,
10648
+ "parameters": [
10649
+ {
10650
+ "parameterName": "name",
10651
+ "parameterTypeTokenRange": {
10652
+ "startIndex": 1,
10653
+ "endIndex": 2
10654
+ },
10655
+ "isOptional": false
10656
+ }
10657
+ ],
10658
+ "name": "isCSharpContextualKeyword"
10659
+ },
10660
+ {
10661
+ "kind": "Function",
10662
+ "canonicalReference": "@alloy-js/csharp!isCSharpKeyword:function(1)",
10663
+ "docComment": "/**\n * Returns true if the given name is a C# reserved keyword.\n * The check is case-sensitive, matching C# language semantics.\n *\n * Note: this only checks reserved keywords, not contextual keywords.\n * Contextual keywords are only reserved in specific language contexts\n * and are valid identifiers elsewhere (e.g., `value` is valid as a parameter name).\n * Use {@link isCSharpContextualKeyword} to check contextual keywords separately.\n */\n",
10664
+ "excerptTokens": [
10665
+ {
10666
+ "kind": "Content",
10667
+ "text": "export declare function isCSharpKeyword(name: "
10668
+ },
10669
+ {
10670
+ "kind": "Content",
10671
+ "text": "string"
10672
+ },
10673
+ {
10674
+ "kind": "Content",
10675
+ "text": "): "
10676
+ },
10677
+ {
10678
+ "kind": "Content",
10679
+ "text": "boolean"
10680
+ },
10681
+ {
10682
+ "kind": "Content",
10683
+ "text": ";"
10684
+ }
10685
+ ],
10686
+ "fileUrlPath": "src/keywords.ts",
10687
+ "returnTypeTokenRange": {
10688
+ "startIndex": 3,
10689
+ "endIndex": 4
10690
+ },
10691
+ "releaseTag": "Public",
10692
+ "overloadIndex": 1,
10693
+ "parameters": [
10694
+ {
10695
+ "parameterName": "name",
10696
+ "parameterTypeTokenRange": {
10697
+ "startIndex": 1,
10698
+ "endIndex": 2
10699
+ },
10700
+ "isOptional": false
10701
+ }
10702
+ ],
10703
+ "name": "isCSharpKeyword"
10704
+ },
10705
+ {
10706
+ "kind": "Function",
10707
+ "canonicalReference": "@alloy-js/csharp!isValidCSharpIdentifier:function(1)",
10708
+ "docComment": "/**\n * Checks whether the provided name is a valid C# identifier (without `@` prefix).\n * Does not account for keyword conflicts — use {@link isCSharpKeyword} for that.\n *\n * @param name - The name to validate.\n *\n * @returns true if the name matches C# identifier rules (letter or underscore start, word chars after).\n */\n",
10709
+ "excerptTokens": [
10710
+ {
10711
+ "kind": "Content",
10712
+ "text": "export declare function isValidCSharpIdentifier(name: "
10713
+ },
10714
+ {
10715
+ "kind": "Content",
10716
+ "text": "string"
10717
+ },
10718
+ {
10719
+ "kind": "Content",
10720
+ "text": "): "
10721
+ },
10722
+ {
10723
+ "kind": "Content",
10724
+ "text": "boolean"
10725
+ },
10726
+ {
10727
+ "kind": "Content",
10728
+ "text": ";"
10729
+ }
10730
+ ],
10731
+ "fileUrlPath": "src/identifier-utils.ts",
10732
+ "returnTypeTokenRange": {
10733
+ "startIndex": 3,
10734
+ "endIndex": 4
10735
+ },
10736
+ "releaseTag": "Public",
10737
+ "overloadIndex": 1,
10738
+ "parameters": [
10739
+ {
10740
+ "parameterName": "name",
10741
+ "parameterTypeTokenRange": {
10742
+ "startIndex": 1,
10743
+ "endIndex": 2
10744
+ },
10745
+ "isOptional": false
10746
+ }
10747
+ ],
10748
+ "name": "isValidCSharpIdentifier"
10749
+ },
10559
10750
  {
10560
10751
  "kind": "Interface",
10561
10752
  "canonicalReference": "@alloy-js/csharp!LeixcalScopePropsWithScopeInfo:interface",
@@ -14622,7 +14813,7 @@
14622
14813
  {
14623
14814
  "kind": "PropertySignature",
14624
14815
  "canonicalReference": "@alloy-js/csharp!PropertyProps#get:member",
14625
- "docComment": "/**\n * If property should have a getter\n */\n",
14816
+ "docComment": "/**\n * If property should have a getter. Pass `true` for an auto-property getter (`get;`),\n * or pass children for a getter with a body.\n *\n * @example\n *\n * auto-property\n * ```tsx\n * <Property name=\"Name\" type=\"string\" get set />\n * ```\n *\n * Produces: `string Name { get; set; }`\n *\n * @example\n *\n * with body\n * ```tsx\n * <Property name=\"Name\" type=\"string\" get={<>return _name;</>} set />\n * ```\n *\n * Produces:\n * ```csharp\n * string Name\n * {\n * get { return _name; }\n * set;\n * }\n * ```\n *\n */\n",
14626
14817
  "excerptTokens": [
14627
14818
  {
14628
14819
  "kind": "Content",
@@ -14630,7 +14821,12 @@
14630
14821
  },
14631
14822
  {
14632
14823
  "kind": "Content",
14633
- "text": "boolean"
14824
+ "text": "boolean | "
14825
+ },
14826
+ {
14827
+ "kind": "Reference",
14828
+ "text": "Children",
14829
+ "canonicalReference": "@alloy-js/core!Children:type"
14634
14830
  },
14635
14831
  {
14636
14832
  "kind": "Content",
@@ -14643,7 +14839,7 @@
14643
14839
  "name": "get",
14644
14840
  "propertyTypeTokenRange": {
14645
14841
  "startIndex": 1,
14646
- "endIndex": 2
14842
+ "endIndex": 3
14647
14843
  }
14648
14844
  },
14649
14845
  {
@@ -14791,7 +14987,7 @@
14791
14987
  {
14792
14988
  "kind": "PropertySignature",
14793
14989
  "canonicalReference": "@alloy-js/csharp!PropertyProps#set:member",
14794
- "docComment": "/**\n * If property should have a setter\n */\n",
14990
+ "docComment": "/**\n * If property should have a setter. Pass `true` for an auto-property setter (`set;`),\n * or pass children for a setter with a body.\n *\n * @example\n *\n * with body\n * ```tsx\n * <Property name=\"Value\" type=\"int\" get set={<>_value = value;</>} />\n * ```\n *\n * Produces:\n * ```csharp\n * int Value\n * {\n * get;\n * set { _value = value; }\n * }\n * ```\n *\n */\n",
14795
14991
  "excerptTokens": [
14796
14992
  {
14797
14993
  "kind": "Content",
@@ -14799,7 +14995,12 @@
14799
14995
  },
14800
14996
  {
14801
14997
  "kind": "Content",
14802
- "text": "boolean"
14998
+ "text": "boolean | "
14999
+ },
15000
+ {
15001
+ "kind": "Reference",
15002
+ "text": "Children",
15003
+ "canonicalReference": "@alloy-js/core!Children:type"
14803
15004
  },
14804
15005
  {
14805
15006
  "kind": "Content",
@@ -14812,7 +15013,7 @@
14812
15013
  "name": "set",
14813
15014
  "propertyTypeTokenRange": {
14814
15015
  "startIndex": 1,
14815
- "endIndex": 2
15016
+ "endIndex": 3
14816
15017
  }
14817
15018
  },
14818
15019
  {
@@ -15603,6 +15804,51 @@
15603
15804
  "endIndex": 9
15604
15805
  }
15605
15806
  },
15807
+ {
15808
+ "kind": "Function",
15809
+ "canonicalReference": "@alloy-js/csharp!sanitizeCSharpIdentifier:function(1)",
15810
+ "docComment": "/**\n * Transforms an arbitrary string into a valid C# identifier by replacing\n * invalid characters. The result may still be a C# keyword — callers\n * should combine with keyword escaping if needed.\n *\n * - If the first character is not a letter or underscore, a `_` prefix is added.\n * - Subsequent non-word characters are replaced with `_`.\n * - Empty strings become `_`.\n *\n * @param name - The string to sanitize.\n *\n * @returns A string that satisfies C# identifier character rules.\n */\n",
15811
+ "excerptTokens": [
15812
+ {
15813
+ "kind": "Content",
15814
+ "text": "export declare function sanitizeCSharpIdentifier(name: "
15815
+ },
15816
+ {
15817
+ "kind": "Content",
15818
+ "text": "string"
15819
+ },
15820
+ {
15821
+ "kind": "Content",
15822
+ "text": "): "
15823
+ },
15824
+ {
15825
+ "kind": "Content",
15826
+ "text": "string"
15827
+ },
15828
+ {
15829
+ "kind": "Content",
15830
+ "text": ";"
15831
+ }
15832
+ ],
15833
+ "fileUrlPath": "src/identifier-utils.ts",
15834
+ "returnTypeTokenRange": {
15835
+ "startIndex": 3,
15836
+ "endIndex": 4
15837
+ },
15838
+ "releaseTag": "Public",
15839
+ "overloadIndex": 1,
15840
+ "parameters": [
15841
+ {
15842
+ "parameterName": "name",
15843
+ "parameterTypeTokenRange": {
15844
+ "startIndex": 1,
15845
+ "endIndex": 2
15846
+ },
15847
+ "isOptional": false
15848
+ }
15849
+ ],
15850
+ "name": "sanitizeCSharpIdentifier"
15851
+ },
15606
15852
  {
15607
15853
  "kind": "Function",
15608
15854
  "canonicalReference": "@alloy-js/csharp!SourceFile:function(1)",