Skip to content

Commit cc00f93

Browse files
committed
Move to C# 11 string literals
1 parent 8d5e5d2 commit cc00f93

File tree

3 files changed

+164
-151
lines changed

3 files changed

+164
-151
lines changed

CommunityToolkit.Tooling.SampleGen.Tests/ToolkitSampleGeneratedPaneTests.cs

Lines changed: 119 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,32 @@ public partial class ToolkitSampleGeneratedPaneTests
1818
[TestMethod]
1919
public void PaneOption_GeneratesWithoutDiagnostics()
2020
{
21-
var source = $@"
21+
var source = """
2222
using System.ComponentModel;
2323
using CommunityToolkit.Tooling.SampleGen;
2424
using CommunityToolkit.Tooling.SampleGen.Attributes;
2525
2626
namespace MyApp
27-
{{
28-
[ToolkitSampleBoolOption(""Test"", false, Title = ""Toggle y"")]
29-
[ToolkitSampleMultiChoiceOption(""TextFontFamily"", ""Segoe UI"", ""Arial"", ""Consolas"", Title = ""Font family"")]
27+
{
28+
[ToolkitSampleBoolOption("Test", false, Title = "Toggle y")]
29+
[ToolkitSampleMultiChoiceOption("TextFontFamily", "Segoe UI", "Arial", "Consolas", Title = "Font family")]
3030
31-
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: """")]
31+
[ToolkitSample(id: nameof(Sample), "Test Sample", description: ")]
3232
public partial class Sample : Windows.UI.Xaml.Controls.UserControl
33-
{{
33+
{
3434
public Sample()
35-
{{
35+
{
3636
var x = this.Test;
3737
var y = this.TextFontFamily;
38-
}}
39-
}}
40-
}}
38+
}
39+
}
40+
}
4141
4242
namespace Windows.UI.Xaml.Controls
43-
{{
44-
public class UserControl {{ }}
45-
}}";
43+
{
44+
public class UserControl { }
45+
}
46+
""";
4647

4748
var result = source.RunSourceGenerator<ToolkitSampleOptionGenerator>(SAMPLE_ASM_NAME);
4849

@@ -109,44 +110,45 @@ public static class ToolkitSampleRegistry
109110
[TestMethod]
110111
public void PaneOption_GeneratesProperty_DuplicatePropNamesAcrossSampleClasses()
111112
{
112-
var source = $@"
113+
var source = """
113114
using System.ComponentModel;
114115
using CommunityToolkit.Tooling.SampleGen;
115116
using CommunityToolkit.Tooling.SampleGen.Attributes;
116117
117118
namespace MyApp
118-
{{
119-
[ToolkitSampleBoolOption(""Test"", false, Title = ""Toggle y"")]
120-
[ToolkitSampleMultiChoiceOption(""TextFontFamily"", ""Segoe UI"", ""Arial"", ""Consolas"", Title = ""Font family"")]
119+
{
120+
[ToolkitSampleBoolOption("Test", false, Title = "Toggle y")]
121+
[ToolkitSampleMultiChoiceOption("TextFontFamily", "Segoe UI", "Arial", "Consolas", Title = "Font family")]
121122
122-
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: """")]
123+
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: "")]
123124
public partial class Sample : Windows.UI.Xaml.Controls.UserControl
124-
{{
125+
{
125126
public Sample()
126-
{{
127+
{
127128
var x = this.Test;
128129
var y = this.TextFontFamily;
129-
}}
130-
}}
130+
}
131+
}
131132
132-
[ToolkitSampleBoolOption(""Test"", false, Title = ""Toggle y"")]
133-
[ToolkitSampleMultiChoiceOption(""TextFontFamily"", ""Segoe UI"", ""Arial"", ""Consolas"", Title = ""Font family"")]
133+
[ToolkitSampleBoolOption("Test", false, Title = "Toggle y")]
134+
[ToolkitSampleMultiChoiceOption("TextFontFamily", "Segoe UI", "Arial", "Consolas", Title = "Font family")]
134135
135-
[ToolkitSample(id: nameof(Sample2), ""Test Sample"", description: """")]
136+
[ToolkitSample(id: nameof(Sample2), "Test Sample", description: "")]
136137
public partial class Sample2 : Windows.UI.Xaml.Controls.UserControl
137-
{{
138+
{
138139
public Sample2()
139-
{{
140+
{
140141
var x = this.Test;
141142
var y = this.TextFontFamily;
142-
}}
143-
}}
144-
}}
143+
}
144+
}
145+
}
145146
146147
namespace Windows.UI.Xaml.Controls
147-
{{
148-
public class UserControl {{ }}
149-
}}";
148+
{
149+
public class UserControl { }
150+
}
151+
""";
150152

151153
var result = source.RunSourceGenerator<ToolkitSampleOptionGenerator>(SAMPLE_ASM_NAME);
152154

@@ -184,24 +186,25 @@ public class UserControl { }
184186
[TestMethod]
185187
public void PaneOptionWithBadName(string name)
186188
{
187-
var source = $@"
189+
var source = """
188190
using System.ComponentModel;
189191
using CommunityToolkit.Tooling.SampleGen;
190192
using CommunityToolkit.Tooling.SampleGen.Attributes;
191193
192194
namespace MyApp
193-
{{
194-
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: """")]
195-
[ToolkitSampleBoolOption(""{name}"", false, Title = ""Toggle visibility"")]
195+
{
196+
[ToolkitSample(id: nameof(Sample), "Test Sample", description: "")]
197+
[ToolkitSampleBoolOption("{name}", false, Title = "Toggle visibility")]
196198
public partial class Sample : Windows.UI.Xaml.Controls.UserControl
197-
{{
198-
}}
199-
}}
199+
{
200+
}
201+
}
200202
201203
namespace Windows.UI.Xaml.Controls
202-
{{
203-
public class UserControl {{ }}
204-
}}";
204+
{
205+
public class UserControl { }
206+
}
207+
""";
205208

206209
var result = source.RunSourceGenerator<ToolkitSampleMetadataGenerator>(SAMPLE_ASM_NAME);
207210

@@ -211,25 +214,26 @@ public class UserControl {{ }}
211214
[TestMethod]
212215
public void PaneOptionWithConflictingPropertyName()
213216
{
214-
var source = $@"
217+
var source = """
215218
using System.ComponentModel;
216219
using CommunityToolkit.Tooling.SampleGen;
217220
using CommunityToolkit.Tooling.SampleGen.Attributes;
218221
219222
namespace MyApp
220-
{{
221-
[ToolkitSampleBoolOption(""IsVisible"", false, Title = ""Toggle x"")]
222-
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: """")]
223+
{
224+
[ToolkitSampleBoolOption("IsVisible", false, Title = "Toggle x")]
225+
[ToolkitSample(id: nameof(Sample), "Test Sample", description: "")]
223226
public partial class Sample : Windows.UI.Xaml.Controls.UserControl
224-
{{
225-
public string IsVisible {{ get; set; }}
226-
}}
227-
}}
227+
{
228+
public string IsVisible { get; set; }
229+
}
230+
}
228231
229232
namespace Windows.UI.Xaml.Controls
230-
{{
231-
public class UserControl {{ }}
232-
}}";
233+
{
234+
public class UserControl { }
235+
}
236+
""";
233237

234238
var result = source.RunSourceGenerator<ToolkitSampleMetadataGenerator>(SAMPLE_ASM_NAME);
235239

@@ -239,29 +243,30 @@ public class UserControl {{ }}
239243
[TestMethod]
240244
public void PaneOptionWithConflictingInheritedPropertyName()
241245
{
242-
var source = $@"
246+
var source = """
243247
using System.ComponentModel;
244248
using CommunityToolkit.Tooling.SampleGen;
245249
using CommunityToolkit.Tooling.SampleGen.Attributes;
246250
247251
namespace MyApp
248-
{{
249-
[ToolkitSampleBoolOption(""IsVisible"", false, Title = ""Toggle x"")]
250-
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: """")]
252+
{
253+
[ToolkitSampleBoolOption("IsVisible", false, Title = "Toggle x")]
254+
[ToolkitSample(id: nameof(Sample), "Test Sample", description: "")]
251255
public partial class Sample : Base
252-
{{
253-
}}
256+
{
257+
}
254258
255259
public class Base : Windows.UI.Xaml.Controls.UserControl
256-
{{
257-
public string IsVisible {{ get; set; }}
258-
}}
259-
}}
260+
{
261+
public string IsVisible { get; set; }
262+
}
263+
}
260264
261265
namespace Windows.UI.Xaml.Controls
262-
{{
263-
public class UserControl {{ }}
264-
}}";
266+
{
267+
public class UserControl { }
268+
}
269+
""";
265270

266271
var result = source.RunSourceGenerator<ToolkitSampleMetadataGenerator>(SAMPLE_ASM_NAME);
267272

@@ -271,27 +276,28 @@ public class UserControl {{ }}
271276
[TestMethod]
272277
public void PaneOptionWithDuplicateName()
273278
{
274-
var source = $@"
279+
var source = """
275280
using System.ComponentModel;
276281
using CommunityToolkit.Tooling.SampleGen;
277282
using CommunityToolkit.Tooling.SampleGen.Attributes;
278283
279284
namespace MyApp
280-
{{
281-
[ToolkitSampleBoolOption(""test"", false, Title = ""Toggle x"")]
282-
[ToolkitSampleBoolOption(""test"", false, Title = ""Toggle y"")]
283-
[ToolkitSampleMultiChoiceOption(""TextFontFamily"", ""Segoe UI"", ""Arial"", Title = ""Text foreground"")]
285+
{
286+
[ToolkitSampleBoolOption("test", false, Title = "Toggle x")]
287+
[ToolkitSampleBoolOption("test", false, Title = "Toggle y")]
288+
[ToolkitSampleMultiChoiceOption("TextFontFamily", "Segoe UI", "Arial", Title = "Text foreground")]
284289
285-
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: """")]
290+
[ToolkitSample(id: nameof(Sample), "Test Sample", description: "")]
286291
public partial class Sample : Windows.UI.Xaml.Controls.UserControl
287-
{{
288-
}}
289-
}}
292+
{
293+
}
294+
}
290295
291296
namespace Windows.UI.Xaml.Controls
292-
{{
293-
public class UserControl {{ }}
294-
}}";
297+
{
298+
public class UserControl { }
299+
}
300+
""";
295301

296302
var result = source.RunSourceGenerator<ToolkitSampleMetadataGenerator>(SAMPLE_ASM_NAME);
297303

@@ -301,32 +307,33 @@ public class UserControl {{ }}
301307
[TestMethod]
302308
public void PaneOptionWithDuplicateName_AllowedBetweenSamples()
303309
{
304-
var source = $@"
310+
var source = """
305311
using System.ComponentModel;
306312
using CommunityToolkit.Tooling.SampleGen;
307313
using CommunityToolkit.Tooling.SampleGen.Attributes;
308314
309315
namespace MyApp
310-
{{
311-
[ToolkitSampleBoolOption(""test"", false, Title = ""Toggle y"")]
316+
{
317+
[ToolkitSampleBoolOption("test", false, Title = "Toggle y")]
312318
313-
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: """")]
319+
[ToolkitSample(id: nameof(Sample), "Test Sample", description: "")]
314320
public partial class Sample : Windows.UI.Xaml.Controls.UserControl
315-
{{
316-
}}
321+
{
322+
}
317323
318-
[ToolkitSampleBoolOption(""test"", false, Title = ""Toggle y"")]
324+
[ToolkitSampleBoolOption("test", false, Title = "Toggle y")]
319325
320-
[ToolkitSample(id: nameof(Sample2), ""Test Sample"", description: """")]
326+
[ToolkitSample(id: nameof(Sample2), "Test Sample", description: "")]
321327
public partial class Sample2 : Windows.UI.Xaml.Controls.UserControl
322-
{{
323-
}}
324-
}}
328+
{
329+
}
330+
}
325331
326332
namespace Windows.UI.Xaml.Controls
327-
{{
328-
public class UserControl {{ }}
329-
}}";
333+
{
334+
public class UserControl { }
335+
}
336+
""";
330337

331338
var result = source.RunSourceGenerator<ToolkitSampleMetadataGenerator>(SAMPLE_ASM_NAME);
332339

@@ -336,19 +343,20 @@ public class UserControl {{ }}
336343
[TestMethod]
337344
public void SampleGeneratedOptionAttributeOnUnsupportedType()
338345
{
339-
var source = $@"
346+
var source = """
340347
using System.ComponentModel;
341348
using CommunityToolkit.Tooling.SampleGen;
342349
using CommunityToolkit.Tooling.SampleGen.Attributes;
343350
344351
namespace MyApp
345-
{{
346-
[ToolkitSampleMultiChoiceOption(""TextFontFamily"", ""Segoe UI"", ""Arial"", ""Consolas"", Title = ""Font family"")]
347-
[ToolkitSampleBoolOption(""Test"", false, Title = ""Toggle visibility"")]
352+
{
353+
[ToolkitSampleMultiChoiceOption("TextFontFamily", "Segoe UI", "Arial", "Consolas", Title = "Font family")]
354+
[ToolkitSampleBoolOption("Test", false, Title = "Toggle visibility")]
348355
public partial class Sample
349-
{{
350-
}}
351-
}}";
356+
{
357+
}
358+
}
359+
""";
352360

353361
var result = source.RunSourceGenerator<ToolkitSampleMetadataGenerator>(SAMPLE_ASM_NAME);
354362

@@ -358,25 +366,26 @@ public partial class Sample
358366
[TestMethod]
359367
public void PaneMultipleChoiceOptionWithNoChoices()
360368
{
361-
var source = $@"
369+
var source = """
362370
using System.ComponentModel;
363371
using CommunityToolkit.Tooling.SampleGen;
364372
using CommunityToolkit.Tooling.SampleGen.Attributes;
365373
366374
namespace MyApp
367-
{{
368-
[ToolkitSampleMultiChoiceOption(""TextFontFamily"", Title = ""Font family"")]
375+
{
376+
[ToolkitSampleMultiChoiceOption("TextFontFamily", Title = "Font family")]
369377
370-
[ToolkitSample(id: nameof(Sample), ""Test Sample"", description: """")]
378+
[ToolkitSample(id: nameof(Sample), "Test Sample", description: "")]
371379
public partial class Sample : Windows.UI.Xaml.Controls.UserControl
372-
{{
373-
}}
374-
}}
380+
{
381+
}
382+
}
375383
376384
namespace Windows.UI.Xaml.Controls
377-
{{
378-
public class UserControl {{ }}
379-
}}";
385+
{
386+
public class UserControl { }
387+
}
388+
""";
380389

381390
var result = source.RunSourceGenerator<ToolkitSampleMetadataGenerator>(SAMPLE_ASM_NAME);
382391

0 commit comments

Comments
 (0)