diff --git a/.github/workflows/CleanupCache.yml b/.github/workflows/CleanupCache.yml index de13a7e77..a7d3db318 100644 --- a/.github/workflows/CleanupCache.yml +++ b/.github/workflows/CleanupCache.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cleanup run: | diff --git a/.github/workflows/Code-Analysis.yml b/.github/workflows/Code-Analysis.yml index 543119190..9f9a71ffa 100644 --- a/.github/workflows/Code-Analysis.yml +++ b/.github/workflows/Code-Analysis.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup dotnet SDK uses: actions/setup-dotnet@v3 with: diff --git a/.github/workflows/LocalesTest.yml b/.github/workflows/LocalesTest.yml index e16da05d2..6da569b44 100644 --- a/.github/workflows/LocalesTest.yml +++ b/.github/workflows/LocalesTest.yml @@ -14,7 +14,7 @@ jobs: matrix: locale-lang: ["pt_BR.UTF-8", "fr_FR.UTF-8"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup dotnet SDK uses: actions/setup-dotnet@v3 with: diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 50f7fa402..6e29817c4 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -29,7 +29,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup dotnet SDK uses: actions/setup-dotnet@v3 with: diff --git a/src/Chapter01.Tests/Chapter01.Tests.csproj b/src/Chapter01.Tests/Chapter01.Tests.csproj index 6e1c9d67b..e9f175ad7 100644 --- a/src/Chapter01.Tests/Chapter01.Tests.csproj +++ b/src/Chapter01.Tests/Chapter01.Tests.csproj @@ -16,7 +16,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter02.Tests/Chapter02.Tests.csproj b/src/Chapter02.Tests/Chapter02.Tests.csproj index ffc1f21b1..59b8e5172 100644 --- a/src/Chapter02.Tests/Chapter02.Tests.csproj +++ b/src/Chapter02.Tests/Chapter02.Tests.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter03.Tests/Chapter03.Tests.csproj b/src/Chapter03.Tests/Chapter03.Tests.csproj index 6a0cee9bb..f2c6a6516 100644 --- a/src/Chapter03.Tests/Chapter03.Tests.csproj +++ b/src/Chapter03.Tests/Chapter03.Tests.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter04.Tests/Chapter04.Tests.csproj b/src/Chapter04.Tests/Chapter04.Tests.csproj index 3ac651e7f..d415e8b4b 100644 --- a/src/Chapter04.Tests/Chapter04.Tests.csproj +++ b/src/Chapter04.Tests/Chapter04.Tests.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter05.Tests/Chapter05.Tests.csproj b/src/Chapter05.Tests/Chapter05.Tests.csproj index d363e779a..8374b9fcf 100644 --- a/src/Chapter05.Tests/Chapter05.Tests.csproj +++ b/src/Chapter05.Tests/Chapter05.Tests.csproj @@ -23,7 +23,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter05.Tests/Listing05.10.Tests.cs b/src/Chapter05.Tests/Listing05.08.Tests.cs similarity index 97% rename from src/Chapter05.Tests/Listing05.10.Tests.cs rename to src/Chapter05.Tests/Listing05.08.Tests.cs index f860cb34b..54edb0020 100644 --- a/src/Chapter05.Tests/Listing05.10.Tests.cs +++ b/src/Chapter05.Tests/Listing05.08.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_10.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_08.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.09.StringBuilderImplicitUsingStatements.Tests.cs b/src/Chapter05.Tests/Listing05.10.StringBuilderImplicitUsingStatements.Tests.cs similarity index 97% rename from src/Chapter05.Tests/Listing05.09.StringBuilderImplicitUsingStatements.Tests.cs rename to src/Chapter05.Tests/Listing05.10.StringBuilderImplicitUsingStatements.Tests.cs index 08bbf4860..b29167232 100644 --- a/src/Chapter05.Tests/Listing05.09.StringBuilderImplicitUsingStatements.Tests.cs +++ b/src/Chapter05.Tests/Listing05.10.StringBuilderImplicitUsingStatements.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_09.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_10.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.11.Tests.cs b/src/Chapter05.Tests/Listing05.12.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.Tests.cs similarity index 80% rename from src/Chapter05.Tests/Listing05.11.Tests.cs rename to src/Chapter05.Tests/Listing05.12.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.Tests.cs index 64a35d75a..d44260518 100644 --- a/src/Chapter05.Tests/Listing05.11.Tests.cs +++ b/src/Chapter05.Tests/Listing05.12.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_11.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_12.Tests; [TestClass] public class ProgramTests @@ -10,6 +10,6 @@ public class ProgramTests public void Main_UsingToAvoidFullyQualifying_MethodCalledAsExpected() { IntelliTect.TestTools.Console.ConsoleAssert.Expect( - Listing05_10.Tests.ProgramTests.Expected, Program.Main); + Listing05_08.Tests.ProgramTests.Expected, Program.Main); } } diff --git a/src/Chapter05.Tests/Listing05.12.Tests.cs b/src/Chapter05.Tests/Listing05.13.UsingStaticDirective.Tests.cs similarity index 96% rename from src/Chapter05.Tests/Listing05.12.Tests.cs rename to src/Chapter05.Tests/Listing05.13.UsingStaticDirective.Tests.cs index 829881823..c32749eed 100644 --- a/src/Chapter05.Tests/Listing05.12.Tests.cs +++ b/src/Chapter05.Tests/Listing05.13.UsingStaticDirective.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_12.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_13.Tests; [TestClass] public class HeyYouTests diff --git a/src/Chapter05.Tests/Listing05.15.Tests.cs b/src/Chapter05.Tests/Listing05.16.PassingCommandLineArgumentsToMain.Tests.cs similarity index 99% rename from src/Chapter05.Tests/Listing05.15.Tests.cs rename to src/Chapter05.Tests/Listing05.16.PassingCommandLineArgumentsToMain.Tests.cs index e3b9434eb..aec436bdf 100644 --- a/src/Chapter05.Tests/Listing05.15.Tests.cs +++ b/src/Chapter05.Tests/Listing05.16.PassingCommandLineArgumentsToMain.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_15.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_16.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.16.Tests.cs b/src/Chapter05.Tests/Listing05.17.PassingVariablesByValue.Tests.cs similarity index 96% rename from src/Chapter05.Tests/Listing05.16.Tests.cs rename to src/Chapter05.Tests/Listing05.17.PassingVariablesByValue.Tests.cs index 908e2f2d6..0c7e77e05 100644 --- a/src/Chapter05.Tests/Listing05.16.Tests.cs +++ b/src/Chapter05.Tests/Listing05.17.PassingVariablesByValue.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_16.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_17.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.17.Tests.cs b/src/Chapter05.Tests/Listing05.18.PassingVariablesByReference.Tests.cs similarity index 96% rename from src/Chapter05.Tests/Listing05.17.Tests.cs rename to src/Chapter05.Tests/Listing05.18.PassingVariablesByReference.Tests.cs index 2b935f0ab..0939a5edb 100644 --- a/src/Chapter05.Tests/Listing05.17.Tests.cs +++ b/src/Chapter05.Tests/Listing05.18.PassingVariablesByReference.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_17.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_18.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.18.Tests.cs b/src/Chapter05.Tests/Listing05.19.PassingVariablesOutOnly.Tests.cs similarity index 98% rename from src/Chapter05.Tests/Listing05.18.Tests.cs rename to src/Chapter05.Tests/Listing05.19.PassingVariablesOutOnly.Tests.cs index dabd55ef0..71155a9aa 100644 --- a/src/Chapter05.Tests/Listing05.18.Tests.cs +++ b/src/Chapter05.Tests/Listing05.19.PassingVariablesOutOnly.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_18.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_19.Tests; [TestClass] public class ConvertToPhoneNumberTests diff --git a/src/Chapter05.Tests/Listing05.19.Tests.cs b/src/Chapter05.Tests/Listing05.20.ReturningAReference.Tests.cs similarity index 96% rename from src/Chapter05.Tests/Listing05.19.Tests.cs rename to src/Chapter05.Tests/Listing05.20.ReturningAReference.Tests.cs index e4269bd7c..c09e86b1d 100644 --- a/src/Chapter05.Tests/Listing05.19.Tests.cs +++ b/src/Chapter05.Tests/Listing05.20.ReturningAReference.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_19.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_20.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.20.Tests.cs b/src/Chapter05.Tests/Listing05.21.PassingAVariableParameterList.Tests.cs similarity index 98% rename from src/Chapter05.Tests/Listing05.20.Tests.cs rename to src/Chapter05.Tests/Listing05.21.PassingAVariableParameterList.Tests.cs index 372beea1d..d08cee478 100644 --- a/src/Chapter05.Tests/Listing05.20.Tests.cs +++ b/src/Chapter05.Tests/Listing05.21.PassingAVariableParameterList.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_20.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_21.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.21.Tests.cs b/src/Chapter05.Tests/Listing05.22.CountingLinesGivenADirectory.Tests.cs similarity index 97% rename from src/Chapter05.Tests/Listing05.21.Tests.cs rename to src/Chapter05.Tests/Listing05.22.CountingLinesGivenADirectory.Tests.cs index 2788ef3d8..5b24bf00b 100644 --- a/src/Chapter05.Tests/Listing05.21.Tests.cs +++ b/src/Chapter05.Tests/Listing05.22.CountingLinesGivenADirectory.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_21.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_22.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.23.Tests.cs b/src/Chapter05.Tests/Listing05.23.CountingLinesUsingOverloading.Tests.cs similarity index 100% rename from src/Chapter05.Tests/Listing05.23.Tests.cs rename to src/Chapter05.Tests/Listing05.23.CountingLinesUsingOverloading.Tests.cs diff --git a/src/Chapter05.Tests/Listing05.22.Tests.cs b/src/Chapter05.Tests/Listing05.24.MethodsWithOptionalParameters.Tests.cs similarity index 97% rename from src/Chapter05.Tests/Listing05.22.Tests.cs rename to src/Chapter05.Tests/Listing05.24.MethodsWithOptionalParameters.Tests.cs index f7be8ca22..0182b3514 100644 --- a/src/Chapter05.Tests/Listing05.22.Tests.cs +++ b/src/Chapter05.Tests/Listing05.24.MethodsWithOptionalParameters.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_22.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_24.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.25.Tests.cs b/src/Chapter05.Tests/Listing05.26.ConvertingAStringToAnInt.Tests.cs similarity index 97% rename from src/Chapter05.Tests/Listing05.25.Tests.cs rename to src/Chapter05.Tests/Listing05.26.ConvertingAStringToAnInt.Tests.cs index 7de989514..50d6722d7 100644 --- a/src/Chapter05.Tests/Listing05.25.Tests.cs +++ b/src/Chapter05.Tests/Listing05.26.ConvertingAStringToAnInt.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_25.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_26.Tests; [TestClass] public class ExceptionHandlingTests diff --git a/src/Chapter05.Tests/Listing05.26.Tests.cs b/src/Chapter05.Tests/Listing05.27.CatchingAnException.Tests.cs similarity index 98% rename from src/Chapter05.Tests/Listing05.26.Tests.cs rename to src/Chapter05.Tests/Listing05.27.CatchingAnException.Tests.cs index cff1c1754..7351a9ebf 100644 --- a/src/Chapter05.Tests/Listing05.26.Tests.cs +++ b/src/Chapter05.Tests/Listing05.27.CatchingAnException.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_26.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_27.Tests; [TestClass] public class ExceptionHandlingTests diff --git a/src/Chapter05.Tests/Listing05.27.Tests.cs b/src/Chapter05.Tests/Listing05.28.FinallyWithoutCatch.Tests.cs similarity index 97% rename from src/Chapter05.Tests/Listing05.27.Tests.cs rename to src/Chapter05.Tests/Listing05.28.FinallyWithoutCatch.Tests.cs index 61970462c..0c9d43fcc 100644 --- a/src/Chapter05.Tests/Listing05.27.Tests.cs +++ b/src/Chapter05.Tests/Listing05.28.FinallyWithoutCatch.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_27.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_28.Tests; [TestClass] public class ExceptionHandlingTests diff --git a/src/Chapter05.Tests/Listing05.28.Tests.cs b/src/Chapter05.Tests/Listing05.29.GeneralCatchBlocks.Tests.cs similarity index 98% rename from src/Chapter05.Tests/Listing05.28.Tests.cs rename to src/Chapter05.Tests/Listing05.29.GeneralCatchBlocks.Tests.cs index bf6770e06..650686274 100644 --- a/src/Chapter05.Tests/Listing05.28.Tests.cs +++ b/src/Chapter05.Tests/Listing05.29.GeneralCatchBlocks.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_28.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_29.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.29.Tests.cs b/src/Chapter05.Tests/Listing05.30.ThrowingAnException.Tests.cs similarity index 96% rename from src/Chapter05.Tests/Listing05.29.Tests.cs rename to src/Chapter05.Tests/Listing05.30.ThrowingAnException.Tests.cs index 679db5831..4e10a37f7 100644 --- a/src/Chapter05.Tests/Listing05.29.Tests.cs +++ b/src/Chapter05.Tests/Listing05.30.ThrowingAnException.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_29.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_30.Tests; [TestClass] public class ThrowingExceptionsTests diff --git a/src/Chapter05.Tests/Listing05.30.Tests.cs b/src/Chapter05.Tests/Listing05.31.RethrowingAnException.Tests.cs similarity index 96% rename from src/Chapter05.Tests/Listing05.30.Tests.cs rename to src/Chapter05.Tests/Listing05.31.RethrowingAnException.Tests.cs index e76c006fe..17b76d60d 100644 --- a/src/Chapter05.Tests/Listing05.30.Tests.cs +++ b/src/Chapter05.Tests/Listing05.31.RethrowingAnException.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_30.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_31.Tests; [TestClass] public class ThrowingExceptionsTests diff --git a/src/Chapter05.Tests/Listing05.31.Tests.cs b/src/Chapter05.Tests/Listing05.32.ParameterValidationThrowingArgumentNullException.Tests.cs similarity index 97% rename from src/Chapter05.Tests/Listing05.31.Tests.cs rename to src/Chapter05.Tests/Listing05.32.ParameterValidationThrowingArgumentNullException.Tests.cs index 129042df3..51686dc50 100644 --- a/src/Chapter05.Tests/Listing05.31.Tests.cs +++ b/src/Chapter05.Tests/Listing05.32.ParameterValidationThrowingArgumentNullException.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_31.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_32.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.32.Tests.cs b/src/Chapter05.Tests/Listing05.33.ParameterValidationWithArgumentException.ThrowIfNull.Tests.cs similarity index 97% rename from src/Chapter05.Tests/Listing05.32.Tests.cs rename to src/Chapter05.Tests/Listing05.33.ParameterValidationWithArgumentException.ThrowIfNull.Tests.cs index 1e19b25d6..591405d93 100644 --- a/src/Chapter05.Tests/Listing05.32.Tests.cs +++ b/src/Chapter05.Tests/Listing05.33.ParameterValidationWithArgumentException.ThrowIfNull.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_32.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_33.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.33.Tests.cs b/src/Chapter05.Tests/Listing05.34.CustomParameterValidation.Tests.cs similarity index 99% rename from src/Chapter05.Tests/Listing05.33.Tests.cs rename to src/Chapter05.Tests/Listing05.34.CustomParameterValidation.Tests.cs index 6c22f3855..64409dee5 100644 --- a/src/Chapter05.Tests/Listing05.33.Tests.cs +++ b/src/Chapter05.Tests/Listing05.34.CustomParameterValidation.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_33.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_34.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter05.Tests/Listing05.34.Tests.cs b/src/Chapter05.Tests/Listing05.35.TryCatch.Tests.cs similarity index 98% rename from src/Chapter05.Tests/Listing05.34.Tests.cs rename to src/Chapter05.Tests/Listing05.35.TryCatch.Tests.cs index 6e7dfd2f7..cabd9e88f 100644 --- a/src/Chapter05.Tests/Listing05.34.Tests.cs +++ b/src/Chapter05.Tests/Listing05.35.TryCatch.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_34.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_35.Tests; [TestClass] public class LeveragingTryParseTests diff --git a/src/Chapter05/Chapter05.csproj b/src/Chapter05/Chapter05.csproj index f2dc1bcb4..72a7e7734 100644 --- a/src/Chapter05/Chapter05.csproj +++ b/src/Chapter05/Chapter05.csproj @@ -9,7 +9,6 @@ - diff --git a/src/Chapter05/Listing05.10.UsingDirectiveExample.cs b/src/Chapter05/Listing05.08.UsingDirectiveExample.cs similarity index 99% rename from src/Chapter05/Listing05.10.UsingDirectiveExample.cs rename to src/Chapter05/Listing05.08.UsingDirectiveExample.cs index 24fa9eb6f..11a5e7ab5 100644 --- a/src/Chapter05/Listing05.10.UsingDirectiveExample.cs +++ b/src/Chapter05/Listing05.08.UsingDirectiveExample.cs @@ -2,7 +2,7 @@ // and the attribute is not available in .NET 6.0. #pragma warning disable SYSLIB1045 // Convert to 'GeneratedRegexAttribute'. -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_10; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_08; #region INCLUDE // The using directive imports all types from the diff --git a/src/Chapter05/Listing05.08.ImplicitUsingsGeneratedGlocalUsingDeclaratives.cs b/src/Chapter05/Listing05.09.ImplicitUsingsGeneratedGlocalUsingDeclaratives.cs similarity index 100% rename from src/Chapter05/Listing05.08.ImplicitUsingsGeneratedGlocalUsingDeclaratives.cs rename to src/Chapter05/Listing05.09.ImplicitUsingsGeneratedGlocalUsingDeclaratives.cs diff --git a/src/Chapter05/Listing05.09.StringBuilderImplicitUsingStatements.cs b/src/Chapter05/Listing05.10.StringBuilderImplicitUsingStatements.cs similarity index 98% rename from src/Chapter05/Listing05.09.StringBuilderImplicitUsingStatements.cs rename to src/Chapter05/Listing05.10.StringBuilderImplicitUsingStatements.cs index 09331c34b..5c0f5ab86 100644 --- a/src/Chapter05/Listing05.09.StringBuilderImplicitUsingStatements.cs +++ b/src/Chapter05/Listing05.10.StringBuilderImplicitUsingStatements.cs @@ -4,7 +4,7 @@ global using System.Text; #region EXCLUDE -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_09; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_10; #endregion EXCLUDE public class Program diff --git a/src/Chapter05/Listing05.09.UsingElementInProjectFile.xml b/src/Chapter05/Listing05.11.SampleConsoleProjectFileWithUsingElement.xml similarity index 93% rename from src/Chapter05/Listing05.09.UsingElementInProjectFile.xml rename to src/Chapter05/Listing05.11.SampleConsoleProjectFileWithUsingElement.xml index 6a8a43f6c..7d8961ae4 100644 --- a/src/Chapter05/Listing05.09.UsingElementInProjectFile.xml +++ b/src/Chapter05/Listing05.11.SampleConsoleProjectFileWithUsingElement.xml @@ -11,4 +11,4 @@ - + \ No newline at end of file diff --git a/src/Chapter05/Listing05.11.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs b/src/Chapter05/Listing05.12.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs similarity index 99% rename from src/Chapter05/Listing05.11.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs rename to src/Chapter05/Listing05.12.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs index 69d6052c7..85d486e05 100644 --- a/src/Chapter05/Listing05.11.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs +++ b/src/Chapter05/Listing05.12.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs @@ -2,7 +2,7 @@ // and the attribute is not available in .NET 6.0. #pragma warning disable SYSLIB1045 // Convert to 'GeneratedRegexAttribute'. -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_11; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_12; #region INCLUDE // The using directive imports all types from the diff --git a/src/Chapter05/Listing05.12.UsingStaticDirective.cs b/src/Chapter05/Listing05.13.UsingStaticDirective.cs similarity index 98% rename from src/Chapter05/Listing05.12.UsingStaticDirective.cs rename to src/Chapter05/Listing05.13.UsingStaticDirective.cs index 71c76dcc6..7dfba3799 100644 --- a/src/Chapter05/Listing05.12.UsingStaticDirective.cs +++ b/src/Chapter05/Listing05.13.UsingStaticDirective.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_12; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_13; #region INCLUDE using static System.Console; diff --git a/src/Chapter05/Listing05.13.DeclaringATypeAlias.cs b/src/Chapter05/Listing05.14.DeclaringATypeAlias.cs similarity index 97% rename from src/Chapter05/Listing05.13.DeclaringATypeAlias.cs rename to src/Chapter05/Listing05.14.DeclaringATypeAlias.cs index 27bc1b5a8..1e093bba9 100644 --- a/src/Chapter05/Listing05.13.DeclaringATypeAlias.cs +++ b/src/Chapter05/Listing05.14.DeclaringATypeAlias.cs @@ -1,5 +1,5 @@ #pragma warning disable CS0168 // Variable is declared but never used -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_13; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_14; #region INCLUDE #region HIGHLIGHT diff --git a/src/Chapter05/Listing05.14.DeclaringATypeAliasWithTheSameName.cs b/src/Chapter05/Listing05.15.DeclaringATypeAliasWithTheSameName.cs similarity index 98% rename from src/Chapter05/Listing05.14.DeclaringATypeAliasWithTheSameName.cs rename to src/Chapter05/Listing05.15.DeclaringATypeAliasWithTheSameName.cs index ad1b9953f..656e1f0fb 100644 --- a/src/Chapter05/Listing05.14.DeclaringATypeAliasWithTheSameName.cs +++ b/src/Chapter05/Listing05.15.DeclaringATypeAliasWithTheSameName.cs @@ -1,5 +1,5 @@ #pragma warning disable CS0168 // Variable is declared but never used -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_14; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_15; #region INCLUDE diff --git a/src/Chapter05/Listing05.15.PassingCommandLineArgumentsToMain.cs b/src/Chapter05/Listing05.16.PassingCommandLineArgumentsToMain.cs similarity index 99% rename from src/Chapter05/Listing05.15.PassingCommandLineArgumentsToMain.cs rename to src/Chapter05/Listing05.16.PassingCommandLineArgumentsToMain.cs index 6fa3142a1..b5279c6d1 100644 --- a/src/Chapter05/Listing05.15.PassingCommandLineArgumentsToMain.cs +++ b/src/Chapter05/Listing05.16.PassingCommandLineArgumentsToMain.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_15; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_16; #region INCLUDE public class Program diff --git a/src/Chapter05/Listing05.16.PassingVariablesByValue.cs b/src/Chapter05/Listing05.17.PassingVariablesByValue.cs similarity index 98% rename from src/Chapter05/Listing05.16.PassingVariablesByValue.cs rename to src/Chapter05/Listing05.17.PassingVariablesByValue.cs index d11d1e1c0..00e1f2d97 100644 --- a/src/Chapter05/Listing05.16.PassingVariablesByValue.cs +++ b/src/Chapter05/Listing05.17.PassingVariablesByValue.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_16; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_17; using System; diff --git a/src/Chapter05/Listing05.17.PassingVariablesByReference.cs b/src/Chapter05/Listing05.18.PassingVariablesByReference.cs similarity index 98% rename from src/Chapter05/Listing05.17.PassingVariablesByReference.cs rename to src/Chapter05/Listing05.18.PassingVariablesByReference.cs index c0d485397..47497d004 100644 --- a/src/Chapter05/Listing05.17.PassingVariablesByReference.cs +++ b/src/Chapter05/Listing05.18.PassingVariablesByReference.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_17; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_18; #region INCLUDE public class Program diff --git a/src/Chapter05/Listing05.18.PassingVariablesOutOnly.cs b/src/Chapter05/Listing05.19.PassingVariablesOutOnly.cs similarity index 99% rename from src/Chapter05/Listing05.18.PassingVariablesOutOnly.cs rename to src/Chapter05/Listing05.19.PassingVariablesOutOnly.cs index a9ab420e6..1584f82a8 100644 --- a/src/Chapter05/Listing05.18.PassingVariablesOutOnly.cs +++ b/src/Chapter05/Listing05.19.PassingVariablesOutOnly.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_18; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_19; public class ConvertToPhoneNumber { diff --git a/src/Chapter05/Listing05.19.ReturningAReference.cs b/src/Chapter05/Listing05.20.ReturningAReference.cs similarity index 99% rename from src/Chapter05/Listing05.19.ReturningAReference.cs rename to src/Chapter05/Listing05.20.ReturningAReference.cs index 6d76d6bf7..3ce0b09bc 100644 --- a/src/Chapter05/Listing05.19.ReturningAReference.cs +++ b/src/Chapter05/Listing05.20.ReturningAReference.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_19; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_20; using System; diff --git a/src/Chapter05/Listing05.20.PassingAVariableParameterList.cs b/src/Chapter05/Listing05.21.PassingAVariableParameterList.cs similarity index 99% rename from src/Chapter05/Listing05.20.PassingAVariableParameterList.cs rename to src/Chapter05/Listing05.21.PassingAVariableParameterList.cs index 2292483ad..d3918a3ee 100644 --- a/src/Chapter05/Listing05.20.PassingAVariableParameterList.cs +++ b/src/Chapter05/Listing05.21.PassingAVariableParameterList.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_20; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_21; #region INCLUDE using System; diff --git a/src/Chapter05/Listing05.21.CountingLinesGivenADirectory.cs b/src/Chapter05/Listing05.22.CountingLinesGivenADirectory.cs similarity index 99% rename from src/Chapter05/Listing05.21.CountingLinesGivenADirectory.cs rename to src/Chapter05/Listing05.22.CountingLinesGivenADirectory.cs index ac34baa34..92709f4cb 100644 --- a/src/Chapter05/Listing05.21.CountingLinesGivenADirectory.cs +++ b/src/Chapter05/Listing05.22.CountingLinesGivenADirectory.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_21; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_22; #region INCLUDE using System.IO; diff --git a/src/Chapter05/Listing05.22.CountingLinesUsingOverloading.cs b/src/Chapter05/Listing05.23.CountingLinesUsingOverloading.cs similarity index 99% rename from src/Chapter05/Listing05.22.CountingLinesUsingOverloading.cs rename to src/Chapter05/Listing05.23.CountingLinesUsingOverloading.cs index 22a50dabe..264dbdf91 100644 --- a/src/Chapter05/Listing05.22.CountingLinesUsingOverloading.cs +++ b/src/Chapter05/Listing05.23.CountingLinesUsingOverloading.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_22; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_23; #region INCLUDE public static class LineCounter diff --git a/src/Chapter05/Listing05.23.MethodsWithOptionalParameters.cs b/src/Chapter05/Listing05.24.MethodsWithOptionalParameters.cs similarity index 99% rename from src/Chapter05/Listing05.23.MethodsWithOptionalParameters.cs rename to src/Chapter05/Listing05.24.MethodsWithOptionalParameters.cs index ab6c8e7d7..97dcd5319 100644 --- a/src/Chapter05/Listing05.23.MethodsWithOptionalParameters.cs +++ b/src/Chapter05/Listing05.24.MethodsWithOptionalParameters.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_23; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_24; #region INCLUDE public static class LineCounter diff --git a/src/Chapter05/Listing05.24.SpecifyingParametersByName.cs b/src/Chapter05/Listing05.25.SpecifyingParametersByName.cs similarity index 97% rename from src/Chapter05/Listing05.24.SpecifyingParametersByName.cs rename to src/Chapter05/Listing05.25.SpecifyingParametersByName.cs index 534a324c9..108fcef9e 100644 --- a/src/Chapter05/Listing05.24.SpecifyingParametersByName.cs +++ b/src/Chapter05/Listing05.25.SpecifyingParametersByName.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_24; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_25; public class Program { diff --git a/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs b/src/Chapter05/Listing05.26.ConvertingAStringToAnInt.cs similarity index 98% rename from src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs rename to src/Chapter05/Listing05.26.ConvertingAStringToAnInt.cs index 31a63668f..7f3c64b7c 100644 --- a/src/Chapter05/Listing05.25.ConvertingAStringToAnInt.cs +++ b/src/Chapter05/Listing05.26.ConvertingAStringToAnInt.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_25; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_26; public class ExceptionHandling { diff --git a/src/Chapter05/Listing05.26.CatchingAnException.cs b/src/Chapter05/Listing05.27.CatchingAnException.cs similarity index 99% rename from src/Chapter05/Listing05.26.CatchingAnException.cs rename to src/Chapter05/Listing05.27.CatchingAnException.cs index 108204919..c6c1dd802 100644 --- a/src/Chapter05/Listing05.26.CatchingAnException.cs +++ b/src/Chapter05/Listing05.27.CatchingAnException.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_26; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_27; #region INCLUDE public class ExceptionHandling diff --git a/src/Chapter05/Listing05.27.FinallyWithoutCatch.cs b/src/Chapter05/Listing05.28.FinallyWithoutCatch.cs similarity index 98% rename from src/Chapter05/Listing05.27.FinallyWithoutCatch.cs rename to src/Chapter05/Listing05.28.FinallyWithoutCatch.cs index 9281bff0a..f2f45671a 100644 --- a/src/Chapter05/Listing05.27.FinallyWithoutCatch.cs +++ b/src/Chapter05/Listing05.28.FinallyWithoutCatch.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_27; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_28; #region INCLUDE using System; diff --git a/src/Chapter05/Listing05.28.GeneralCatchBlocks.cs b/src/Chapter05/Listing05.29.GeneralCatchBlocks.cs similarity index 99% rename from src/Chapter05/Listing05.28.GeneralCatchBlocks.cs rename to src/Chapter05/Listing05.29.GeneralCatchBlocks.cs index 9533ba627..116122c1c 100644 --- a/src/Chapter05/Listing05.28.GeneralCatchBlocks.cs +++ b/src/Chapter05/Listing05.29.GeneralCatchBlocks.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_28; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_29; #pragma warning disable CS0168 // Variable is declared but never used #region INCLUDE diff --git a/src/Chapter05/Listing05.29.ThrowingAnException.cs b/src/Chapter05/Listing05.30.ThrowingAnException.cs similarity index 99% rename from src/Chapter05/Listing05.29.ThrowingAnException.cs rename to src/Chapter05/Listing05.30.ThrowingAnException.cs index f5b319932..e086e8f10 100644 --- a/src/Chapter05/Listing05.29.ThrowingAnException.cs +++ b/src/Chapter05/Listing05.30.ThrowingAnException.cs @@ -1,7 +1,7 @@ #pragma warning disable CS1058 #pragma warning disable CS0168 // Variable is declared but never used #pragma warning disable CS0162 // Unreachable code detected -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_29; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_30; public class ThrowingExceptions { diff --git a/src/Chapter05/Listing05.30.RethrowingAnException.cs b/src/Chapter05/Listing05.31.RethrowingAnException.cs similarity index 99% rename from src/Chapter05/Listing05.30.RethrowingAnException.cs rename to src/Chapter05/Listing05.31.RethrowingAnException.cs index 65bf53add..4b9741975 100644 --- a/src/Chapter05/Listing05.30.RethrowingAnException.cs +++ b/src/Chapter05/Listing05.31.RethrowingAnException.cs @@ -1,7 +1,7 @@ #pragma warning disable CS0162 // Unreachable code detected #pragma warning disable CS1058 // A previous catch clause already catches all exceptions #pragma warning disable CS0168 // Variable is declared but never used -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_30; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_31; public class ThrowingExceptions { diff --git a/src/Chapter05/Listing05.31.ParameterValidationThrowingArgumentNullException.cs b/src/Chapter05/Listing05.32.ParameterValidationThrowingArgumentNullException.cs similarity index 98% rename from src/Chapter05/Listing05.31.ParameterValidationThrowingArgumentNullException.cs rename to src/Chapter05/Listing05.32.ParameterValidationThrowingArgumentNullException.cs index ab95bf269..bbd16e77f 100644 --- a/src/Chapter05/Listing05.31.ParameterValidationThrowingArgumentNullException.cs +++ b/src/Chapter05/Listing05.32.ParameterValidationThrowingArgumentNullException.cs @@ -1,5 +1,5 @@ #pragma warning disable IDE0059 // Unnecessary assignment of a value -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_31; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_32; public class Program { diff --git a/src/Chapter05/Listing05.32.ParameterValidationWithArgumentException.ThrowIfNull.cs b/src/Chapter05/Listing05.33.ParameterValidationWithArgumentException.ThrowIfNull.cs similarity index 98% rename from src/Chapter05/Listing05.32.ParameterValidationWithArgumentException.ThrowIfNull.cs rename to src/Chapter05/Listing05.33.ParameterValidationWithArgumentException.ThrowIfNull.cs index 668cc9c0c..cabed7bdb 100644 --- a/src/Chapter05/Listing05.32.ParameterValidationWithArgumentException.ThrowIfNull.cs +++ b/src/Chapter05/Listing05.33.ParameterValidationWithArgumentException.ThrowIfNull.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_32; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_33; public class Program { diff --git a/src/Chapter05/Listing05.33.CustomParameterValidation.cs b/src/Chapter05/Listing05.34.CustomParameterValidation.cs similarity index 99% rename from src/Chapter05/Listing05.33.CustomParameterValidation.cs rename to src/Chapter05/Listing05.34.CustomParameterValidation.cs index 6c8ecf7ab..88aa85290 100644 --- a/src/Chapter05/Listing05.33.CustomParameterValidation.cs +++ b/src/Chapter05/Listing05.34.CustomParameterValidation.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_33; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_34; #region INCLUDE public class Program diff --git a/src/Chapter05/Listing05.34.TryCatch.cs b/src/Chapter05/Listing05.35.TryCatch.cs similarity index 98% rename from src/Chapter05/Listing05.34.TryCatch.cs rename to src/Chapter05/Listing05.35.TryCatch.cs index 2479e707b..f1e517fde 100644 --- a/src/Chapter05/Listing05.34.TryCatch.cs +++ b/src/Chapter05/Listing05.35.TryCatch.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_34; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_35; public class LeveragingTryParse { diff --git a/src/Chapter06.Tests/Chapter06.Tests.csproj b/src/Chapter06.Tests/Chapter06.Tests.csproj index 1b1da10dc..d60602729 100644 --- a/src/Chapter06.Tests/Chapter06.Tests.csproj +++ b/src/Chapter06.Tests/Chapter06.Tests.csproj @@ -11,6 +11,6 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter06.Tests/Listing06.26.DefiningAConstructor.Tests.cs b/src/Chapter06.Tests/Listing06.26.DefiningAConstructor.Tests.cs index 964f8d77c..26fe029b2 100644 --- a/src/Chapter06.Tests/Listing06.26.DefiningAConstructor.Tests.cs +++ b/src/Chapter06.Tests/Listing06.26.DefiningAConstructor.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_26.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_28.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter06.Tests/Listing06.28.Tests.cs b/src/Chapter06.Tests/Listing06.29.DefaultConstructorNoLongerAvailable.Tests.cs similarity index 86% rename from src/Chapter06.Tests/Listing06.28.Tests.cs rename to src/Chapter06.Tests/Listing06.29.DefaultConstructorNoLongerAvailable.Tests.cs index 7ceaae4b7..0a105259a 100644 --- a/src/Chapter06.Tests/Listing06.28.Tests.cs +++ b/src/Chapter06.Tests/Listing06.29.DefaultConstructorNoLongerAvailable.Tests.cs @@ -1,7 +1,7 @@ using AddisonWesley.Michaelis.EssentialCSharp.Shared.Tests; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_28.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_29.Tests; [TestClass] public class ProgramTests @@ -12,7 +12,7 @@ public async Task UnassignedVariableThrowsError() await CompilerAssert.CompileAsync( new string[] { CompilerAssert.GetTargetFileNameToCompileFromTestFileName(), - "Listing06.26.DefiningAConstructor.cs" }, + "Listing06.28.DefiningAConstructor.cs" }, new string[] { "CS7036" }); } -} \ No newline at end of file +} diff --git a/src/Chapter06.Tests/Listing06.29.CallingAnObjectInitializer.Tests.cs b/src/Chapter06.Tests/Listing06.30.CallingAnObjectInitializerWithExplicitMemberAssignment.Tests.cs similarity index 96% rename from src/Chapter06.Tests/Listing06.29.CallingAnObjectInitializer.Tests.cs rename to src/Chapter06.Tests/Listing06.30.CallingAnObjectInitializerWithExplicitMemberAssignment.Tests.cs index 77f26e4de..292eaee87 100644 --- a/src/Chapter06.Tests/Listing06.29.CallingAnObjectInitializer.Tests.cs +++ b/src/Chapter06.Tests/Listing06.30.CallingAnObjectInitializerWithExplicitMemberAssignment.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_29.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_30.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter06.Tests/Listing06.32.OverloadingAConstructor.Tests.cs b/src/Chapter06.Tests/Listing06.33.OverloadingAConstructor.Tests.cs similarity index 96% rename from src/Chapter06.Tests/Listing06.32.OverloadingAConstructor.Tests.cs rename to src/Chapter06.Tests/Listing06.33.OverloadingAConstructor.Tests.cs index 79fc1bc76..6a997fb31 100644 --- a/src/Chapter06.Tests/Listing06.32.OverloadingAConstructor.Tests.cs +++ b/src/Chapter06.Tests/Listing06.33.OverloadingAConstructor.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_32.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_33.Tests; [TestClass] public class EmployeeTests diff --git a/src/Chapter06.Tests/Listing06.33.CallingOneConstructorFromAnother.Tests.cs b/src/Chapter06.Tests/Listing06.34.CallingOneConstructorFromAnother.Tests.cs similarity index 96% rename from src/Chapter06.Tests/Listing06.33.CallingOneConstructorFromAnother.Tests.cs rename to src/Chapter06.Tests/Listing06.34.CallingOneConstructorFromAnother.Tests.cs index 1889b6232..5ab9638c9 100644 --- a/src/Chapter06.Tests/Listing06.33.CallingOneConstructorFromAnother.Tests.cs +++ b/src/Chapter06.Tests/Listing06.34.CallingOneConstructorFromAnother.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_33.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_34.Tests; [TestClass] public class EmployeeTests diff --git a/src/Chapter06.Tests/Listing06.34.ProvidingAnInitializationMethod.Tests.cs b/src/Chapter06.Tests/Listing06.35.ProvidingAnInitializationMethod.Tests.cs similarity index 96% rename from src/Chapter06.Tests/Listing06.34.ProvidingAnInitializationMethod.Tests.cs rename to src/Chapter06.Tests/Listing06.35.ProvidingAnInitializationMethod.Tests.cs index 7703520b5..f1a190545 100644 --- a/src/Chapter06.Tests/Listing06.34.ProvidingAnInitializationMethod.Tests.cs +++ b/src/Chapter06.Tests/Listing06.35.ProvidingAnInitializationMethod.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_34.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_35.Tests; [TestClass] public class EmployeeTests diff --git a/src/Chapter06.Tests/Listing06.35.ProvidingValidationOnNon-NullableProperty.Tests.cs b/src/Chapter06.Tests/Listing06.36.ProvidingValidationOnNon-NullableProperty.Tests.cs similarity index 95% rename from src/Chapter06.Tests/Listing06.35.ProvidingValidationOnNon-NullableProperty.Tests.cs rename to src/Chapter06.Tests/Listing06.36.ProvidingValidationOnNon-NullableProperty.Tests.cs index 57e9d6155..8d72f2caf 100644 --- a/src/Chapter06.Tests/Listing06.35.ProvidingValidationOnNon-NullableProperty.Tests.cs +++ b/src/Chapter06.Tests/Listing06.36.ProvidingValidationOnNon-NullableProperty.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_35.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_36.Tests; [TestClass] public class EmployeeTests diff --git a/src/Chapter06.Tests/Listing06.38.SpecifyingRequiredMembersWithinTheObjectInitializer.Tests.cs b/src/Chapter06.Tests/Listing06.39.SpecifyingRequiredMembersWithinTheObjectInitializer.Tests.cs similarity index 84% rename from src/Chapter06.Tests/Listing06.38.SpecifyingRequiredMembersWithinTheObjectInitializer.Tests.cs rename to src/Chapter06.Tests/Listing06.39.SpecifyingRequiredMembersWithinTheObjectInitializer.Tests.cs index e2e73dfbb..1121c7cd5 100644 --- a/src/Chapter06.Tests/Listing06.38.SpecifyingRequiredMembersWithinTheObjectInitializer.Tests.cs +++ b/src/Chapter06.Tests/Listing06.39.SpecifyingRequiredMembersWithinTheObjectInitializer.Tests.cs @@ -1,7 +1,7 @@ using AddisonWesley.Michaelis.EssentialCSharp.Shared.Tests; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_38.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_39.Tests; #if NET7_0_OR_GREATER [TestClass] @@ -13,8 +13,8 @@ public async Task NotSpecifyingRequiredMembersWithinTheObjectInitializer() await CompilerAssert.CompileAsync( new string[]{ CompilerAssert.GetTargetFileNameToCompileFromTestFileName(), - "Listing06.37.RequiredProperties.cs"}, + "Listing06.38.RequiredProperties.cs"}, new string[] { "CS9035" }); } } -#endif // NET7_0_OR_GREATER \ No newline at end of file +#endif // NET7_0_OR_GREATER diff --git a/src/Chapter06.Tests/Listing06.40.UsingNotNullWhenAndNotNullIfNotNullAttributes.Tests.cs b/src/Chapter06.Tests/Listing06.41.UsingNotNullWhenAndNotNullIfNotNullAttributes.Tests.cs similarity index 98% rename from src/Chapter06.Tests/Listing06.40.UsingNotNullWhenAndNotNullIfNotNullAttributes.Tests.cs rename to src/Chapter06.Tests/Listing06.41.UsingNotNullWhenAndNotNullIfNotNullAttributes.Tests.cs index a8c56896a..d287036d3 100644 --- a/src/Chapter06.Tests/Listing06.40.UsingNotNullWhenAndNotNullIfNotNullAttributes.Tests.cs +++ b/src/Chapter06.Tests/Listing06.41.UsingNotNullWhenAndNotNullIfNotNullAttributes.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_40.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_41.Tests; [TestClass] public class NullabilityAttributesExaminedTests diff --git a/src/Chapter06.Tests/Listing06.41.PotentialNullReturnWithMaybeNullAttribute.Tests.cs b/src/Chapter06.Tests/Listing06.42.PotentialNullReturnWithMaybeNullAttribute.Tests.cs similarity index 97% rename from src/Chapter06.Tests/Listing06.41.PotentialNullReturnWithMaybeNullAttribute.Tests.cs rename to src/Chapter06.Tests/Listing06.42.PotentialNullReturnWithMaybeNullAttribute.Tests.cs index 67b0884a3..171e54103 100644 --- a/src/Chapter06.Tests/Listing06.41.PotentialNullReturnWithMaybeNullAttribute.Tests.cs +++ b/src/Chapter06.Tests/Listing06.42.PotentialNullReturnWithMaybeNullAttribute.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_41.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_42.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter06.Tests/Listing06.42.DefiningAndUsingADeconstructors.Tests.cs b/src/Chapter06.Tests/Listing06.43.DefiningAndUsingADeconstructors.Tests.cs similarity index 96% rename from src/Chapter06.Tests/Listing06.42.DefiningAndUsingADeconstructors.Tests.cs rename to src/Chapter06.Tests/Listing06.43.DefiningAndUsingADeconstructors.Tests.cs index f10973d43..e931fbe5b 100644 --- a/src/Chapter06.Tests/Listing06.42.DefiningAndUsingADeconstructors.Tests.cs +++ b/src/Chapter06.Tests/Listing06.43.DefiningAndUsingADeconstructors.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_42.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_43.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter06.Tests/Listing06.43.ImplicitlyInvokingDeconstructors.Tests.cs b/src/Chapter06.Tests/Listing06.44.ImplicitlyInvokingDeconstructors.Tests.cs similarity index 96% rename from src/Chapter06.Tests/Listing06.43.ImplicitlyInvokingDeconstructors.Tests.cs rename to src/Chapter06.Tests/Listing06.44.ImplicitlyInvokingDeconstructors.Tests.cs index 3ee92c824..c3ea91034 100644 --- a/src/Chapter06.Tests/Listing06.43.ImplicitlyInvokingDeconstructors.Tests.cs +++ b/src/Chapter06.Tests/Listing06.44.ImplicitlyInvokingDeconstructors.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_43.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_44.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter06.Tests/Listing06.46.AccessingAStaticField.Tests.cs b/src/Chapter06.Tests/Listing06.47.AccessingAStaticField.Tests.cs similarity index 96% rename from src/Chapter06.Tests/Listing06.46.AccessingAStaticField.Tests.cs rename to src/Chapter06.Tests/Listing06.47.AccessingAStaticField.Tests.cs index d7401e9a5..c1f3470d7 100644 --- a/src/Chapter06.Tests/Listing06.46.AccessingAStaticField.Tests.cs +++ b/src/Chapter06.Tests/Listing06.47.AccessingAStaticField.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_46.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_47.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter06.Tests/Listing06.47.DefiningAStaticMethodOnDirectoryInfo.Tests.cs b/src/Chapter06.Tests/Listing06.48.DefiningAStaticMethodOnDirectoryInfo.Tests.cs similarity index 98% rename from src/Chapter06.Tests/Listing06.47.DefiningAStaticMethodOnDirectoryInfo.Tests.cs rename to src/Chapter06.Tests/Listing06.48.DefiningAStaticMethodOnDirectoryInfo.Tests.cs index 6ab31d06e..d14b7988d 100644 --- a/src/Chapter06.Tests/Listing06.47.DefiningAStaticMethodOnDirectoryInfo.Tests.cs +++ b/src/Chapter06.Tests/Listing06.48.DefiningAStaticMethodOnDirectoryInfo.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_47.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_48.Tests; [TestClass] public class DirectoryTests diff --git a/src/Chapter06.Tests/Listing06.50.DeclaringAStaticClass.Tests.cs b/src/Chapter06.Tests/Listing06.51.DeclaringAStaticClass.Tests.cs similarity index 97% rename from src/Chapter06.Tests/Listing06.50.DeclaringAStaticClass.Tests.cs rename to src/Chapter06.Tests/Listing06.51.DeclaringAStaticClass.Tests.cs index 9d381e45c..c1e09938e 100644 --- a/src/Chapter06.Tests/Listing06.50.DeclaringAStaticClass.Tests.cs +++ b/src/Chapter06.Tests/Listing06.51.DeclaringAStaticClass.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_50.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_51.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter06.Tests/Listing06.54.DeclaringAReadOnlyAutomaticallyImplementedProperty.Tests.cs b/src/Chapter06.Tests/Listing06.55.DeclaringAReadOnlyAutomaticallyImplementedProperty.Tests.cs similarity index 95% rename from src/Chapter06.Tests/Listing06.54.DeclaringAReadOnlyAutomaticallyImplementedProperty.Tests.cs rename to src/Chapter06.Tests/Listing06.55.DeclaringAReadOnlyAutomaticallyImplementedProperty.Tests.cs index fa570c98a..037baa2cd 100644 --- a/src/Chapter06.Tests/Listing06.54.DeclaringAReadOnlyAutomaticallyImplementedProperty.Tests.cs +++ b/src/Chapter06.Tests/Listing06.55.DeclaringAReadOnlyAutomaticallyImplementedProperty.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_54.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_55.Tests; [TestClass] public class DirectoryTests diff --git a/src/Chapter06.Tests/Listing06.55.DefiningANestedClass.Tests.cs b/src/Chapter06.Tests/Listing06.56.DefiningANestedClass.Tests.cs similarity index 99% rename from src/Chapter06.Tests/Listing06.55.DefiningANestedClass.Tests.cs rename to src/Chapter06.Tests/Listing06.56.DefiningANestedClass.Tests.cs index f76612e62..d764001b4 100644 --- a/src/Chapter06.Tests/Listing06.55.DefiningANestedClass.Tests.cs +++ b/src/Chapter06.Tests/Listing06.56.DefiningANestedClass.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_55.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_56.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter06/Listing06.06.AccessingFields.cs b/src/Chapter06/Listing06.06.AccessingFields.cs index ecf72ac02..791cb207e 100644 --- a/src/Chapter06/Listing06.06.AccessingFields.cs +++ b/src/Chapter06/Listing06.06.AccessingFields.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_06; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_06; using Listing06_05; using System; diff --git a/src/Chapter06/Listing06.26.DefiningAPrimaryConstructor.cs b/src/Chapter06/Listing06.26.DefiningAPrimaryConstructor.cs new file mode 100644 index 000000000..8f4d82d8f --- /dev/null +++ b/src/Chapter06/Listing06.26.DefiningAPrimaryConstructor.cs @@ -0,0 +1,60 @@ +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_26; + +#if NET8_0_OR_GREATER +public class Program +{ + public static void Main() + { + Employee employee = new("Inigo", "Montoya"); + employee.Salary = "Too Little"; + + System.Console.WriteLine( + $"{employee.FirstName} {employee.LastName}: {employee.Salary}"); + } +} + +#region INCLUDE + #region HIGHLIGHT + // Employee constructor +public class Employee(string firstName, string lastName) +{ + public string FirstName { get; set; } = firstName; + public string LastName { get; set; } = lastName; + #endregion HIGHLIGHT + public string? Salary { get; set; } = "Not Enough"; + + #region EXCLUDE + public string? Title { get; set; } + public Employee? Manager { get; set; } + + // Name property + public string FullName + { + get + { + return FirstName + " " + LastName; + } + set + { + // Split the assigned value into + // first and last names + string[] names = value.Split(' '); + if(names.Length == 2) + { + FirstName = names[0]; + LastName = names[1]; + } + else + { + // Throw an exception if the full + // name was not assigned + throw new System.ArgumentException( + $"Assigned value '{ value }' is invalid", + nameof(value)); + } + } + } + #endregion EXCLUDE +} +#endregion INCLUDE +#endif // NET8_0_OR_GREATER \ No newline at end of file diff --git a/src/Chapter06/Listing06.27.CallingAConstructor.cs b/src/Chapter06/Listing06.27.CallingAConstructor.cs index 7ed879528..6608fa1ec 100644 --- a/src/Chapter06/Listing06.27.CallingAConstructor.cs +++ b/src/Chapter06/Listing06.27.CallingAConstructor.cs @@ -1,6 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_27; -using Listing06_26; +using Listing06_28; #region INCLUDE public class Program diff --git a/src/Chapter06/Listing06.26.DefiningAConstructor.cs b/src/Chapter06/Listing06.28.DefiningAConstructor.cs similarity index 94% rename from src/Chapter06/Listing06.26.DefiningAConstructor.cs rename to src/Chapter06/Listing06.28.DefiningAConstructor.cs index 693a37052..15eaa4b86 100644 --- a/src/Chapter06/Listing06.26.DefiningAConstructor.cs +++ b/src/Chapter06/Listing06.28.DefiningAConstructor.cs @@ -1,7 +1,4 @@ -// Disabled pending introductin to object initializers -#pragma warning disable IDE0017 - -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_26; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_28; public class Program { diff --git a/src/Chapter06/Listing06.28.DefaultConstructorNoLongerAvailable.cs b/src/Chapter06/Listing06.29.DefaultConstructorNoLongerAvailable.cs similarity index 94% rename from src/Chapter06/Listing06.28.DefaultConstructorNoLongerAvailable.cs rename to src/Chapter06/Listing06.29.DefaultConstructorNoLongerAvailable.cs index 41962bc91..8919cf678 100644 --- a/src/Chapter06/Listing06.28.DefaultConstructorNoLongerAvailable.cs +++ b/src/Chapter06/Listing06.29.DefaultConstructorNoLongerAvailable.cs @@ -1,9 +1,9 @@ // Variable is declared but never used #pragma warning disable CS0168 -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_28; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_29; -using Listing06_26; +using Listing06_28; #region INCLUDE public class Program diff --git a/src/Chapter06/Listing06.29.CallingAnObjectInitializerWithExplicitMemberAssignment.cs b/src/Chapter06/Listing06.30.CallingAnObjectInitializerWithExplicitMemberAssignment.cs similarity index 95% rename from src/Chapter06/Listing06.29.CallingAnObjectInitializerWithExplicitMemberAssignment.cs rename to src/Chapter06/Listing06.30.CallingAnObjectInitializerWithExplicitMemberAssignment.cs index 58d93de48..467be988e 100644 --- a/src/Chapter06/Listing06.29.CallingAnObjectInitializerWithExplicitMemberAssignment.cs +++ b/src/Chapter06/Listing06.30.CallingAnObjectInitializerWithExplicitMemberAssignment.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_29; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_30; #region INCLUDE public class Program diff --git a/src/Chapter06/Listing06.30.CallingAnObjectInitializer.cs b/src/Chapter06/Listing06.31.CallingAnObjectInitializer.cs similarity index 92% rename from src/Chapter06/Listing06.30.CallingAnObjectInitializer.cs rename to src/Chapter06/Listing06.31.CallingAnObjectInitializer.cs index 9a2841ae6..8293396b9 100644 --- a/src/Chapter06/Listing06.30.CallingAnObjectInitializer.cs +++ b/src/Chapter06/Listing06.31.CallingAnObjectInitializer.cs @@ -1,7 +1,7 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_30; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_31; using System.Collections.Generic; -using Listing06_26; +using Listing06_28; #region INCLUDE public class Program diff --git a/src/Chapter06/Listing06.31.InitOnlySetters.cs b/src/Chapter06/Listing06.32.InitOnlySetters.cs similarity index 99% rename from src/Chapter06/Listing06.31.InitOnlySetters.cs rename to src/Chapter06/Listing06.32.InitOnlySetters.cs index f232e69a0..c60ff9291 100644 --- a/src/Chapter06/Listing06.31.InitOnlySetters.cs +++ b/src/Chapter06/Listing06.32.InitOnlySetters.cs @@ -1,7 +1,7 @@ // Non-nullable field is uninitialized. Consider declaring as nullable. #pragma warning disable CS8618 // Pending a constructors -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_31; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_32; #region INCLUDE public class Employee diff --git a/src/Chapter06/Listing06.32.OverloadingAConstructor.cs b/src/Chapter06/Listing06.33.OverloadingAConstructor.cs similarity index 99% rename from src/Chapter06/Listing06.32.OverloadingAConstructor.cs rename to src/Chapter06/Listing06.33.OverloadingAConstructor.cs index 1546ae7ea..8fd2a432b 100644 --- a/src/Chapter06/Listing06.32.OverloadingAConstructor.cs +++ b/src/Chapter06/Listing06.33.OverloadingAConstructor.cs @@ -2,7 +2,7 @@ #pragma warning disable IDE0044 #pragma warning disable 649 // _Id is never assigned -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_32; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_33; #region INCLUDE public class Employee diff --git a/src/Chapter06/Listing06.33.CallingOneConstructorFromAnother.cs b/src/Chapter06/Listing06.34.CallingOneConstructorFromAnother.cs similarity index 99% rename from src/Chapter06/Listing06.33.CallingOneConstructorFromAnother.cs rename to src/Chapter06/Listing06.34.CallingOneConstructorFromAnother.cs index 5bd312e45..2d3429a91 100644 --- a/src/Chapter06/Listing06.33.CallingOneConstructorFromAnother.cs +++ b/src/Chapter06/Listing06.34.CallingOneConstructorFromAnother.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_33; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_34; #region INCLUDE public class Employee diff --git a/src/Chapter06/Listing06.34.ProvidingAnInitializationMethod.cs b/src/Chapter06/Listing06.35.ProvidingAnInitializationMethod.cs similarity index 99% rename from src/Chapter06/Listing06.34.ProvidingAnInitializationMethod.cs rename to src/Chapter06/Listing06.35.ProvidingAnInitializationMethod.cs index 475bbeca8..c0eb3d5c9 100644 --- a/src/Chapter06/Listing06.34.ProvidingAnInitializationMethod.cs +++ b/src/Chapter06/Listing06.35.ProvidingAnInitializationMethod.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_34; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_35; public class Program { diff --git a/src/Chapter06/Listing06.35.ProvidingValidationOnNon-NullableProperty.cs b/src/Chapter06/Listing06.36.ProvidingValidationOnNon-NullableProperty.cs similarity index 98% rename from src/Chapter06/Listing06.35.ProvidingValidationOnNon-NullableProperty.cs rename to src/Chapter06/Listing06.36.ProvidingValidationOnNon-NullableProperty.cs index fbaea9ba8..02b6bef67 100644 --- a/src/Chapter06/Listing06.35.ProvidingValidationOnNon-NullableProperty.cs +++ b/src/Chapter06/Listing06.36.ProvidingValidationOnNon-NullableProperty.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_35; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_36; using System; diff --git a/src/Chapter06/Listing06.36.ValidationOfNonNullReferenceTypeAutomaticallyImplementedProperties.cs b/src/Chapter06/Listing06.37.ValidationOfNonNullReferenceTypeAutomaticallyImplementedProperties.cs similarity index 97% rename from src/Chapter06/Listing06.36.ValidationOfNonNullReferenceTypeAutomaticallyImplementedProperties.cs rename to src/Chapter06/Listing06.37.ValidationOfNonNullReferenceTypeAutomaticallyImplementedProperties.cs index 96c38a6d0..bd115a6c3 100644 --- a/src/Chapter06/Listing06.36.ValidationOfNonNullReferenceTypeAutomaticallyImplementedProperties.cs +++ b/src/Chapter06/Listing06.37.ValidationOfNonNullReferenceTypeAutomaticallyImplementedProperties.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_36; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_37; using System; diff --git a/src/Chapter06/Listing06.37.RequiredProperties.cs b/src/Chapter06/Listing06.38.RequiredProperties.cs similarity index 99% rename from src/Chapter06/Listing06.37.RequiredProperties.cs rename to src/Chapter06/Listing06.38.RequiredProperties.cs index e09e7e336..505c87d51 100644 --- a/src/Chapter06/Listing06.37.RequiredProperties.cs +++ b/src/Chapter06/Listing06.38.RequiredProperties.cs @@ -1,6 +1,6 @@ #if NET7_0_OR_GREATER -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_37; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_38; #region INCLUDE public class Book diff --git a/src/Chapter06/Listing06.38.SpecifyingRequiredMembersWithinTheObjectInitializer.cs b/src/Chapter06/Listing06.39.SpecifyingRequiredMembersWithinTheObjectInitializer.cs similarity index 97% rename from src/Chapter06/Listing06.38.SpecifyingRequiredMembersWithinTheObjectInitializer.cs rename to src/Chapter06/Listing06.39.SpecifyingRequiredMembersWithinTheObjectInitializer.cs index 4e40eca6c..f3004b9a3 100644 --- a/src/Chapter06/Listing06.38.SpecifyingRequiredMembersWithinTheObjectInitializer.cs +++ b/src/Chapter06/Listing06.39.SpecifyingRequiredMembersWithinTheObjectInitializer.cs @@ -1,12 +1,12 @@ #if NET7_0_OR_GREATER #if COMPILEERROR // EXCLUDE -using AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_37; +using AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_38; #endif // COMPILEERROR // EXCLUDE using System.Runtime.CompilerServices; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_38; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_39; public class Program { diff --git a/src/Chapter06/Listing06.39.DisablingRequiredObjectInitialization.cs b/src/Chapter06/Listing06.40.DisablingRequiredObjectInitialization.cs similarity index 99% rename from src/Chapter06/Listing06.39.DisablingRequiredObjectInitialization.cs rename to src/Chapter06/Listing06.40.DisablingRequiredObjectInitialization.cs index 6dd35fca7..e11399fb8 100644 --- a/src/Chapter06/Listing06.39.DisablingRequiredObjectInitialization.cs +++ b/src/Chapter06/Listing06.40.DisablingRequiredObjectInitialization.cs @@ -1,7 +1,7 @@ #if NET7_0_OR_GREATER using System.Diagnostics.CodeAnalysis; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_39; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_40; public class Program { diff --git a/src/Chapter06/Listing06.40.UsingNotNullWhenAndNotNullIfNotNullAttributes.cs b/src/Chapter06/Listing06.41.UsingNotNullWhenAndNotNullIfNotNullAttributes.cs similarity index 99% rename from src/Chapter06/Listing06.40.UsingNotNullWhenAndNotNullIfNotNullAttributes.cs rename to src/Chapter06/Listing06.41.UsingNotNullWhenAndNotNullIfNotNullAttributes.cs index 344e0bcb8..74921691a 100644 --- a/src/Chapter06/Listing06.40.UsingNotNullWhenAndNotNullIfNotNullAttributes.cs +++ b/src/Chapter06/Listing06.41.UsingNotNullWhenAndNotNullIfNotNullAttributes.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_40; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_41; #region INCLUDE using System.Diagnostics.CodeAnalysis; diff --git a/src/Chapter06/Listing06.41.PotentialNullReturnWithMaybeNullAttribute.cs b/src/Chapter06/Listing06.42.PotentialNullReturnWithMaybeNullAttribute.cs similarity index 98% rename from src/Chapter06/Listing06.41.PotentialNullReturnWithMaybeNullAttribute.cs rename to src/Chapter06/Listing06.42.PotentialNullReturnWithMaybeNullAttribute.cs index e9d4d3899..c3b118105 100644 --- a/src/Chapter06/Listing06.41.PotentialNullReturnWithMaybeNullAttribute.cs +++ b/src/Chapter06/Listing06.42.PotentialNullReturnWithMaybeNullAttribute.cs @@ -1,5 +1,5 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_41; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_42; using System; using System.Diagnostics.CodeAnalysis; diff --git a/src/Chapter06/Listing06.42.DefiningAndUsingADeconstructors.cs b/src/Chapter06/Listing06.43.DefiningAndUsingADeconstructors.cs similarity index 99% rename from src/Chapter06/Listing06.42.DefiningAndUsingADeconstructors.cs rename to src/Chapter06/Listing06.43.DefiningAndUsingADeconstructors.cs index 41f7efcdb..679f4e70a 100644 --- a/src/Chapter06/Listing06.42.DefiningAndUsingADeconstructors.cs +++ b/src/Chapter06/Listing06.43.DefiningAndUsingADeconstructors.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_42; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_43; #region INCLUDE public class Employee diff --git a/src/Chapter06/Listing06.43.ImplicitlyInvokingDeconstructors.cs b/src/Chapter06/Listing06.44.ImplicitlyInvokingDeconstructors.cs similarity index 98% rename from src/Chapter06/Listing06.43.ImplicitlyInvokingDeconstructors.cs rename to src/Chapter06/Listing06.44.ImplicitlyInvokingDeconstructors.cs index d6b6f5470..e8c773224 100644 --- a/src/Chapter06/Listing06.43.ImplicitlyInvokingDeconstructors.cs +++ b/src/Chapter06/Listing06.44.ImplicitlyInvokingDeconstructors.cs @@ -1,6 +1,6 @@ -using AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_42; +using AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_43; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_43; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_44; #region INCLUDE public class Program diff --git a/src/Chapter06/Listing06.44.DeclaringAStaticField.cs b/src/Chapter06/Listing06.45.DeclaringAStaticField.cs similarity index 98% rename from src/Chapter06/Listing06.44.DeclaringAStaticField.cs rename to src/Chapter06/Listing06.45.DeclaringAStaticField.cs index b42cb7a16..d6848ede6 100644 --- a/src/Chapter06/Listing06.44.DeclaringAStaticField.cs +++ b/src/Chapter06/Listing06.45.DeclaringAStaticField.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_44; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_45; #region INCLUDE public class Employee diff --git a/src/Chapter06/Listing06.45.AssigningAStaticFieldAtDeclaration.cs b/src/Chapter06/Listing06.46.AssigningAStaticFieldAtDeclaration.cs similarity index 95% rename from src/Chapter06/Listing06.45.AssigningAStaticFieldAtDeclaration.cs rename to src/Chapter06/Listing06.46.AssigningAStaticFieldAtDeclaration.cs index c1d2a9fec..3e5fbadfe 100644 --- a/src/Chapter06/Listing06.45.AssigningAStaticFieldAtDeclaration.cs +++ b/src/Chapter06/Listing06.46.AssigningAStaticFieldAtDeclaration.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_45; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_46; #region INCLUDE public class Employee diff --git a/src/Chapter06/Listing06.46.AccessingAStaticField.cs b/src/Chapter06/Listing06.47.AccessingAStaticField.cs similarity index 99% rename from src/Chapter06/Listing06.46.AccessingAStaticField.cs rename to src/Chapter06/Listing06.47.AccessingAStaticField.cs index 77cf1380a..c4c8e7122 100644 --- a/src/Chapter06/Listing06.46.AccessingAStaticField.cs +++ b/src/Chapter06/Listing06.47.AccessingAStaticField.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_46; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_47; #region INCLUDE using System; diff --git a/src/Chapter06/Listing06.47.DefiningAStaticMethodOnDirectoryInfo.cs b/src/Chapter06/Listing06.48.DefiningAStaticMethodOnDirectoryInfo.cs similarity index 99% rename from src/Chapter06/Listing06.47.DefiningAStaticMethodOnDirectoryInfo.cs rename to src/Chapter06/Listing06.48.DefiningAStaticMethodOnDirectoryInfo.cs index 51240ce91..e3d4ec0f7 100644 --- a/src/Chapter06/Listing06.47.DefiningAStaticMethodOnDirectoryInfo.cs +++ b/src/Chapter06/Listing06.48.DefiningAStaticMethodOnDirectoryInfo.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_47; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_48; using System; using System.IO; diff --git a/src/Chapter06/Listing06.48.DeclaringAStaticConstructor.cs b/src/Chapter06/Listing06.49.DeclaringAStaticConstructor.cs similarity index 96% rename from src/Chapter06/Listing06.48.DeclaringAStaticConstructor.cs rename to src/Chapter06/Listing06.49.DeclaringAStaticConstructor.cs index 53b6ed29c..3079b66f0 100644 --- a/src/Chapter06/Listing06.48.DeclaringAStaticConstructor.cs +++ b/src/Chapter06/Listing06.49.DeclaringAStaticConstructor.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_48; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_49; using System; diff --git a/src/Chapter06/Listing06.49.DeclaringAStaticProperty.cs b/src/Chapter06/Listing06.50.DeclaringAStaticProperty.cs similarity index 97% rename from src/Chapter06/Listing06.49.DeclaringAStaticProperty.cs rename to src/Chapter06/Listing06.50.DeclaringAStaticProperty.cs index f88178c7d..d79759aa9 100644 --- a/src/Chapter06/Listing06.49.DeclaringAStaticProperty.cs +++ b/src/Chapter06/Listing06.50.DeclaringAStaticProperty.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_49; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_50; #region INCLUDE public class Employee diff --git a/src/Chapter06/Listing06.50.DeclaringAStaticClass.cs b/src/Chapter06/Listing06.51.DeclaringAStaticClass.cs similarity index 99% rename from src/Chapter06/Listing06.50.DeclaringAStaticClass.cs rename to src/Chapter06/Listing06.51.DeclaringAStaticClass.cs index 367ed215c..43b35c477 100644 --- a/src/Chapter06/Listing06.50.DeclaringAStaticClass.cs +++ b/src/Chapter06/Listing06.51.DeclaringAStaticClass.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_50; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_51; using System; using static SimpleMath; diff --git a/src/Chapter06/Listing06.51.StaticCopyMethodForDirectoryInfo.cs b/src/Chapter06/Listing06.52.StaticCopyMethodForDirectoryInfo.cs similarity index 99% rename from src/Chapter06/Listing06.51.StaticCopyMethodForDirectoryInfo.cs rename to src/Chapter06/Listing06.52.StaticCopyMethodForDirectoryInfo.cs index c7f996a3f..053f5376b 100644 --- a/src/Chapter06/Listing06.51.StaticCopyMethodForDirectoryInfo.cs +++ b/src/Chapter06/Listing06.52.StaticCopyMethodForDirectoryInfo.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_51; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_52; using System; using System.IO; diff --git a/src/Chapter06/Listing06.52.DeclaringAConstantField.cs b/src/Chapter06/Listing06.53.DeclaringAConstantField.cs similarity index 95% rename from src/Chapter06/Listing06.52.DeclaringAConstantField.cs rename to src/Chapter06/Listing06.53.DeclaringAConstantField.cs index 9049f86a5..314b8991c 100644 --- a/src/Chapter06/Listing06.52.DeclaringAConstantField.cs +++ b/src/Chapter06/Listing06.53.DeclaringAConstantField.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_52; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_53; #region INCLUDE public class ConvertUnits diff --git a/src/Chapter06/Listing06.53.DeclaringAFieldAsReadonly.cs b/src/Chapter06/Listing06.54.DeclaringAFieldAsReadonly.cs similarity index 98% rename from src/Chapter06/Listing06.53.DeclaringAFieldAsReadonly.cs rename to src/Chapter06/Listing06.54.DeclaringAFieldAsReadonly.cs index 19ca85741..64f7c0656 100644 --- a/src/Chapter06/Listing06.53.DeclaringAFieldAsReadonly.cs +++ b/src/Chapter06/Listing06.54.DeclaringAFieldAsReadonly.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_53; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_54; #region INCLUDE public class Employee diff --git a/src/Chapter06/Listing06.54.DeclaringAReadOnlyAutomaticallyImplementedProperty.cs b/src/Chapter06/Listing06.55.DeclaringAReadOnlyAutomaticallyImplementedProperty.cs similarity index 99% rename from src/Chapter06/Listing06.54.DeclaringAReadOnlyAutomaticallyImplementedProperty.cs rename to src/Chapter06/Listing06.55.DeclaringAReadOnlyAutomaticallyImplementedProperty.cs index 32a157117..45d006f99 100644 --- a/src/Chapter06/Listing06.54.DeclaringAReadOnlyAutomaticallyImplementedProperty.cs +++ b/src/Chapter06/Listing06.55.DeclaringAReadOnlyAutomaticallyImplementedProperty.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_54; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_55; using System; diff --git a/src/Chapter06/Listing06.55.DefiningANestedClass.cs b/src/Chapter06/Listing06.56.DefiningANestedClass.cs similarity index 99% rename from src/Chapter06/Listing06.55.DefiningANestedClass.cs rename to src/Chapter06/Listing06.56.DefiningANestedClass.cs index f4f77425d..7a1c8133f 100644 --- a/src/Chapter06/Listing06.55.DefiningANestedClass.cs +++ b/src/Chapter06/Listing06.56.DefiningANestedClass.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_55; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_56; using System; diff --git a/src/Chapter06/Listing06.56.DefiningAPartialClass.cs b/src/Chapter06/Listing06.57.DefiningAPartialClass.cs similarity index 95% rename from src/Chapter06/Listing06.56.DefiningAPartialClass.cs rename to src/Chapter06/Listing06.57.DefiningAPartialClass.cs index 0a051f81c..073de36fd 100644 --- a/src/Chapter06/Listing06.56.DefiningAPartialClass.cs +++ b/src/Chapter06/Listing06.57.DefiningAPartialClass.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_56; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_57; #region INCLUDE // File: Program1.cs diff --git a/src/Chapter06/Listing06.57.DefiningANestedClassInASeperatePartialClass.cs b/src/Chapter06/Listing06.58.DefiningANestedClassInASeperatePartialClass.cs similarity index 99% rename from src/Chapter06/Listing06.57.DefiningANestedClassInASeperatePartialClass.cs rename to src/Chapter06/Listing06.58.DefiningANestedClassInASeperatePartialClass.cs index ad8c80c16..aada32911 100644 --- a/src/Chapter06/Listing06.57.DefiningANestedClassInASeperatePartialClass.cs +++ b/src/Chapter06/Listing06.58.DefiningANestedClassInASeperatePartialClass.cs @@ -1,7 +1,7 @@ // Ignored as implementation was removed for elucidation #pragma warning disable IDE0060 //Remove unused parameter -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_57; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_58; using System; diff --git a/src/Chapter06/Listing06.58.DefiningAPartialMethodToAccessItsImplementation.cs b/src/Chapter06/Listing06.59.DefiningAPartialMethodToAccessItsImplementation.cs similarity index 99% rename from src/Chapter06/Listing06.58.DefiningAPartialMethodToAccessItsImplementation.cs rename to src/Chapter06/Listing06.59.DefiningAPartialMethodToAccessItsImplementation.cs index c26e553eb..e71e95aa7 100644 --- a/src/Chapter06/Listing06.58.DefiningAPartialMethodToAccessItsImplementation.cs +++ b/src/Chapter06/Listing06.59.DefiningAPartialMethodToAccessItsImplementation.cs @@ -1,7 +1,7 @@ // Non-nullable field is uninitialized. Consider declaring as nullable. #pragma warning disable CS8618 // Pending a constructors -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_58; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_59; using System; diff --git a/src/Chapter07.Tests/Chapter07.Tests.csproj b/src/Chapter07.Tests/Chapter07.Tests.csproj index d8e1fec6e..bc639b7b4 100644 --- a/src/Chapter07.Tests/Chapter07.Tests.csproj +++ b/src/Chapter07.Tests/Chapter07.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter08.Tests/Chapter08.Tests.csproj b/src/Chapter08.Tests/Chapter08.Tests.csproj index 397571ca8..e33e69cbe 100644 --- a/src/Chapter08.Tests/Chapter08.Tests.csproj +++ b/src/Chapter08.Tests/Chapter08.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter09.Tests/Chapter09.Tests.csproj b/src/Chapter09.Tests/Chapter09.Tests.csproj index 44bec0548..9d7d3b436 100644 --- a/src/Chapter09.Tests/Chapter09.Tests.csproj +++ b/src/Chapter09.Tests/Chapter09.Tests.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter09.Tests/Listing09.16.OverridingToString.Tests.cs b/src/Chapter09.Tests/Listing09.16.OverridingToString.Tests.cs index 5d697db0b..06d4fcc6e 100644 --- a/src/Chapter09.Tests/Listing09.16.OverridingToString.Tests.cs +++ b/src/Chapter09.Tests/Listing09.16.OverridingToString.Tests.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter09.Listing09_16.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter09.Listing09_16.Tests; using AddisonWesley.Michaelis.EssentialCSharp.Chapter09.Listing09_16; @@ -12,8 +12,8 @@ public void Override_ToString_MatchesExpectedValue() Angle angle1 = new(120, 20, 20, "AngleName"); Angle angle2 = new(320, 10, 10, null); - string expected1 = $"AngleName: 120� 20' 20\""; - string expected2 = $"320� 10' 10\""; + string expected1 = $"AngleName: 120° 20' 20\""; + string expected2 = $"320° 10' 10\""; string actual1 = angle1.ToString(); string actual2 = angle2.ToString(); diff --git a/src/Chapter09/Listing09.05.DeclaringRecordClass.cs b/src/Chapter09/Listing09.05.DeclaringRecordClass.cs index 7c298c54a..013c3faa0 100644 --- a/src/Chapter09/Listing09.05.DeclaringRecordClass.cs +++ b/src/Chapter09/Listing09.05.DeclaringRecordClass.cs @@ -2,7 +2,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter09.Listing09_05; #region INCLUDE -// Use the record struct construct to declare a value type +// Use the record class construct to declare a reference type public record class Coordinate( Angle Longitude, Angle Latitude) #endregion INCLUDE diff --git a/src/Chapter09/Listing09.16.OverridingToString.cs b/src/Chapter09/Listing09.16.OverridingToString.cs index ec26dc1dc..704c850aa 100644 --- a/src/Chapter09/Listing09.16.OverridingToString.cs +++ b/src/Chapter09/Listing09.16.OverridingToString.cs @@ -19,7 +19,7 @@ public override string ToString() { string prefix = string.IsNullOrWhiteSpace(Name) ? string.Empty : Name + ": "; - return $"{prefix}{Degrees}� {Minutes}' {Seconds}\""; + return $"{prefix}{Degrees}° {Minutes}' {Seconds}\""; } #endregion INCLUDE } diff --git a/src/Chapter10.Tests/Chapter10.Tests.csproj b/src/Chapter10.Tests/Chapter10.Tests.csproj index edb2f36e3..a400ed731 100644 --- a/src/Chapter10.Tests/Chapter10.Tests.csproj +++ b/src/Chapter10.Tests/Chapter10.Tests.csproj @@ -16,7 +16,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter11.Tests/Chapter11.Tests.csproj b/src/Chapter11.Tests/Chapter11.Tests.csproj index e2ea67431..67656fa73 100644 --- a/src/Chapter11.Tests/Chapter11.Tests.csproj +++ b/src/Chapter11.Tests/Chapter11.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter12.Tests/Chapter12.Tests.csproj b/src/Chapter12.Tests/Chapter12.Tests.csproj index c6becbc38..2555972e2 100644 --- a/src/Chapter12.Tests/Chapter12.Tests.csproj +++ b/src/Chapter12.Tests/Chapter12.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter12.Tests/Listing12.41.Tests.cs b/src/Chapter12.Tests/Listing12.41.Tests.cs new file mode 100644 index 000000000..85a1698bb --- /dev/null +++ b/src/Chapter12.Tests/Listing12.41.Tests.cs @@ -0,0 +1,15 @@ +using AddisonWesley.Michaelis.EssentialCSharp.Shared.Tests; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter12.Listing12_41.Tests; + +[TestClass] +public class Listing12 +{ + [TestMethod] + public async Task CannotConvertTypes() + { + await CompilerAssert.CompileTestTargetFileAsync( + new string[] { "CS0030" }); + } +} diff --git a/src/Chapter12/Listing12.41.PreventingCovarianceMaintainsHomogeneity.cs b/src/Chapter12/Listing12.41.PreventingCovarianceMaintainsHomogeneity.cs index 2d5678588..83f996371 100644 --- a/src/Chapter12/Listing12.41.PreventingCovarianceMaintainsHomogeneity.cs +++ b/src/Chapter12/Listing12.41.PreventingCovarianceMaintainsHomogeneity.cs @@ -1,6 +1,3 @@ -using AddisonWesley.Michaelis.EssentialCSharp.Chapter08.Listing08_05; -using AddisonWesley.Michaelis.EssentialCSharp.Chapter12.Listing12_11; - namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter12.Listing12_41; public class Program @@ -14,12 +11,57 @@ public static void Main() Pair contacts = new(contact1, contact2); #region HIGHLIGHT + #if COMPILEERROR // EXCLUDE // This gives an error: Cannot convert type ... // But suppose it did not - // IPair pdaPair = (IPair) contacts; + IPair pdaPair = (IPair) contacts; // This is perfectly legal, but not type-safe - // pair.First = new Address("123 Sesame Street"); + pdaPair.First = new Address("123 Sesame Street"); + #endif // COMPILEERROR // EXCLUDE #endregion HIGHLIGHT #endregion INCLUDE } } + +public class Address : PdaItem +{ + public Address(string address) : base(address) + { + } +} + +public struct Pair : IPair +{ + public Pair(T first, T second) + { + First = first; + Second = second; + } + + public T First { get; set; } + public T Second { get; set; } +} + +interface IPair +{ + T First { get; set; } + T Second { get; set; } +} + +public class Contact : PdaItem +{ + public Contact(string name) + : base(name) + { + } +} + +public abstract class PdaItem +{ + public PdaItem(string name) + { + Name = name; + } + + public virtual string Name { get; set; } +} diff --git a/src/Chapter13.Tests/Chapter13.Tests.csproj b/src/Chapter13.Tests/Chapter13.Tests.csproj index b9cc18fc3..ecc91fe3e 100644 --- a/src/Chapter13.Tests/Chapter13.Tests.csproj +++ b/src/Chapter13.Tests/Chapter13.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter13/Listing13.21.StaticAnonymousFunctions.cs b/src/Chapter13/Listing13.21.StaticAnonymousFunctions.cs index 122d08346..25b96bb71 100644 --- a/src/Chapter13/Listing13.21.StaticAnonymousFunctions.cs +++ b/src/Chapter13/Listing13.21.StaticAnonymousFunctions.cs @@ -31,7 +31,7 @@ public static void Main() // Error CS8820: A static anonymous function // cannot contain a reference to comparisonCount. comparisonCount++; - #endif // COMPILEERROR EXCLUDE + #endif // COMPILEERROR // EXCLUDE return first < second; } ); diff --git a/src/Chapter13/Table13.01.c.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.c.LambdaExpressionNotesAndExamples.cs index 80c551caf..e7d2c68b1 100644 --- a/src/Chapter13/Table13.01.c.LambdaExpressionNotesAndExamples.cs +++ b/src/Chapter13/Table13.01.c.LambdaExpressionNotesAndExamples.cs @@ -10,8 +10,8 @@ static public void ExpressionsCanHaveReturnTypes() { #if !NET6_0_OR_GREATER Action action = void () => { }; - var func = short?(long number) => number <= short.MaxValue ? (short)number : null; - } + var func = short?(long number) => + number <= short.MaxValue ? (short)number : null; #endif } } diff --git a/src/Chapter14.Tests/Chapter14.Tests.csproj b/src/Chapter14.Tests/Chapter14.Tests.csproj index 88b96b3a1..5d3edd14f 100644 --- a/src/Chapter14.Tests/Chapter14.Tests.csproj +++ b/src/Chapter14.Tests/Chapter14.Tests.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter15.Tests/Chapter15.Tests.csproj b/src/Chapter15.Tests/Chapter15.Tests.csproj index 1c4f83c48..39b5aebcc 100644 --- a/src/Chapter15.Tests/Chapter15.Tests.csproj +++ b/src/Chapter15.Tests/Chapter15.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter16.Tests/Chapter16.Tests.csproj b/src/Chapter16.Tests/Chapter16.Tests.csproj index 511445352..79ac946da 100644 --- a/src/Chapter16.Tests/Chapter16.Tests.csproj +++ b/src/Chapter16.Tests/Chapter16.Tests.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter17.Tests/Chapter17.Tests.csproj b/src/Chapter17.Tests/Chapter17.Tests.csproj index 8dbc33991..f8fc5c420 100644 --- a/src/Chapter17.Tests/Chapter17.Tests.csproj +++ b/src/Chapter17.Tests/Chapter17.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter18.Tests/Chapter18.Tests.csproj b/src/Chapter18.Tests/Chapter18.Tests.csproj index e245a876f..5ed078795 100644 --- a/src/Chapter18.Tests/Chapter18.Tests.csproj +++ b/src/Chapter18.Tests/Chapter18.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter19.Tests/Chapter19.Tests.csproj b/src/Chapter19.Tests/Chapter19.Tests.csproj index ba7247fea..8251f716f 100644 --- a/src/Chapter19.Tests/Chapter19.Tests.csproj +++ b/src/Chapter19.Tests/Chapter19.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter20.Tests/BaseProgramTests.cs b/src/Chapter20.Tests/BaseProgramTests.cs index 2df88254f..f309500db 100644 --- a/src/Chapter20.Tests/BaseProgramTests.cs +++ b/src/Chapter20.Tests/BaseProgramTests.cs @@ -27,6 +27,7 @@ public void TestInitialize() } [TestMethod] + [Ignore] [DataRow("IntelliTect", @"[1-9]\d*")] [DataRow("Text Snippet That Does Not Exist On The Page", @"0")] public void Main_FindText_VerifyOccurenceCount(string findText, string countPattern) @@ -106,7 +107,7 @@ protected static void AssertAggregateExceptionType(string messagePrefix, Aggrega ExceptionDispatchInfo.Capture( innerException!).Throw(); - return true; // Identifhy whether the exception should report that it is handled or not. + return true; // Identify whether the exception should report that it is handled or not. }); } @@ -168,7 +169,7 @@ public async Task Main_GivenBadUri_ThrowException(string uri, string defaultMess } if (exception is AggregateException aggregateException) { - // Innerexception expected to be WebException. + // InnerException expected to be WebException. exception = aggregateException.Flatten(); aggregateException.Handle(innerException => { diff --git a/src/Chapter20.Tests/Chapter20.Tests.csproj b/src/Chapter20.Tests/Chapter20.Tests.csproj index 3e6332041..d510404df 100644 --- a/src/Chapter20.Tests/Chapter20.Tests.csproj +++ b/src/Chapter20.Tests/Chapter20.Tests.csproj @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter21.Tests/Chapter21.Tests.csproj b/src/Chapter21.Tests/Chapter21.Tests.csproj index 80cf79b5b..f80f38c0b 100644 --- a/src/Chapter21.Tests/Chapter21.Tests.csproj +++ b/src/Chapter21.Tests/Chapter21.Tests.csproj @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter22.Tests/Chapter22.Tests.csproj b/src/Chapter22.Tests/Chapter22.Tests.csproj index 1bc267018..270a836c0 100644 --- a/src/Chapter22.Tests/Chapter22.Tests.csproj +++ b/src/Chapter22.Tests/Chapter22.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter23.Tests/Chapter23.Tests.csproj b/src/Chapter23.Tests/Chapter23.Tests.csproj index f2d0941ce..7885c684f 100644 --- a/src/Chapter23.Tests/Chapter23.Tests.csproj +++ b/src/Chapter23.Tests/Chapter23.Tests.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/src/Chapter23.Tests/Listing23.20.DesignatingABlockForUnsafeCode.Tests.cs b/src/Chapter23.Tests/Listing23.20.DesignatingABlockForUnsafeCode.Tests.cs index 6013145d7..af00bca96 100644 --- a/src/Chapter23.Tests/Listing23.20.DesignatingABlockForUnsafeCode.Tests.cs +++ b/src/Chapter23.Tests/Listing23.20.DesignatingABlockForUnsafeCode.Tests.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_20.Tests; - +#if NET8_0_OR_GREATER [TestClass] public class Listing21_20_Tests { @@ -21,3 +21,4 @@ public void GetProcessorIdReturnsCorrectValue() }); } } +#endif \ No newline at end of file diff --git a/src/Chapter23/Listing23.20.DesignatingABlockForUnsafeCode.cs b/src/Chapter23/Listing23.20.DesignatingABlockForUnsafeCode.cs index 3e4f466fe..183254e9f 100644 --- a/src/Chapter23/Listing23.20.DesignatingABlockForUnsafeCode.cs +++ b/src/Chapter23/Listing23.20.DesignatingABlockForUnsafeCode.cs @@ -1,5 +1,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_20; +#if NET8_0_OR_GREATER #region INCLUDE using System; using System.Runtime.InteropServices; @@ -7,8 +8,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter23.Listing23_20; public class Program { - public unsafe delegate void MethodInvoker(byte* buffer); - public unsafe static int Main() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) @@ -26,25 +25,23 @@ public unsafe static int Main() 0x89, 0x48, 0x08, // mov %ecx,0x8(%rax) 0x4c, 0x89, 0xc3, // mov %r8,%rbx 0xc3 // retq - }; - - byte[] buffer = new byte[12]; + }; + Buffer buffer = new(); using (VirtualMemoryPtr codeBytesPtr = new(codeBytes.Length)) { Marshal.Copy( codeBytes, 0, codeBytesPtr, codeBytes.Length); - - MethodInvoker method = Marshal.GetDelegateForFunctionPointer(codeBytesPtr); - fixed (byte* newBuffer = &buffer[0]) - { - method(newBuffer); - } + + delegate* method = (delegate*)(IntPtr)codeBytesPtr; + method(&buffer[0]); } Console.Write("Processor Id: "); - Console.WriteLine(ASCIIEncoding.ASCII.GetChars(buffer)); + char[] chars = new char[Buffer.Length]; + Encoding.ASCII.GetChars(buffer, chars); + Console.WriteLine(chars); } // unsafe } else @@ -54,6 +51,15 @@ public unsafe static int Main() return 0; } } + +[System.Runtime.CompilerServices.InlineArrayAttribute(Length)] +public struct Buffer +{ + public const int Length = 10; + + private byte _element0; +} + #endregion INCLUDE public class VirtualMemoryPtr : SafeHandle @@ -67,10 +73,9 @@ public VirtualMemoryPtr(int memorySize) : AllocatedPointer = VirtualMemoryManager.AllocExecutionBlock( memorySize, ProcessHandle); - Disposed = false; } - public readonly IntPtr AllocatedPointer; + readonly IntPtr AllocatedPointer; readonly IntPtr ProcessHandle; readonly IntPtr MemorySize; bool Disposed; @@ -264,3 +269,4 @@ public static IntPtr AllocExecutionBlock(int size) size, GetCurrentProcessHandle()); } } +#endif \ No newline at end of file diff --git a/src/ChapterTests.props b/src/ChapterTests.props index 89289b05f..d8d43615f 100644 --- a/src/ChapterTests.props +++ b/src/ChapterTests.props @@ -9,7 +9,7 @@ --> - +