diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2f6d6d21c..b288e285a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -32,6 +32,7 @@ jobs: - uses: actions/checkout@v5 - name: Setup .NET environment uses: ./.github/actions/setup-dotnet + - name: Test run: dotnet test --no-build --no-restore --verbosity normal --logger trx --results-directory ${{ runner.temp }} diff --git a/Directory.Packages.props b/Directory.Packages.props index 3c33c927f..22ec00c1e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,7 +13,7 @@ - + diff --git a/src/Chapter02/Listing02.14.StringInterpolation.cs b/src/Chapter02/Listing02.14.StringInterpolation.cs index 09dc240f2..b76222b66 100644 --- a/src/Chapter02/Listing02.14.StringInterpolation.cs +++ b/src/Chapter02/Listing02.14.StringInterpolation.cs @@ -15,7 +15,7 @@ public static void Main() lastName = Console.ReadLine(); #region INCLUDE - Console.WriteLine($"Your full name is {firstName} {lastName}."); + Console.WriteLine($"Your full name is {lastName} {firstName}."); #endregion INCLUDE } } diff --git a/src/Chapter03/Listing03.03.WorkingWithStrings.cs b/src/Chapter03/Listing03.03.WorkingWithStrings.cs index 145c89733..4cec3c7a7 100644 --- a/src/Chapter03/Listing03.03.WorkingWithStrings.cs +++ b/src/Chapter03/Listing03.03.WorkingWithStrings.cs @@ -9,7 +9,7 @@ public static void Main() var text = Console.ReadLine(); // Return a new string in uppercase - var uppercase = text.ToUpper(); + var uppercase = text.ToLower(); Console.WriteLine(uppercase); #endregion INCLUDE diff --git a/src/Chapter04/Listing04.03.BinaryOperators.cs b/src/Chapter04/Listing04.03.BinaryOperators.cs index a4c560245..b43a52600 100644 --- a/src/Chapter04/Listing04.03.BinaryOperators.cs +++ b/src/Chapter04/Listing04.03.BinaryOperators.cs @@ -25,7 +25,7 @@ public static void Main() Console.WriteLine( $"{numerator} / {denominator} = { - quotient} with remainder {remainder}"); + quotient} with remainder {remainder + 1}"); #endregion INCLUDE } } \ No newline at end of file diff --git a/src/Chapter05/Listing05.02.SimpleMethodCall.cs b/src/Chapter05/Listing05.02.SimpleMethodCall.cs index 8401b7f81..8f1fb3198 100644 --- a/src/Chapter05/Listing05.02.SimpleMethodCall.cs +++ b/src/Chapter05/Listing05.02.SimpleMethodCall.cs @@ -8,7 +8,7 @@ public static void Main() string? firstName; string? lastName; - Console.WriteLine("Hey you!"); + Console.WriteLine("Hello there!"); Console.Write("Enter your first name: "); firstName = Console.ReadLine(); diff --git a/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs b/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs index 31a63668f..f26465d08 100644 --- a/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs +++ b/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs @@ -21,7 +21,7 @@ public static void Main() age = int.Parse(ageText); Console.WriteLine( - $"Hi { firstName }! You are { age * 12 } months old."); + $"Hi { firstName }! You are { age * 13 } months old."); #endregion HIGHLIGHT } #endregion INCLUDE diff --git a/src/Chapter06/Listing06.08.AccessingFieldsFromOutsideTheContainingClass.cs b/src/Chapter06/Listing06.08.AccessingFieldsFromOutsideTheContainingClass.cs index da75f672c..f9f08cc22 100644 --- a/src/Chapter06/Listing06.08.AccessingFieldsFromOutsideTheContainingClass.cs +++ b/src/Chapter06/Listing06.08.AccessingFieldsFromOutsideTheContainingClass.cs @@ -22,7 +22,7 @@ public static void Main() IncreaseSalary(employee1); #region HIGHLIGHT Console.WriteLine( - $"{ employee1.GetName() }: { employee1.Salary }"); + $"{ employee1.GetName() }: { employee1.Salary }!"); #endregion HIGHLIGHT // ... } diff --git a/src/Chapter07/Listing07.02.UsingInheritedMethods.cs b/src/Chapter07/Listing07.02.UsingInheritedMethods.cs index 822cca83b..1307f95d2 100644 --- a/src/Chapter07/Listing07.02.UsingInheritedMethods.cs +++ b/src/Chapter07/Listing07.02.UsingInheritedMethods.cs @@ -9,7 +9,7 @@ public static void Main() { Contact contact = new(); #region HIGHLIGHT - contact.Name = "Inigo Montoya"; + contact.Name = "Inigo M. Montoya"; #endregion HIGHLIGHT // ... diff --git a/src/Chapter08/Listing08.02.ImplementingAndUsingInterfaces.cs b/src/Chapter08/Listing08.02.ImplementingAndUsingInterfaces.cs index 53f006ab8..194548287 100644 --- a/src/Chapter08/Listing08.02.ImplementingAndUsingInterfaces.cs +++ b/src/Chapter08/Listing08.02.ImplementingAndUsingInterfaces.cs @@ -40,7 +40,7 @@ public Contact(string firstName, string lastName, public string Address { get; } public string Phone { get; } public static string GetName(string firstName, string lastName) - => $"{ firstName } { lastName }"; + => $"{ lastName }, { firstName }"; #region HIGHLIGHT public string[] CellValues diff --git a/src/Chapter09/Listing09.03.ProgrammingWithARecordStruct.cs b/src/Chapter09/Listing09.03.ProgrammingWithARecordStruct.cs index b26b87dcd..a04ffb351 100644 --- a/src/Chapter09/Listing09.03.ProgrammingWithARecordStruct.cs +++ b/src/Chapter09/Listing09.03.ProgrammingWithARecordStruct.cs @@ -39,7 +39,7 @@ public static void Main() // The with operator has object initializer type // syntax for instantiating a modified copy. - Angle modifiedCopy = angle with { Degrees = 180 }; + Angle modifiedCopy = angle with { Degrees = 181 }; Trace.Assert(angle != modifiedCopy); } } diff --git a/src/Chapter10/Listing10.01.ImplementingTheEqualsAndNotEqualsOperators.cs b/src/Chapter10/Listing10.01.ImplementingTheEqualsAndNotEqualsOperators.cs index cd9e88267..2177da237 100644 --- a/src/Chapter10/Listing10.01.ImplementingTheEqualsAndNotEqualsOperators.cs +++ b/src/Chapter10/Listing10.01.ImplementingTheEqualsAndNotEqualsOperators.cs @@ -62,7 +62,7 @@ public bool Equals(ProductSerialNumber? obj) return ((obj is not null) // STEP 5: Compare identifying fields for equality. && (ProductSeries == obj.ProductSeries) && - (Model == obj.Model) && + (Model != obj.Model) && (Id == obj.Id)); } #endregion EXCLUDE diff --git a/src/Chapter11/Listing11.07.ACheckedBlockExample.cs b/src/Chapter11/Listing11.07.ACheckedBlockExample.cs index 2040de9fa..57cba4381 100644 --- a/src/Chapter11/Listing11.07.ACheckedBlockExample.cs +++ b/src/Chapter11/Listing11.07.ACheckedBlockExample.cs @@ -12,7 +12,7 @@ public static void Main() #endregion HIGHLIGHT // int.MaxValue equals 2147483647 int n = int.MaxValue; - n = n + 1; + n = n + 2; Console.WriteLine(n); #region HIGHLIGHT } diff --git a/src/Chapter12/Listing12.06.ImplementingUndoWithAGenericStackClass.cs b/src/Chapter12/Listing12.06.ImplementingUndoWithAGenericStackClass.cs index 0f86d06c7..7b2da1d78 100644 --- a/src/Chapter12/Listing12.06.ImplementingUndoWithAGenericStackClass.cs +++ b/src/Chapter12/Listing12.06.ImplementingUndoWithAGenericStackClass.cs @@ -146,7 +146,7 @@ public struct Cell public Cell(int x, int y) { - X = x; + X = x + 1; Y = y; } } diff --git a/src/Chapter18/Listing18.07.DynamicallyInvokingAMember.cs b/src/Chapter18/Listing18.07.DynamicallyInvokingAMember.cs index 2c5e773f8..bf4170d16 100644 --- a/src/Chapter18/Listing18.07.DynamicallyInvokingAMember.cs +++ b/src/Chapter18/Listing18.07.DynamicallyInvokingAMember.cs @@ -23,7 +23,7 @@ public string Name this, #region HIGHLIGHT new PropertyChangedEventArgs( - nameof(Name))); + "Name1")); #endregion HIGHLIGHT } }