Skip to content

Commit

Permalink
Merge branch 'v12.0' into ascott18-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMichaelis authored Sep 5, 2023
2 parents aff5b87 + f9e8037 commit 145855e
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Chapter05/Listing05.30.RethrowingAnException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void Main()
catch (FormatException exception)
{
Console.WriteLine(
"A FormateException was thrown");
"A FormatException was thrown");
}
#region INCLUDE
// ...
Expand Down
6 changes: 3 additions & 3 deletions src/Chapter06/Listing06.06.AccessingFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static void Main()
employee1.Salary = "Too Little";
IncreaseSalary(employee1);
Console.WriteLine(
$"{
employee1.FirstName } {
employee1.LastName }: {
$"{
employee1.FirstName } {
employee1.LastName }: {
employee1.Salary }");
#endregion HIGHLIGHT
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public required string Title
}
set
{
ArgumentException.ThrowIfNullOrEmpty(
value = value?.Trim()!);
ArgumentException.ThrowIfNullOrEmpty(value);
_Title = value;
}
}
Expand All @@ -56,8 +55,7 @@ public required string Isbn
}
set
{
ArgumentException.ThrowIfNullOrEmpty(
value = value?.Trim()!);
ArgumentException.ThrowIfNullOrEmpty(value);
_Isbn = value;
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/Chapter13.Tests/Listing13.21.StaticAnonymousFunctions.Tests.cs
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" } );
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_21.Tests;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_22.Tests;

[TestClass]
public class ProgramTests
Expand All @@ -13,4 +13,4 @@ public void MainTest()
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_22.Tests;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_23.Tests;

[TestClass]
public class ProgramTests
Expand All @@ -13,4 +13,4 @@ public void MainTest()
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, CaptureLoop.Main);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_23.Tests;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_24.Tests;

[TestClass]
public class ProgramTests
Expand All @@ -13,4 +13,4 @@ public void MainTest()
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, DoNotCaptureLoop.Main);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_25.Tests;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_26.Tests;

[TestClass]
public class ProgramTests
Expand Down Expand Up @@ -30,4 +30,4 @@ public void Main_ExamingingAnExpressTree()
Program.Main();
});
}
}
}
50 changes: 50 additions & 0 deletions src/Chapter13/Listing13.21.StaticAnonymousFunctions.cs
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_21;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_22;

using System;
using Listing13_11;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_22;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_23;

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_23;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_24;

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_24;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_25;

/*
#region INCLUDE
Expand All @@ -8,4 +8,4 @@
SQL WHERE CLAUSE:
select * from Person where upper(Name) = 'INIGO MONTOYA';
#endregion INCLUDE
*/
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_25;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_26;

#region INCLUDE
using System;
Expand Down Expand Up @@ -58,4 +58,4 @@ private static string NodeToString(Expression expression) =>
" (" + expression.NodeType.ToString() + ")",
};
#endregion INCLUDE
}
}

0 comments on commit 145855e

Please sign in to comment.