Skip to content

Commit fcca67a

Browse files
committed
Switch and Map methods are flagged with DebuggerStepThroughAttribute
1 parent 55b3b2b commit fcca67a

File tree

85 files changed

+492
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+492
-37
lines changed

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/AdHocUnions/AdHocUnionCodeGenerator.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -417,18 +417,18 @@ private void GenerateSwitchForAction(bool withState, bool isPartially)
417417
/// <exception cref=""System.InvalidOperationException"">If the union (struct) is not initialized or initialized with default value.</exception>");
418418
}
419419

420-
var methodName = isPartially ? "SwitchPartially" : "Switch";
420+
_sb.Append(@"
421+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
422+
public void ").Append(isPartially ? "SwitchPartially" : "Switch");
421423

422424
if (withState)
423425
{
424-
_sb.Append(@"
425-
public void ").Append(methodName).Append(@"<TState>(
426+
_sb.Append(@"<TState>(
426427
TState ").AppendEscaped(_state.Settings.SwitchMapStateParameterName).Append(",");
427428
}
428429
else
429430
{
430-
_sb.Append(@"
431-
public void ").Append(methodName).Append("(");
431+
_sb.Append("(");
432432
}
433433

434434
if (isPartially)
@@ -575,18 +575,18 @@ private void GenerateSwitchForFunc(bool withState, bool isPartially)
575575
/// <exception cref=""System.InvalidOperationException"">If the union (struct) is not initialized or initialized with default value.</exception>");
576576
}
577577

578-
var methodName = isPartially ? "SwitchPartially" : "Switch";
578+
_sb.Append(@"
579+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
580+
public TResult ").Append(isPartially ? "SwitchPartially" : "Switch");
579581

580582
if (withState)
581583
{
582-
_sb.Append(@"
583-
public TResult ").Append(methodName).Append(@"<TState, TResult>(
584+
_sb.Append(@"<TState, TResult>(
584585
TState ").AppendEscaped(_state.Settings.SwitchMapStateParameterName).Append(",");
585586
}
586587
else
587588
{
588-
_sb.Append(@"
589-
public TResult ").Append(methodName).Append("<TResult>(");
589+
_sb.Append("<TResult>(");
590590
}
591591

592592
if (isPartially)
@@ -729,10 +729,9 @@ private void GenerateMap(bool isPartially)
729729
/// <exception cref=""System.InvalidOperationException"">If the union (struct) is not initialized or initialized with default value.</exception>");
730730
}
731731

732-
var methodName = isPartially ? "MapPartially" : "Map";
733-
734732
_sb.Append(@"
735-
public TResult ").Append(methodName).Append("<TResult>(");
733+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
734+
public TResult ").Append(isPartially ? "MapPartially" : "Map").Append("<TResult>(");
736735

737736
if (isPartially)
738737
{

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/RegularUnions/RegularUnionCodeGenerator.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,9 @@ private void GenerateSwitchForAction(bool withState, bool isPartially)
223223
/// <param name=""").Append(typeMember.ArgumentName).Append(@""">The action to execute if the current type is ").AppendTypeForXmlComment(typeMember.State).Append(".</param>");
224224
}
225225

226-
var methodName = isPartially ? "SwitchPartially" : "Switch";
227-
228226
_sb.Append(@"
229-
public void ").Append(methodName);
227+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
228+
public void ").Append(isPartially ? "SwitchPartially" : "Switch");
230229

231230
if (withState)
232231
{
@@ -369,10 +368,9 @@ private void GenerateSwitchForFunc(bool withState, bool isPartially)
369368
/// <param name=""").Append(typeMember.ArgumentName).Append(@""">The function to execute if the current type is ").AppendTypeForXmlComment(typeMember.State).Append(".</param>");
370369
}
371370

372-
var methodName = isPartially ? "SwitchPartially" : "Switch";
373-
374371
_sb.Append(@"
375-
public TResult ").Append(methodName);
372+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
373+
public TResult ").Append(isPartially ? "SwitchPartially" : "Switch");
376374

377375
if (withState)
378376
{
@@ -509,10 +507,9 @@ private void GenerateMap(bool isPartially)
509507
/// <param name=""").Append(typeMember.ArgumentName).Append(@""">The instance to return if the current type is ").AppendTypeForXmlComment(typeMember.State).Append(".</param>");
510508
}
511509

512-
var methodName = isPartially ? "MapPartially" : "Map";
513-
514510
_sb.Append(@"
515-
public TResult ").Append(methodName).Append("<TResult>(");
511+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
512+
public TResult ").Append(isPartially ? "MapPartially" : "Map").Append("<TResult>(");
516513

517514
if (isPartially)
518515
{

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -426,18 +426,18 @@ private void GenerateSwitchForAction(bool withState, bool isPartially)
426426
_sb.Append(@""">The action to execute if the current item is equal to <see cref=""").Append(item.Name).Append(@"""/>.</param>");
427427
}
428428

429-
var methodName = isPartially ? "SwitchPartially" : "Switch";
429+
_sb.Append(@"
430+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
431+
public void ").Append(isPartially ? "SwitchPartially" : "Switch");
430432

431433
if (withState)
432434
{
433-
_sb.Append(@"
434-
public void ").Append(methodName).Append(@"<TState>(
435+
_sb.Append(@"<TState>(
435436
TState ").AppendEscaped(_state.Settings.SwitchMapStateParameterName).Append(",");
436437
}
437438
else
438439
{
439-
_sb.Append(@"
440-
public void ").Append(methodName).Append("(");
440+
_sb.Append("(");
441441
}
442442

443443
if (isPartially)
@@ -631,18 +631,18 @@ private void GenerateSwitchForFunc(bool withState, bool isPartially)
631631
_sb.Append(@""">The function to execute if the current item is equal to <see cref=""").Append(item.Name).Append(@"""/>.</param>");
632632
}
633633

634-
var methodName = isPartially ? "SwitchPartially" : "Switch";
634+
_sb.Append(@"
635+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
636+
public TResult ").Append(isPartially ? "SwitchPartially" : "Switch");
635637

636638
if (withState)
637639
{
638-
_sb.Append(@"
639-
public TResult ").Append(methodName).Append(@"<TState, TResult>(
640+
_sb.Append(@"<TState, TResult>(
640641
TState ").AppendEscaped(_state.Settings.SwitchMapStateParameterName).Append(",");
641642
}
642643
else
643644
{
644-
_sb.Append(@"
645-
public TResult ").Append(methodName).Append("<TResult>(");
645+
_sb.Append("<TResult>(");
646646
}
647647

648648
if (isPartially)
@@ -828,10 +828,9 @@ private void GenerateMap(bool isPartially)
828828
/// <param name=""").Append(item.ArgumentName).Append(@""">The instance to return if the current item is equal to <see cref=""").Append(item.Name).Append(@"""/>.</param>");
829829
}
830830

831-
var methodName = isPartially ? "MapPartially" : "Map";
832-
833831
_sb.Append(@"
834-
public TResult ").Append(methodName).Append("<TResult>(");
832+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
833+
public TResult ").Append(isPartially ? "MapPartially" : "Map").Append("<TResult>(");
835834

836835
if (isPartially)
837836
{
@@ -1586,7 +1585,7 @@ private void GenerateConstructors()
15861585
.Select(ctor =>
15871586
{
15881587
if (ctor.Arguments.Length == 0)
1589-
return (IReadOnlyList<ConstructorArgument>)[];
1588+
return (IReadOnlyList<ConstructorArgument>) [];
15901589

15911590
return ctor.Arguments
15921591
.Select(a =>

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.Should_generate_class_with_array.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ namespace Thinktecture.Tests
8585
/// </summary>
8686
/// <param name="stringArray">The action to execute if the current value is of type <c>string[]</c>.</param>
8787
/// <param name="int32">The action to execute if the current value is of type <see cref="int"/>.</param>
88+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
8889
public void Switch(
8990
global::System.Action<string[]> @stringArray,
9091
global::System.Action<int> @int32)
@@ -108,6 +109,7 @@ namespace Thinktecture.Tests
108109
/// <param name="state">State to be passed to the callbacks.</param>
109110
/// <param name="stringArray">The action to execute if the current value is of type <c>string[]</c>.</param>
110111
/// <param name="int32">The action to execute if the current value is of type <see cref="int"/>.</param>
112+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
111113
public void Switch<TState>(
112114
TState @state,
113115
global::System.Action<TState, string[]> @stringArray,
@@ -134,6 +136,7 @@ namespace Thinktecture.Tests
134136
/// </summary>
135137
/// <param name="stringArray">The function to execute if the current value is of type <c>string[]</c>.</param>
136138
/// <param name="int32">The function to execute if the current value is of type <see cref="int"/>.</param>
139+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
137140
public TResult Switch<TResult>(
138141
global::System.Func<string[], TResult> @stringArray,
139142
global::System.Func<int, TResult> @int32)
@@ -158,6 +161,7 @@ namespace Thinktecture.Tests
158161
/// <param name="state">State to be passed to the callbacks.</param>
159162
/// <param name="stringArray">The function to execute if the current value is of type <c>string[]</c>.</param>
160163
/// <param name="int32">The function to execute if the current value is of type <see cref="int"/>.</param>
164+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
161165
public TResult Switch<TState, TResult>(
162166
TState @state,
163167
global::System.Func<TState, string[], TResult> @stringArray,
@@ -183,6 +187,7 @@ namespace Thinktecture.Tests
183187
/// </summary>
184188
/// <param name="stringArray">The instance to return if the current value is of type <c>string[]</c>.</param>
185189
/// <param name="int32">The instance to return if the current value is of type <see cref="int"/>.</param>
190+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
186191
public TResult Map<TResult>(
187192
TResult @stringArray,
188193
TResult @int32)

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.Should_generate_class_with_generics.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ namespace Thinktecture.Tests
8585
/// </summary>
8686
/// <param name="listOfString">The action to execute if the current value is of type <c>global::System.Collections.Generic.List&lt;string&gt;</c>.</param>
8787
/// <param name="listOfInt32">The action to execute if the current value is of type <c>global::System.Collections.Generic.List&lt;int&gt;</c>.</param>
88+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
8889
public void Switch(
8990
global::System.Action<global::System.Collections.Generic.List<string>> @listOfString,
9091
global::System.Action<global::System.Collections.Generic.List<int>> @listOfInt32)
@@ -108,6 +109,7 @@ namespace Thinktecture.Tests
108109
/// <param name="state">State to be passed to the callbacks.</param>
109110
/// <param name="listOfString">The action to execute if the current value is of type <c>global::System.Collections.Generic.List&lt;string&gt;</c>.</param>
110111
/// <param name="listOfInt32">The action to execute if the current value is of type <c>global::System.Collections.Generic.List&lt;int&gt;</c>.</param>
112+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
111113
public void Switch<TState>(
112114
TState @state,
113115
global::System.Action<TState, global::System.Collections.Generic.List<string>> @listOfString,
@@ -134,6 +136,7 @@ namespace Thinktecture.Tests
134136
/// </summary>
135137
/// <param name="listOfString">The function to execute if the current value is of type <c>global::System.Collections.Generic.List&lt;string&gt;</c>.</param>
136138
/// <param name="listOfInt32">The function to execute if the current value is of type <c>global::System.Collections.Generic.List&lt;int&gt;</c>.</param>
139+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
137140
public TResult Switch<TResult>(
138141
global::System.Func<global::System.Collections.Generic.List<string>, TResult> @listOfString,
139142
global::System.Func<global::System.Collections.Generic.List<int>, TResult> @listOfInt32)
@@ -158,6 +161,7 @@ namespace Thinktecture.Tests
158161
/// <param name="state">State to be passed to the callbacks.</param>
159162
/// <param name="listOfString">The function to execute if the current value is of type <c>global::System.Collections.Generic.List&lt;string&gt;</c>.</param>
160163
/// <param name="listOfInt32">The function to execute if the current value is of type <c>global::System.Collections.Generic.List&lt;int&gt;</c>.</param>
164+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
161165
public TResult Switch<TState, TResult>(
162166
TState @state,
163167
global::System.Func<TState, global::System.Collections.Generic.List<string>, TResult> @listOfString,
@@ -183,6 +187,7 @@ namespace Thinktecture.Tests
183187
/// </summary>
184188
/// <param name="listOfString">The instance to return if the current value is of type <c>global::System.Collections.Generic.List&lt;string&gt;</c>.</param>
185189
/// <param name="listOfInt32">The instance to return if the current value is of type <c>global::System.Collections.Generic.List&lt;int&gt;</c>.</param>
190+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
186191
public TResult Map<TResult>(
187192
TResult @listOfString,
188193
TResult @listOfInt32)

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.Should_generate_class_with_nullable_string_and_nullable_int.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ namespace Thinktecture.Tests
8585
/// </summary>
8686
/// <param name="string">The action to execute if the current value is of type <c>string?</c>.</param>
8787
/// <param name="nullableOfInt32">The action to execute if the current value is of type <c>int?</c>.</param>
88+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
8889
public void Switch(
8990
global::System.Action<string?> @string,
9091
global::System.Action<int?> @nullableOfInt32)
@@ -108,6 +109,7 @@ namespace Thinktecture.Tests
108109
/// <param name="state">State to be passed to the callbacks.</param>
109110
/// <param name="string">The action to execute if the current value is of type <c>string?</c>.</param>
110111
/// <param name="nullableOfInt32">The action to execute if the current value is of type <c>int?</c>.</param>
112+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
111113
public void Switch<TState>(
112114
TState @state,
113115
global::System.Action<TState, string?> @string,
@@ -134,6 +136,7 @@ namespace Thinktecture.Tests
134136
/// </summary>
135137
/// <param name="string">The function to execute if the current value is of type <c>string?</c>.</param>
136138
/// <param name="nullableOfInt32">The function to execute if the current value is of type <c>int?</c>.</param>
139+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
137140
public TResult Switch<TResult>(
138141
global::System.Func<string?, TResult> @string,
139142
global::System.Func<int?, TResult> @nullableOfInt32)
@@ -158,6 +161,7 @@ namespace Thinktecture.Tests
158161
/// <param name="state">State to be passed to the callbacks.</param>
159162
/// <param name="string">The function to execute if the current value is of type <c>string?</c>.</param>
160163
/// <param name="nullableOfInt32">The function to execute if the current value is of type <c>int?</c>.</param>
164+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
161165
public TResult Switch<TState, TResult>(
162166
TState @state,
163167
global::System.Func<TState, string?, TResult> @string,
@@ -183,6 +187,7 @@ namespace Thinktecture.Tests
183187
/// </summary>
184188
/// <param name="string">The instance to return if the current value is of type <c>string?</c>.</param>
185189
/// <param name="nullableOfInt32">The instance to return if the current value is of type <c>int?</c>.</param>
190+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
186191
public TResult Map<TResult>(
187192
TResult @string,
188193
TResult @nullableOfInt32)

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.Should_generate_class_with_same_member_types.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ namespace Thinktecture.Tests
161161
/// <param name="string2">The action to execute if the current value is of type <see cref="string"/>.</param>
162162
/// <param name="string3">The action to execute if the current value is of type <c>string?</c>.</param>
163163
/// <param name="nullableOfInt32">The action to execute if the current value is of type <c>int?</c>.</param>
164+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
164165
public void Switch(
165166
global::System.Action<string> @text,
166167
global::System.Action<int> @int32,
@@ -199,6 +200,7 @@ namespace Thinktecture.Tests
199200
/// <param name="string2">The action to execute if the current value is of type <see cref="string"/>.</param>
200201
/// <param name="string3">The action to execute if the current value is of type <c>string?</c>.</param>
201202
/// <param name="nullableOfInt32">The action to execute if the current value is of type <c>int?</c>.</param>
203+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
202204
public void Switch<TState>(
203205
TState @state,
204206
global::System.Action<TState, string> @text,
@@ -240,6 +242,7 @@ namespace Thinktecture.Tests
240242
/// <param name="string2">The function to execute if the current value is of type <see cref="string"/>.</param>
241243
/// <param name="string3">The function to execute if the current value is of type <c>string?</c>.</param>
242244
/// <param name="nullableOfInt32">The function to execute if the current value is of type <c>int?</c>.</param>
245+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
243246
public TResult Switch<TResult>(
244247
global::System.Func<string, TResult> @text,
245248
global::System.Func<int, TResult> @int32,
@@ -276,6 +279,7 @@ namespace Thinktecture.Tests
276279
/// <param name="string2">The function to execute if the current value is of type <see cref="string"/>.</param>
277280
/// <param name="string3">The function to execute if the current value is of type <c>string?</c>.</param>
278281
/// <param name="nullableOfInt32">The function to execute if the current value is of type <c>int?</c>.</param>
282+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
279283
public TResult Switch<TState, TResult>(
280284
TState @state,
281285
global::System.Func<TState, string, TResult> @text,
@@ -313,6 +317,7 @@ namespace Thinktecture.Tests
313317
/// <param name="string2">The instance to return if the current value is of type <see cref="string"/>.</param>
314318
/// <param name="string3">The instance to return if the current value is of type <c>string?</c>.</param>
315319
/// <param name="nullableOfInt32">The instance to return if the current value is of type <c>int?</c>.</param>
320+
[global::System.Diagnostics.DebuggerStepThroughAttribute]
316321
public TResult Map<TResult>(
317322
TResult @text,
318323
TResult @int32,

0 commit comments

Comments
 (0)