-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v12.0' into ascott18-patch-1
- Loading branch information
Showing
14 changed files
with
92 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Chapter13.Tests/Listing13.21.StaticAnonymousFunctions.Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using AddisonWesley.Michaelis.EssentialCSharp.Shared.Tests; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_21.Tests; | ||
|
||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public async Task StaticAnonymousFunctionBehavior() | ||
{ | ||
await CompilerAssert.CompileAsync( | ||
new string[] { "Listing13.21.StaticAnonymousFunctions.cs", | ||
"Listing13.11.UsingADifferentFuncCompatibleMethod.cs"}, | ||
new string[] { "CS8820" } ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_21; | ||
|
||
using System; | ||
using Listing13_11; | ||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
int[] items = new int[5]; | ||
|
||
for (int i = 0; i < items.Length; i++) | ||
{ | ||
Console.Write("Enter an integer:"); | ||
string? text = Console.ReadLine(); | ||
if (!int.TryParse(text, out items[i])) | ||
{ | ||
Console.WriteLine($"'{text}' is not a valid integer."); | ||
return; | ||
} | ||
} | ||
|
||
#region INCLUDE | ||
int comparisonCount = 0; | ||
|
||
DelegateSample.BubbleSort(items, | ||
#region HIGHLIGHT | ||
static (int first, int second) => | ||
#endregion HIGHLIGHT | ||
{ | ||
#if COMPILEERROR // EXCLUDE | ||
// Error CS8820: A static anonymous function | ||
// cannot contain a reference to comparisonCount. | ||
comparisonCount++; | ||
#endif // COMPILEERROR EXCLUDE | ||
return first < second; | ||
} | ||
); | ||
|
||
for (int i = 0; i < items.Length; i++) | ||
{ | ||
Console.WriteLine(items[i]); | ||
} | ||
|
||
#region HIGHLIGHT | ||
Console.WriteLine("Items were compared {0} times.", | ||
comparisonCount); | ||
#endregion HIGHLIGHT | ||
} | ||
} | ||
#endregion INCLUDE |
2 changes: 1 addition & 1 deletion
2
...deGeneratedByCompilerForOuterVariables.cs → ...deGeneratedByCompilerForOuterVariables.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...13.22.CapturingLoopVariablesCSharpFive.cs → ...13.23.CapturingLoopVariablesCSharpFive.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...LoopVariableWorkaroundBeforeCSharpFive.cs → ...LoopVariableWorkaroundBeforeCSharpFive.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters