@alloy-js/csharp 0.18.0-dev.15 → 0.18.0-dev.16

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.
@@ -2,7 +2,7 @@ import { Children } from "@alloy-js/core/jsx-runtime";
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { TestNamespace } from "../../../test/utils.jsx";
4
4
  import { ClassDeclaration } from "../ClassDeclaration.jsx";
5
- import { ClassProperty } from "./property.jsx";
5
+ import { Property } from "./property.jsx";
6
6
 
7
7
  const Wrapper = (props: { children: Children }) => (
8
8
  <TestNamespace>
@@ -19,7 +19,7 @@ describe("modifiers", () => {
19
19
  (accessModifier) => {
20
20
  expect(
21
21
  <Wrapper>
22
- <ClassProperty
22
+ <Property
23
23
  {...{ [accessModifier]: true }}
24
24
  name="TestProp"
25
25
  type="string"
@@ -49,7 +49,7 @@ describe("modifiers", () => {
49
49
  ] as const)("%s", (methodModifier) => {
50
50
  expect(
51
51
  <Wrapper>
52
- <ClassProperty
52
+ <Property
53
53
  {...{ [methodModifier]: true }}
54
54
  name="TestProp"
55
55
  type="string"
@@ -68,7 +68,7 @@ describe("modifiers", () => {
68
68
  it("combine modifiers", () => {
69
69
  expect(
70
70
  <Wrapper>
71
- <ClassProperty public new name="TestProp" type="string" get />
71
+ <Property public new name="TestProp" type="string" get />
72
72
  </Wrapper>,
73
73
  ).toRenderTo(`
74
74
  public class TestClass
@@ -82,7 +82,7 @@ describe("modifiers", () => {
82
82
  it("applies PascalCase naming policy", () => {
83
83
  expect(
84
84
  <Wrapper>
85
- <ClassProperty name="test_prop" type="string" get />
85
+ <Property name="test_prop" type="string" get />
86
86
  </Wrapper>,
87
87
  ).toRenderTo(`
88
88
  public class TestClass
@@ -95,7 +95,7 @@ it("applies PascalCase naming policy", () => {
95
95
  it("has getter only", () => {
96
96
  expect(
97
97
  <Wrapper>
98
- <ClassProperty name="TestProp" type="string" get />
98
+ <Property name="TestProp" type="string" get />
99
99
  </Wrapper>,
100
100
  ).toRenderTo(`
101
101
  public class TestClass
@@ -108,7 +108,7 @@ it("has getter only", () => {
108
108
  it("has setter only", () => {
109
109
  expect(
110
110
  <Wrapper>
111
- <ClassProperty name="TestProp" type="string" set />
111
+ <Property name="TestProp" type="string" set />
112
112
  </Wrapper>,
113
113
  ).toRenderTo(`
114
114
  public class TestClass
@@ -121,7 +121,7 @@ it("has setter only", () => {
121
121
  it("has getter and setter", () => {
122
122
  expect(
123
123
  <Wrapper>
124
- <ClassProperty name="TestProp" type="string" get set />
124
+ <Property name="TestProp" type="string" get set />
125
125
  </Wrapper>,
126
126
  ).toRenderTo(`
127
127
  public class TestClass
@@ -134,7 +134,7 @@ it("has getter and setter", () => {
134
134
  it("has getter and init", () => {
135
135
  expect(
136
136
  <Wrapper>
137
- <ClassProperty name="TestProp" type="string" get init />
137
+ <Property name="TestProp" type="string" get init />
138
138
  </Wrapper>,
139
139
  ).toRenderTo(`
140
140
  public class TestClass
@@ -148,13 +148,7 @@ it("specify doc comment", () => {
148
148
  expect(
149
149
  <TestNamespace>
150
150
  <ClassDeclaration name="Test">
151
- <ClassProperty
152
- name="Method"
153
- type="string"
154
- get
155
- set
156
- doc="This is a test"
157
- />
151
+ <Property name="Method" type="string" get set doc="This is a test" />
158
152
  </ClassDeclaration>
159
153
  </TestNamespace>,
160
154
  ).toRenderTo(`
@@ -169,7 +163,7 @@ it("specify doc comment", () => {
169
163
  it("specify nullable property", () => {
170
164
  expect(
171
165
  <Wrapper>
172
- <ClassProperty name="TestProp" type="string" nullable get set />
166
+ <Property name="TestProp" type="string" nullable get set />
173
167
  </Wrapper>,
174
168
  ).toRenderTo(`
175
169
  public class TestClass
@@ -182,13 +176,7 @@ it("specify nullable property", () => {
182
176
  it("specify initializer", () => {
183
177
  expect(
184
178
  <Wrapper>
185
- <ClassProperty
186
- name="TestProp"
187
- type="string"
188
- get
189
- set
190
- initializer={`"abc"`}
191
- />
179
+ <Property name="TestProp" type="string" get set initializer={`"abc"`} />
192
180
  </Wrapper>,
193
181
  ).toRenderTo(`
194
182
  public class TestClass
@@ -19,8 +19,8 @@ import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
19
19
  import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
20
20
  import { DocWhen } from "../doc/comment.jsx";
21
21
 
22
- /** Method modifiers. Can only be one. */
23
- export interface ClassPropertyModifiers {
22
+ /** Property modifiers. */
23
+ export interface PropertyModifiers {
24
24
  readonly new?: boolean;
25
25
  readonly static?: boolean;
26
26
  readonly virtual?: boolean;
@@ -31,7 +31,7 @@ export interface ClassPropertyModifiers {
31
31
  readonly readonly?: boolean;
32
32
  }
33
33
 
34
- const getModifiers = makeModifiers<ClassPropertyModifiers>([
34
+ const getModifiers = makeModifiers<PropertyModifiers>([
35
35
  "new",
36
36
  "static",
37
37
  "virtual",
@@ -42,10 +42,8 @@ const getModifiers = makeModifiers<ClassPropertyModifiers>([
42
42
  "readonly",
43
43
  ]);
44
44
 
45
- /** Properties for {@link ClassProperty} component */
46
- export interface ClassPropertyProps
47
- extends AccessModifiers,
48
- ClassPropertyModifiers {
45
+ /** Properties for {@link Property} component */
46
+ export interface PropertyProps extends AccessModifiers, PropertyModifiers {
49
47
  name: string;
50
48
  refkey?: Refkey;
51
49
 
@@ -94,7 +92,7 @@ export interface ClassPropertyProps
94
92
  * public int My { get; set; };
95
93
  * ```
96
94
  */
97
- export function ClassProperty(props: ClassPropertyProps) {
95
+ export function Property(props: PropertyProps) {
98
96
  const name = useCSharpNamePolicy().getName(props.name, "class-property");
99
97
  const scope = useCSharpScope();
100
98
  if (
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { TestNamespace } from "../../../test/utils.jsx";
3
- import { ClassProperty } from "../class/property.jsx";
3
+ import { Property } from "../property/property.jsx";
4
4
  import { RecordDeclaration } from "./declaration.jsx";
5
5
 
6
6
  it("declares class with no members", () => {
@@ -60,7 +60,7 @@ it("specify class property inside", () => {
60
60
  expect(
61
61
  <TestNamespace>
62
62
  <RecordDeclaration name="TestRecord" doc="This is a test">
63
- <ClassProperty name="Prop" get set type="string" />
63
+ <Property name="Prop" get set type="string" />
64
64
  </RecordDeclaration>
65
65
  </TestNamespace>,
66
66
  ).toRenderTo(`