Skip to content

Commit 18e93f4

Browse files
committed
Add tests for properties and nullable properties
1 parent 24a5baa commit 18e93f4

File tree

2 files changed

+201
-0
lines changed

2 files changed

+201
-0
lines changed

src/Razor/test/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/CodeDirective.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,36 @@ export function RunCodeDirectiveSuite() {
3737
`@code {
3838
private int currentCount = 0;
3939
40+
private void IncrementCount()
41+
{
42+
var someString = "{ var ThisShouldNotBeCSharp = true; }";
43+
currentCount++;
44+
}
45+
}`);
46+
});
47+
48+
it('Multi line with property', async () => {
49+
await assertMatchesSnapshot(
50+
`@code {
51+
public string Goo { get; set; }
52+
53+
private int currentCount = 0;
54+
55+
private void IncrementCount()
56+
{
57+
var someString = "{ var ThisShouldNotBeCSharp = true; }";
58+
currentCount++;
59+
}
60+
}`);
61+
});
62+
63+
it('Multi line with nullable property', async () => {
64+
await assertMatchesSnapshot(
65+
`@code {
66+
public string? Goo { get; set; }
67+
68+
private int currentCount = 0;
69+
4070
private void IncrementCount()
4171
{
4272
var someString = "{ var ThisShouldNotBeCSharp = true; }";

src/Razor/test/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/tests/__snapshots__/GrammarTests.test.ts.snap

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,177 @@ Line: }
241241
"
242242
`;
243243

244+
exports[`Grammar tests @code directive Multi line with nullable property 1`] = `
245+
"Line: @code {
246+
- token from 0 to 1 (@) with scopes text.aspnetcorerazor, keyword.control.cshtml.transition
247+
- token from 1 to 5 (code) with scopes text.aspnetcorerazor, keyword.control.razor.directive.code
248+
- token from 5 to 6 ( ) with scopes text.aspnetcorerazor
249+
- token from 6 to 7 ({) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, keyword.control.razor.directive.codeblock.open
250+
251+
Line: public string? Goo { get; set; }
252+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
253+
- token from 4 to 10 (public) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, storage.modifier.cs
254+
- token from 10 to 11 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
255+
- token from 11 to 17 (string) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
256+
- token from 17 to 18 (?) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.operator.conditional.question-mark.cs
257+
- token from 18 to 19 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
258+
- token from 19 to 22 (Goo) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
259+
- token from 22 to 23 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
260+
- token from 23 to 24 ({) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.curlybrace.open.cs
261+
- token from 24 to 25 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
262+
- token from 25 to 28 (get) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
263+
- token from 28 to 30 (; ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
264+
- token from 30 to 33 (set) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
265+
- token from 33 to 35 (; ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
266+
- token from 35 to 36 (}) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.curlybrace.close.cs
267+
268+
Line:
269+
- token from 0 to 1 () with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
270+
271+
Line: private int currentCount = 0;
272+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
273+
- token from 4 to 11 (private) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
274+
- token from 11 to 12 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
275+
- token from 12 to 15 (int) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
276+
- token from 15 to 16 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
277+
- token from 16 to 28 (currentCount) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
278+
- token from 28 to 29 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
279+
- token from 29 to 30 (=) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.operator.assignment.cs
280+
- token from 30 to 31 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
281+
- token from 31 to 32 (0) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, constant.numeric.decimal.cs
282+
- token from 32 to 34 (;) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
283+
284+
Line:
285+
- token from 0 to 1 () with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
286+
287+
Line: private void IncrementCount()
288+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
289+
- token from 4 to 11 (private) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
290+
- token from 11 to 12 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
291+
- token from 12 to 16 (void) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
292+
- token from 16 to 17 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
293+
- token from 17 to 31 (IncrementCount) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, entity.name.function.cs
294+
- token from 31 to 32 (() with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.parenthesis.open.cs
295+
- token from 32 to 33 ()) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.parenthesis.close.cs
296+
297+
Line: {
298+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
299+
- token from 4 to 5 ({) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.curlybrace.open.cs
300+
301+
Line: var someString = \\"{ var ThisShouldNotBeCSharp = true; }\\";
302+
- token from 0 to 8 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
303+
- token from 8 to 11 (var) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
304+
- token from 11 to 12 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
305+
- token from 12 to 22 (someString) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
306+
- token from 22 to 23 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
307+
- token from 23 to 24 (=) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.operator.assignment.cs
308+
- token from 24 to 25 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
309+
- token from 25 to 26 (\\") with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, string.quoted.double.cs, punctuation.definition.string.begin.cs
310+
- token from 26 to 63 ({ var ThisShouldNotBeCSharp = true; }) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, string.quoted.double.cs
311+
- token from 63 to 64 (\\") with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, string.quoted.double.cs, punctuation.definition.string.end.cs
312+
- token from 64 to 66 (;) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
313+
314+
Line: currentCount++;
315+
- token from 0 to 8 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
316+
- token from 8 to 20 (currentCount) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
317+
- token from 20 to 22 (++) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.operator.increment.cs
318+
- token from 22 to 24 (;) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
319+
320+
Line: }
321+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
322+
- token from 4 to 5 (}) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.curlybrace.close.cs
323+
324+
Line: }
325+
- token from 0 to 2 (}) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
326+
"
327+
`;
328+
329+
exports[`Grammar tests @code directive Multi line with property 1`] = `
330+
"Line: @code {
331+
- token from 0 to 1 (@) with scopes text.aspnetcorerazor, keyword.control.cshtml.transition
332+
- token from 1 to 5 (code) with scopes text.aspnetcorerazor, keyword.control.razor.directive.code
333+
- token from 5 to 6 ( ) with scopes text.aspnetcorerazor
334+
- token from 6 to 7 ({) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, keyword.control.razor.directive.codeblock.open
335+
336+
Line: public string Goo { get; set; }
337+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
338+
- token from 4 to 10 (public) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, storage.modifier.cs
339+
- token from 10 to 11 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
340+
- token from 11 to 17 (string) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
341+
- token from 17 to 18 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
342+
- token from 18 to 21 (Goo) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
343+
- token from 21 to 22 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
344+
- token from 22 to 23 ({) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.curlybrace.open.cs
345+
- token from 23 to 24 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
346+
- token from 24 to 27 (get) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
347+
- token from 27 to 28 (;) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.terminator.statement.cs
348+
- token from 28 to 29 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
349+
- token from 29 to 32 (set) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
350+
- token from 32 to 33 (;) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.terminator.statement.cs
351+
- token from 33 to 34 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
352+
- token from 34 to 35 (}) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.curlybrace.close.cs
353+
354+
Line:
355+
- token from 0 to 1 () with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
356+
357+
Line: private int currentCount = 0;
358+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
359+
- token from 4 to 11 (private) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, storage.modifier.cs
360+
- token from 11 to 12 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
361+
- token from 12 to 15 (int) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.type.cs
362+
- token from 15 to 16 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
363+
- token from 16 to 28 (currentCount) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, entity.name.variable.local.cs
364+
- token from 28 to 29 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
365+
- token from 29 to 30 (=) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.operator.assignment.cs
366+
- token from 30 to 31 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
367+
- token from 31 to 32 (0) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, constant.numeric.decimal.cs
368+
- token from 32 to 33 (;) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.terminator.statement.cs
369+
370+
Line:
371+
- token from 0 to 1 () with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
372+
373+
Line: private void IncrementCount()
374+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
375+
- token from 4 to 11 (private) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, storage.modifier.cs
376+
- token from 11 to 12 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
377+
- token from 12 to 16 (void) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.type.cs
378+
- token from 16 to 17 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
379+
- token from 17 to 31 (IncrementCount) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, entity.name.function.cs
380+
- token from 31 to 32 (() with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.parenthesis.open.cs
381+
- token from 32 to 33 ()) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.parenthesis.close.cs
382+
383+
Line: {
384+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
385+
- token from 4 to 5 ({) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.curlybrace.open.cs
386+
387+
Line: var someString = \\"{ var ThisShouldNotBeCSharp = true; }\\";
388+
- token from 0 to 8 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
389+
- token from 8 to 11 (var) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.other.var.cs
390+
- token from 11 to 12 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
391+
- token from 12 to 22 (someString) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, entity.name.variable.local.cs
392+
- token from 22 to 23 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
393+
- token from 23 to 24 (=) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.operator.assignment.cs
394+
- token from 24 to 25 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
395+
- token from 25 to 26 (\\") with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, string.quoted.double.cs, punctuation.definition.string.begin.cs
396+
- token from 26 to 63 ({ var ThisShouldNotBeCSharp = true; }) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, string.quoted.double.cs
397+
- token from 63 to 64 (\\") with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, string.quoted.double.cs, punctuation.definition.string.end.cs
398+
- token from 64 to 65 (;) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.terminator.statement.cs
399+
400+
Line: currentCount++;
401+
- token from 0 to 8 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
402+
- token from 8 to 20 (currentCount) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, variable.other.readwrite.cs
403+
- token from 20 to 22 (++) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, keyword.operator.increment.cs
404+
- token from 22 to 23 (;) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.terminator.statement.cs
405+
406+
Line: }
407+
- token from 0 to 4 ( ) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs
408+
- token from 4 to 5 (}) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, source.cs, punctuation.curlybrace.close.cs
409+
410+
Line: }
411+
- token from 0 to 1 (}) with scopes text.aspnetcorerazor, meta.structure.razor.directive.codeblock, keyword.control.razor.directive.codeblock.close
412+
"
413+
`;
414+
244415
exports[`Grammar tests @code directive Multi-line comment with curly braces 1`] = `
245416
"Line: @code { /* { var ThisShouldNotBeCSharp = true; } */ }
246417
- token from 0 to 1 (@) with scopes text.aspnetcorerazor, keyword.control.cshtml.transition

0 commit comments

Comments
 (0)