From 6d888fff031ccb840f7f4aedf7b8002e16126121 Mon Sep 17 00:00:00 2001 From: Mark Michaelis Date: Wed, 20 Sep 2023 18:02:57 +0100 Subject: [PATCH 1/7] Temporarily disable select Chapter 20 tests (#550) IntelliTect.com is failing so tests are failing. Temporarily disabled the failing tests. --- src/Chapter20.Tests/BaseProgramTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Chapter20.Tests/BaseProgramTests.cs b/src/Chapter20.Tests/BaseProgramTests.cs index 2df88254..f309500d 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 => { From 65ff6554621c7bbfe04eca8f1e70724194b4a32d Mon Sep 17 00:00:00 2001 From: Mark Michaelis Date: Wed, 20 Sep 2023 22:26:30 +0100 Subject: [PATCH 2/7] Add code for Generic attributes and Caller* attributes - Chapter 18 (#548) --- .../Listing06.27.CallingAConstructor.cs | 2 +- .../Listing18.26.GenericAttributes.Tests.cs | 24 ++++++++ ...ing18.27.CallerArgumentExpression.Tests.cs | 61 +++++++++++++++++++ ...ynamicProgrammingUsingReflection.Tests.cs} | 6 +- ...ndingToXMLElementsWithoutDynamic.Tests.cs} | 6 +- ....RuntimeBindingToXMLWithDynamics.Tests.cs} | 6 +- src/Chapter18/Chapter18.csproj | 4 +- .../Listing18.26.GenericAttributes.cs | 44 +++++++++++++ .../Listing18.27.CallerArgumentExpression.cs | 59 ++++++++++++++++++ ...8.28.DynamicProgrammingUsingReflection.cs} | 3 +- ...timeBindingToXMLElementsWithoutDynamic.cs} | 2 +- ...g18.30.RuntimeBindingToXMLWithDynamics.cs} | 4 +- ...18.31.ImplementingACustomDynamicObject.cs} | 2 +- ...eMembersOnSystem.Dynamic.DynamicObject.cs} | 2 +- 14 files changed, 207 insertions(+), 18 deletions(-) create mode 100644 src/Chapter18.Tests/Listing18.26.GenericAttributes.Tests.cs create mode 100644 src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs rename src/Chapter18.Tests/{Listing18.26.Tests.cs => Listing18.28.DynamicProgrammingUsingReflection.Tests.cs} (83%) rename src/Chapter18.Tests/{Listing18.27.Tests.cs => Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs} (81%) rename src/Chapter18.Tests/{Listing18.28.Tests.cs => Listing18.30.RuntimeBindingToXMLWithDynamics.Tests.cs} (81%) create mode 100644 src/Chapter18/Listing18.26.GenericAttributes.cs create mode 100644 src/Chapter18/Listing18.27.CallerArgumentExpression.cs rename src/Chapter18/{Listing18.26.DynamicProgrammingUsingReflection.cs => Listing18.28.DynamicProgrammingUsingReflection.cs} (96%) rename src/Chapter18/{Listing18.27.RuntimeBindingToXMLElementsWithoutDynamic.cs => Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.cs} (98%) rename src/Chapter18/{Listing18.28.RuntimeBindingToXMLWithDynamics.cs => Listing18.30.RuntimeBindingToXMLWithDynamics.cs} (93%) rename src/Chapter18/{Listing18.29.ImplementingACustomDynamicObject.cs => Listing18.31.ImplementingACustomDynamicObject.cs} (99%) rename src/Chapter18/{Listing18.30.OverridableMembersOnSystem.Dynamic.DynamicObject.cs => Listing18.32.OverridableMembersOnSystem.Dynamic.DynamicObject.cs} (95%) diff --git a/src/Chapter06/Listing06.27.CallingAConstructor.cs b/src/Chapter06/Listing06.27.CallingAConstructor.cs index 6608fa1e..8fcf2def 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_28; +using Listing06_30; #region INCLUDE public class Program diff --git a/src/Chapter18.Tests/Listing18.26.GenericAttributes.Tests.cs b/src/Chapter18.Tests/Listing18.26.GenericAttributes.Tests.cs new file mode 100644 index 00000000..902709e4 --- /dev/null +++ b/src/Chapter18.Tests/Listing18.26.GenericAttributes.Tests.cs @@ -0,0 +1,24 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26.Tests; + +#if NET7_0_OR_GREATER +[TestClass] +public class GenericExceptionTests +{ + [TestMethod] + public void ExpectedExceptionIsThrown() + { + ExpectedException.AssertExceptionThrown( + SampleTests.ThrowDivideByZeroExceptionTest); + } + + [TestMethod] + [ExpectedException(typeof(InvalidOperationException))] + public void ExpectedExceptionIsNotThrown() + { + ExpectedException.AssertExceptionThrown( + () => { }); + } +} +#endif // NET7_0_OR_GREATER diff --git a/src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs b/src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs new file mode 100644 index 00000000..e919f6c9 --- /dev/null +++ b/src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs @@ -0,0 +1,61 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27.Tests; + +#if NET7_0_OR_GREATER +[TestClass] +public class GenericExceptionTests +{ + [TestMethod] + public void ExpectedExceptionIsThrown() + { + ExpectedException.AssertExceptionThrown( + SampleTests.ThrowArgumentNullExceptionTest); + } + + [TestMethod] + public void VerifyExpectedExceptionMessage() + { + try + { + ExpectedException.AssertExceptionThrown( + () => { }); + } + catch(InvalidOperationException exception) + { + Assert.IsTrue(exception.Message.Contains("'() => { }'")); + } + } + + [TestMethod] + public void Method() + { + try + { + SampleTests.Method(); + } + catch (InvalidOperationException exception) + { + Assert.IsTrue( + exception.Message.Contains("'() => { }'") && + exception.Message.Contains("'Method'") && + exception.Message.Contains("'./FileName.cs'")); + // The expected exception, System.DivideByZeroException, + // was not thrown by the expression, 'Method' in the method, './FileName.cs', and file 'C:\Git\EssentialCSharp\src\Chapter18\Listing18.25b.CallerArgumentExpression.cs'. + } + } + + private object PassingMethodNameAndFileName() + { + throw new NotImplementedException(); + } + + [TestMethod] + [ExpectedException(typeof(InvalidOperationException))] + public void ExpectedExceptionIsNotThrown() + { + ExpectedException.AssertExceptionThrown( + () => { }); + } +} +#endif // NET7_0_OR_GREATER diff --git a/src/Chapter18.Tests/Listing18.26.Tests.cs b/src/Chapter18.Tests/Listing18.28.DynamicProgrammingUsingReflection.Tests.cs similarity index 83% rename from src/Chapter18.Tests/Listing18.26.Tests.cs rename to src/Chapter18.Tests/Listing18.28.DynamicProgrammingUsingReflection.Tests.cs index c69f6f1e..9a866d02 100644 --- a/src/Chapter18.Tests/Listing18.26.Tests.cs +++ b/src/Chapter18.Tests/Listing18.28.DynamicProgrammingUsingReflection.Tests.cs @@ -1,6 +1,6 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28.Tests; [TestClass] public class ProgramTests @@ -14,4 +14,4 @@ public void MainTest() IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Program.Main); } -} \ No newline at end of file +} diff --git a/src/Chapter18.Tests/Listing18.27.Tests.cs b/src/Chapter18.Tests/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs similarity index 81% rename from src/Chapter18.Tests/Listing18.27.Tests.cs rename to src/Chapter18.Tests/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs index 43f414d4..8316cfc9 100644 --- a/src/Chapter18.Tests/Listing18.27.Tests.cs +++ b/src/Chapter18.Tests/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs @@ -1,6 +1,6 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_29.Tests; [TestClass] public class ProgramTests @@ -13,4 +13,4 @@ public void MainTest() IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Program.Main); } -} \ No newline at end of file +} diff --git a/src/Chapter18.Tests/Listing18.28.Tests.cs b/src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLWithDynamics.Tests.cs similarity index 81% rename from src/Chapter18.Tests/Listing18.28.Tests.cs rename to src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLWithDynamics.Tests.cs index 344a7b5e..90b2e178 100644 --- a/src/Chapter18.Tests/Listing18.28.Tests.cs +++ b/src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLWithDynamics.Tests.cs @@ -1,6 +1,6 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_30.Tests; [TestClass] public class ProgramTests @@ -13,4 +13,4 @@ public void MainTest() IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Program.Main); } -} \ No newline at end of file +} diff --git a/src/Chapter18/Chapter18.csproj b/src/Chapter18/Chapter18.csproj index 182e79bb..f0dfe4c1 100644 --- a/src/Chapter18/Chapter18.csproj +++ b/src/Chapter18/Chapter18.csproj @@ -15,7 +15,7 @@ - + Program.cs @@ -29,6 +29,6 @@ DoWorkEventArgs.cs - + diff --git a/src/Chapter18/Listing18.26.GenericAttributes.cs b/src/Chapter18/Listing18.26.GenericAttributes.cs new file mode 100644 index 00000000..fb5a72ef --- /dev/null +++ b/src/Chapter18/Listing18.26.GenericAttributes.cs @@ -0,0 +1,44 @@ +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26; + +#if NET7_0_OR_GREATER +#region INCLUDE +public class SampleTests +{ + #region HIGHLIGHT + [ExpectedException] + #endregion HIGHLIGHT + public static void ThrowDivideByZeroExceptionTest() + { + var result = 1/"".Length; + } +} + +[AttributeUsage(AttributeTargets.Method)] +#region HIGHLIGHT +public class ExpectedException : + Attribute where TException : Exception +#endregion HIGHLIGHT +{ + #region EXCLUDE + public static TException AssertExceptionThrown(Action testMethod) + { + try + { + testMethod(); + throw new InvalidOperationException( + $"The expected exception, { + typeof(TException).FullName }, was not thrown."); + } + catch (TException exception) + { + return exception; + } + } + + // Attribute detection + #endregion EXCLUDE + + // ... +} +#endregion INCLUDE +#endif // NET7_0_OR_GREATER diff --git a/src/Chapter18/Listing18.27.CallerArgumentExpression.cs b/src/Chapter18/Listing18.27.CallerArgumentExpression.cs new file mode 100644 index 00000000..b0e255be --- /dev/null +++ b/src/Chapter18/Listing18.27.CallerArgumentExpression.cs @@ -0,0 +1,59 @@ +using System.Runtime.CompilerServices; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27; + +#if NET7_0_OR_GREATER +#region INCLUDE +public class SampleTests +{ + #region HIGHLIGHT + [ExpectedException] + #endregion HIGHLIGHT + public static void ThrowArgumentNullExceptionTest() + { + var result = 1/"".Length; + } + +public static void Method() +{ + ExpectedException.AssertExceptionThrown( + () => throw new DivideByZeroException()); +} +} + +[AttributeUsage(AttributeTargets.Method)] +public class ExpectedException : + Attribute where TException : Exception +{ + #region HIGHLIGHT + public static TException AssertExceptionThrown( + Action testAction, + [CallerArgumentExpression(nameof(testAction))] + string testExpression = null!, + [CallerMemberName]string testActionMemberName = null!, + [CallerFilePath]string testActionFileName = null! + ) + #endregion HIGHLIGHT + { + try + { + testAction(); + throw new InvalidOperationException( + $"The expected exception, { + typeof(TException).FullName }, was not thrown" + + $" by the expression '{ + testExpression }' in the method '{ + testActionMemberName }' and file '{ + testActionFileName }'."); + } + catch (TException exception) + { + return exception; + } + } + + // Attribute detection + // ... +} +#endregion INCLUDE +#endif // NET7_0_OR_GREATER diff --git a/src/Chapter18/Listing18.26.DynamicProgrammingUsingReflection.cs b/src/Chapter18/Listing18.28.DynamicProgrammingUsingReflection.cs similarity index 96% rename from src/Chapter18/Listing18.26.DynamicProgrammingUsingReflection.cs rename to src/Chapter18/Listing18.28.DynamicProgrammingUsingReflection.cs index 1d52070c..1d54f707 100644 --- a/src/Chapter18/Listing18.26.DynamicProgrammingUsingReflection.cs +++ b/src/Chapter18/Listing18.28.DynamicProgrammingUsingReflection.cs @@ -1,10 +1,11 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28; public class Program { public static void Main() { #region INCLUDE + // ... dynamic data = "Hello! My name is Inigo Montoya"; Console.WriteLine(data); diff --git a/src/Chapter18/Listing18.27.RuntimeBindingToXMLElementsWithoutDynamic.cs b/src/Chapter18/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.cs similarity index 98% rename from src/Chapter18/Listing18.27.RuntimeBindingToXMLElementsWithoutDynamic.cs rename to src/Chapter18/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.cs index 7af50d29..2a87e91e 100644 --- a/src/Chapter18/Listing18.27.RuntimeBindingToXMLElementsWithoutDynamic.cs +++ b/src/Chapter18/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_29; #region INCLUDE using System.Xml.Linq; diff --git a/src/Chapter18/Listing18.28.RuntimeBindingToXMLWithDynamics.cs b/src/Chapter18/Listing18.30.RuntimeBindingToXMLWithDynamics.cs similarity index 93% rename from src/Chapter18/Listing18.28.RuntimeBindingToXMLWithDynamics.cs rename to src/Chapter18/Listing18.30.RuntimeBindingToXMLWithDynamics.cs index 6ae9cd73..a5ad6808 100644 --- a/src/Chapter18/Listing18.28.RuntimeBindingToXMLWithDynamics.cs +++ b/src/Chapter18/Listing18.30.RuntimeBindingToXMLWithDynamics.cs @@ -1,6 +1,6 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_30; -using Listing18_29; +using Listing18_31; public class Program { public static void Main() diff --git a/src/Chapter18/Listing18.29.ImplementingACustomDynamicObject.cs b/src/Chapter18/Listing18.31.ImplementingACustomDynamicObject.cs similarity index 99% rename from src/Chapter18/Listing18.29.ImplementingACustomDynamicObject.cs rename to src/Chapter18/Listing18.31.ImplementingACustomDynamicObject.cs index 61d6ba8e..c02a24c5 100644 --- a/src/Chapter18/Listing18.29.ImplementingACustomDynamicObject.cs +++ b/src/Chapter18/Listing18.31.ImplementingACustomDynamicObject.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_29; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_31; #region INCLUDE using System.Dynamic; diff --git a/src/Chapter18/Listing18.30.OverridableMembersOnSystem.Dynamic.DynamicObject.cs b/src/Chapter18/Listing18.32.OverridableMembersOnSystem.Dynamic.DynamicObject.cs similarity index 95% rename from src/Chapter18/Listing18.30.OverridableMembersOnSystem.Dynamic.DynamicObject.cs rename to src/Chapter18/Listing18.32.OverridableMembersOnSystem.Dynamic.DynamicObject.cs index bdf90872..46b23bb9 100644 --- a/src/Chapter18/Listing18.30.OverridableMembersOnSystem.Dynamic.DynamicObject.cs +++ b/src/Chapter18/Listing18.32.OverridableMembersOnSystem.Dynamic.DynamicObject.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_30 +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_32 { #region INCLUDE using System.Collections.Generic; From 74939e63860c0839c1760eb94cd692d8b4b078c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anr=C3=A9=20=22Ray=22=20Tanner?= <40047765+A-Tanner@users.noreply.github.com> Date: Wed, 20 Sep 2023 20:36:35 -0700 Subject: [PATCH 3/7] Mmichaelis/updating tables (#547) Adds code listings and tests for Table 13.01 Note : test c does not generate any errors as of version 10.0, and the content should be edited to reflect this Fixes [#1529](https://github.com/IntelliTect-dev/EssentialCSharp.Tooling/issues/1529) --------- Co-authored-by: Mark Michaelis --- src/Chapter13.Tests/Table13.01.Tests.cs | 25 ++++++++++++++++ ...3.01.a.LambdaExpressionNotesAndExamples.cs | 16 ++++++++++ ...3.01.b.LambdaExpressionNotesAndExamples.cs | 18 +++++++++++ ...3.01.c.LambdaExpressionNotesAndExamples.cs | 17 +++++++++++ ...3.01.d.LambdaExpressionNotesAndExamples.cs | 19 ++++++++++++ ...3.01.e.LambdaExpressionNotesAndExamples.cs | 20 +++++++++++++ ...3.01.f.LambdaExpressionNotesAndExamples.cs | 19 ++++++++++++ ...3.01.g.LambdaExpressionNotesAndExamples.cs | 30 +++++++++++++++++++ ...3.01.h.LambdaExpressionNotesAndExamples.cs | 21 +++++++++++++ ...3.01.i.LambdaExpressionNotesAndExamples.cs | 24 +++++++++++++++ ...3.01.j.LambdaExpressionNotesAndExamples.cs | 25 ++++++++++++++++ 11 files changed, 234 insertions(+) create mode 100644 src/Chapter13.Tests/Table13.01.Tests.cs create mode 100644 src/Chapter13/Table13.01.a.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.b.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.c.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.d.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.e.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.f.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.g.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.h.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.i.LambdaExpressionNotesAndExamples.cs create mode 100644 src/Chapter13/Table13.01.j.LambdaExpressionNotesAndExamples.cs diff --git a/src/Chapter13.Tests/Table13.01.Tests.cs b/src/Chapter13.Tests/Table13.01.Tests.cs new file mode 100644 index 00000000..966f4571 --- /dev/null +++ b/src/Chapter13.Tests/Table13.01.Tests.cs @@ -0,0 +1,25 @@ +using AddisonWesley.Michaelis.EssentialCSharp.Shared.Tests; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01.Tests; + +[TestClass] +public class LambdaHighlightTests +{ + + [TestMethod] + /* 1. */ [DataRow(".a")] + /* 2. */ [DataRow(".b")] + /* 3. */ [DataRow(".c")] + /* 4. */ [DataRow(".d", "CS0023")] + /* 5. */ [DataRow(".e", "CS0837")] + /* 6. */ [DataRow(".f", "CS0029", "CS1662")] + /* 7. */ [DataRow(".g", "CS8070", "CS1632")] + /* 8. */ [DataRow(".h", "CS0103")] + /* 9. */ [DataRow(".i", "CS0165")] + /* 10. */ [DataRow(".j", "CS0165")] + public async Task ParseAndCompile(string fileNameSuffix, params string[] errorIds) + { + await CompilerAssert.CompileAsync($"Table13.01{fileNameSuffix}.LambdaExpressionNotesAndExamples.cs", errorIds); + } +} \ No newline at end of file diff --git a/src/Chapter13/Table13.01.a.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.a.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..8c883916 --- /dev/null +++ b/src/Chapter13/Table13.01.a.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,16 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 1. + public static void DiscardParameters() + { +#if !NET6_0_OR_GREATER + Action x = (_, _)=> + Console.WriteLine("This is a test."); +#endif + } +} diff --git a/src/Chapter13/Table13.01.b.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.b.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..b9aaa69f --- /dev/null +++ b/src/Chapter13/Table13.01.b.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,18 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 2. + static public void TypeInferenceOfExpression() + { +#if !NET6_0_OR_GREATER + //You can assign lambda + //expression to an implicitly + //typed local variable starting C#10 + var v = (int x) => x; +#endif + } +} diff --git a/src/Chapter13/Table13.01.c.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.c.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..e7d2c68b --- /dev/null +++ b/src/Chapter13/Table13.01.c.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,17 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 3. + static public void ExpressionsCanHaveReturnTypes() + { +#if !NET6_0_OR_GREATER + Action action = void () => { }; + var func = short?(long number) => + number <= short.MaxValue ? (short)number : null; +#endif + } +} diff --git a/src/Chapter13/Table13.01.d.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.d.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..fdd4d8b9 --- /dev/null +++ b/src/Chapter13/Table13.01.d.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,19 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 4. + public static void MemberMethodsOnExpressions() + { + //#if COMPILEERROR + #if !NET6_0_OR_GREATER + //ERROR: Operator "." cannot be applied to + //operand of type "lambda expression" + string s = ((int x) => x).ToString(); + #endif + //#endif // COMPILEERROR + } +} diff --git a/src/Chapter13/Table13.01.e.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.e.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..f6c11a05 --- /dev/null +++ b/src/Chapter13/Table13.01.e.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,20 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 5. + public static void PatternMatchingOnType() + { +//#if COMPILEERROR +#if !NET6_0_OR_GREATER + //ERROR: The first operand of an "is" or "as" + //operator may not be a lambda expression or + //anonymous method + bool b = ((int x) => x) is Func; +#endif +//#endif // COMPILEERROR + } +} diff --git a/src/Chapter13/Table13.01.f.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.f.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..77e5948d --- /dev/null +++ b/src/Chapter13/Table13.01.f.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,19 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 6. + public static void ConvertingToImproperDelegate() + { +//#if COMPILEERROR +#if !NET6_0_OR_GREATER + //ERROR: Lambda expression is not compatible + //with Func type + Func f = (int x) => x; +#endif +//#endif // COMPILEERROR + } +} diff --git a/src/Chapter13/Table13.01.g.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.g.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..6818489c --- /dev/null +++ b/src/Chapter13/Table13.01.g.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,30 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 7. + public static void JumpStatementsToOutOfScopeDestinations() + { + //#if COMPILEERROR +#if !NET6_0_OR_GREATER + //ERROR: Control cannot leave the body of an + //anonymous method or lambda expression + string[] args = { "/File", "fileThatMostCertainlyDoesNotExist" }; + Func f; + switch (args[0]) + { + case "/File": + f = () => + { + if (!File.Exists(args[1])) + break; + return args[1]; + }; + } +#endif + //#endif // COMPILEERROR + } +} diff --git a/src/Chapter13/Table13.01.h.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.h.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..ff6999e8 --- /dev/null +++ b/src/Chapter13/Table13.01.h.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,21 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 8. + public static void AccessingParametersAndLocalsOutOfBody() + { +//#if COMPILEERROR +#if !NET6_0_OR_GREATER + //ERROR: The name "first" does not + //exist in the current context + Func expression = + (first, second) => first > second; + first++; +#endif +//#endif // COMPILEERROR + } +} diff --git a/src/Chapter13/Table13.01.i.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.i.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..0e346651 --- /dev/null +++ b/src/Chapter13/Table13.01.i.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,24 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 9. + public static void UsingOutParameters() + { +//#if COMPILEERROR +#if !NET6_0_OR_GREATER + int number; + Func f = + text => int.TryParse(text, out number); + if (f("1")) + { + //ERROR: Use of unassigned local variable + System.Console.Write(number); + } +#endif +//#endif // COMPILEERROR + } +} diff --git a/src/Chapter13/Table13.01.j.LambdaExpressionNotesAndExamples.cs b/src/Chapter13/Table13.01.j.LambdaExpressionNotesAndExamples.cs new file mode 100644 index 00000000..245576ca --- /dev/null +++ b/src/Chapter13/Table13.01.j.LambdaExpressionNotesAndExamples.cs @@ -0,0 +1,25 @@ +// Justification: Only snippets of source code shown for elucidation. +#pragma warning disable CS0168 // Variable is declared but never used + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Table13_01; + +public partial class LambdaExpressionNotesAndExamples +{ + // 10. + public static void CompilerWillNotDetectInLambdaAssignment() + { + //#if COMPILEERROR +#if !NET6_0_OR_GREATER + + int number; + Func isFortyTwo = + x => 42 == (number = x); + if (isFortyTwo(42)) + { + // ERROR: Use of unassigned local variable + System.Console.Write(number); + } +#endif + //#endif // COMPILEERROR + } +} From 5c58f5203338655d10a3ac7eb92e6afaeb75e113 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Thu, 21 Sep 2023 09:53:15 +0100 Subject: [PATCH 4/7] fix: Re-enable tests (#555) --- src/Chapter20.Tests/BaseProgramTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Chapter20.Tests/BaseProgramTests.cs b/src/Chapter20.Tests/BaseProgramTests.cs index f309500d..a97d3566 100644 --- a/src/Chapter20.Tests/BaseProgramTests.cs +++ b/src/Chapter20.Tests/BaseProgramTests.cs @@ -1,4 +1,4 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Diagnostics.CodeAnalysis; using System.Net; using System.Runtime.ExceptionServices; @@ -27,7 +27,6 @@ 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) From 3c1817c82eaadbed97f59b8ea9a0b4025398ebfa Mon Sep 17 00:00:00 2001 From: Mark Michaelis Date: Thu, 21 Sep 2023 09:58:02 +0100 Subject: [PATCH 5/7] Resubmit Chapter 18 after Renumber (#553) --- ...pecificAttributeAndCheckingItsInitialization.Tests.cs} | 6 +++--- ...25.UsingConditionalAttributeToEliminateACall.Tests.cs} | 6 +++--- ...es.Tests.cs => Listing18.27.GenericException.Tests.cs} | 2 +- ....cs => Listing18.28.CallerArgumentExpression.Tests.cs} | 2 +- ...sting18.29.DynamicProgrammingUsingReflection.Tests.cs} | 2 +- ...30.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs} | 2 +- ...Listing18.31.RuntimeBindingToXMLWithDynamics.Tests.cs} | 2 +- src/Chapter18/Chapter18.csproj | 8 ++++---- ....csprojMockFileForResequencingListings.Placeholder.cs} | 2 +- ...ribute.cs => Listing18.14.DefiningACustomAttribute.cs} | 2 +- ...bute.cs => Listing18.15.RetrievingACustomAttribute.cs} | 2 +- ...cs => Listing18.16.ProvidingAnAttributeConstructor.cs} | 2 +- ...vingASpecificAttributeAndCheckingItsInitialization.cs} | 4 ++-- ...=> Listing18.18.RetrievingCustomAttributeInstances.cs} | 2 +- ...UpdatingCommandLineHandler.TryParseToHandleAliases.cs} | 4 ++-- ....20.RestrictingTheConstructsAnAttributeCanDecorate.cs} | 2 +- ...teUsageAttributeRestrictingWhereToApplyAnAttribute.cs} | 2 +- ...mitingAnAttributesUsageWithAttributeUsageAttribute.cs} | 2 +- ...dParameter.cs => Listing18.23.UsingANamedParameter.cs} | 2 +- ...gsAttribute.cs => Listing18.24.UsingFlagsAttribute.cs} | 2 +- ...ing18.25.UsingConditionalAttributeToEliminateACall.cs} | 2 +- ...ttribute.cs => Listing18.26.UsingObsoleteAttribute.cs} | 2 +- ...ericAttributes.cs => Listing18.27.GenericException.cs} | 7 ++----- ...ession.cs => Listing18.28.CallerArgumentExpression.cs} | 2 +- ... => Listing18.29.DynamicProgrammingUsingReflection.cs} | 2 +- ...ing18.30.RuntimeBindingToXMLElementsWithoutDynamic.cs} | 2 +- ...cs => Listing18.31.RuntimeBindingToXMLWithDynamics.cs} | 4 ++-- ...s => Listing18.32.ImplementingACustomDynamicObject.cs} | 2 +- ...3.OverridableMembersOnSystem.Dynamic.DynamicObject.cs} | 2 +- 29 files changed, 40 insertions(+), 43 deletions(-) rename src/Chapter18.Tests/{Listing18.16.Tests.cs => Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs} (80%) rename src/Chapter18.Tests/{Listing18.24.Tests.cs => Listing18.25.UsingConditionalAttributeToEliminateACall.Tests.cs} (82%) rename src/Chapter18.Tests/{Listing18.26.GenericAttributes.Tests.cs => Listing18.27.GenericException.Tests.cs} (97%) rename src/Chapter18.Tests/{Listing18.27.CallerArgumentExpression.Tests.cs => Listing18.28.CallerArgumentExpression.Tests.cs} (99%) rename src/Chapter18.Tests/{Listing18.28.DynamicProgrammingUsingReflection.Tests.cs => Listing18.29.DynamicProgrammingUsingReflection.Tests.cs} (96%) rename src/Chapter18.Tests/{Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs => Listing18.30.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs} (95%) rename src/Chapter18.Tests/{Listing18.30.RuntimeBindingToXMLWithDynamics.Tests.cs => Listing18.31.RuntimeBindingToXMLWithDynamics.Tests.cs} (95%) rename src/Chapter18/{Listing18.12.csprojMockFileForResequencingListings.Placeholder.cs => Listing18.13.csprojMockFileForResequencingListings.Placeholder.cs} (96%) rename src/Chapter18/{Listing18.13.DefiningACustomAttribute.cs => Listing18.14.DefiningACustomAttribute.cs} (94%) rename src/Chapter18/{Listing18.14.RetrievingACustomAttribute.cs => Listing18.15.RetrievingACustomAttribute.cs} (98%) rename src/Chapter18/{Listing18.15.ProvidingAnAttributeConstructor.cs => Listing18.16.ProvidingAnAttributeConstructor.cs} (98%) rename src/Chapter18/{Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.cs => Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.cs} (97%) rename src/Chapter18/{Listing18.17.RetrievingCustomAttributeInstances.cs => Listing18.18.RetrievingCustomAttributeInstances.cs} (99%) rename src/Chapter18/{Listing18.18.UpdatingCommandLineHandler.TryParseToHandleAliases.cs => Listing18.19.UpdatingCommandLineHandler.TryParseToHandleAliases.cs} (99%) rename src/Chapter18/{Listing18.19.RestrictingTheConstructsAnAttributeCanDecorate.cs => Listing18.20.RestrictingTheConstructsAnAttributeCanDecorate.cs} (95%) rename src/Chapter18/{Listing18.20.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs => Listing18.21.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs} (96%) rename src/Chapter18/{Listing18.21.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs => Listing18.22.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs} (97%) rename src/Chapter18/{Listing18.22.UsingANamedParameter.cs => Listing18.23.UsingANamedParameter.cs} (95%) rename src/Chapter18/{Listing18.23.UsingFlagsAttribute.cs => Listing18.24.UsingFlagsAttribute.cs} (98%) rename src/Chapter18/{Listing18.24.UsingConditionalAttributeToEliminateACall.cs => Listing18.25.UsingConditionalAttributeToEliminateACall.cs} (98%) rename src/Chapter18/{Listing18.25.UsingObsoleteAttribute.cs => Listing18.26.UsingObsoleteAttribute.cs} (96%) rename src/Chapter18/{Listing18.26.GenericAttributes.cs => Listing18.27.GenericException.cs} (94%) rename src/Chapter18/{Listing18.27.CallerArgumentExpression.cs => Listing18.28.CallerArgumentExpression.cs} (99%) rename src/Chapter18/{Listing18.28.DynamicProgrammingUsingReflection.cs => Listing18.29.DynamicProgrammingUsingReflection.cs} (98%) rename src/Chapter18/{Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.cs => Listing18.30.RuntimeBindingToXMLElementsWithoutDynamic.cs} (98%) rename src/Chapter18/{Listing18.30.RuntimeBindingToXMLWithDynamics.cs => Listing18.31.RuntimeBindingToXMLWithDynamics.cs} (93%) rename src/Chapter18/{Listing18.31.ImplementingACustomDynamicObject.cs => Listing18.32.ImplementingACustomDynamicObject.cs} (99%) rename src/Chapter18/{Listing18.32.OverridableMembersOnSystem.Dynamic.DynamicObject.cs => Listing18.33.OverridableMembersOnSystem.Dynamic.DynamicObject.cs} (99%) diff --git a/src/Chapter18.Tests/Listing18.16.Tests.cs b/src/Chapter18.Tests/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs similarity index 80% rename from src/Chapter18.Tests/Listing18.16.Tests.cs rename to src/Chapter18.Tests/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs index e7ef66eb..385d1494 100644 --- a/src/Chapter18.Tests/Listing18.16.Tests.cs +++ b/src/Chapter18.Tests/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs @@ -1,6 +1,6 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_16.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_17.Tests; [TestClass] public class ProgramTests @@ -13,4 +13,4 @@ public void MainTest() IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Program.Main); } -} \ No newline at end of file +} diff --git a/src/Chapter18.Tests/Listing18.24.Tests.cs b/src/Chapter18.Tests/Listing18.25.UsingConditionalAttributeToEliminateACall.Tests.cs similarity index 82% rename from src/Chapter18.Tests/Listing18.24.Tests.cs rename to src/Chapter18.Tests/Listing18.25.UsingConditionalAttributeToEliminateACall.Tests.cs index c0f24b7e..1fe007a7 100644 --- a/src/Chapter18.Tests/Listing18.24.Tests.cs +++ b/src/Chapter18.Tests/Listing18.25.UsingConditionalAttributeToEliminateACall.Tests.cs @@ -1,6 +1,6 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_24.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_25.Tests; [TestClass] public class ProgramTests @@ -15,4 +15,4 @@ public void MainTest() IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Program.Main); } -} \ No newline at end of file +} diff --git a/src/Chapter18.Tests/Listing18.26.GenericAttributes.Tests.cs b/src/Chapter18.Tests/Listing18.27.GenericException.Tests.cs similarity index 97% rename from src/Chapter18.Tests/Listing18.26.GenericAttributes.Tests.cs rename to src/Chapter18.Tests/Listing18.27.GenericException.Tests.cs index 902709e4..b4f07bb6 100644 --- a/src/Chapter18.Tests/Listing18.26.GenericAttributes.Tests.cs +++ b/src/Chapter18.Tests/Listing18.27.GenericException.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27.Tests; #if NET7_0_OR_GREATER [TestClass] diff --git a/src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs b/src/Chapter18.Tests/Listing18.28.CallerArgumentExpression.Tests.cs similarity index 99% rename from src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs rename to src/Chapter18.Tests/Listing18.28.CallerArgumentExpression.Tests.cs index e919f6c9..9eb8b2c5 100644 --- a/src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs +++ b/src/Chapter18.Tests/Listing18.28.CallerArgumentExpression.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28.Tests; #if NET7_0_OR_GREATER [TestClass] diff --git a/src/Chapter18.Tests/Listing18.28.DynamicProgrammingUsingReflection.Tests.cs b/src/Chapter18.Tests/Listing18.29.DynamicProgrammingUsingReflection.Tests.cs similarity index 96% rename from src/Chapter18.Tests/Listing18.28.DynamicProgrammingUsingReflection.Tests.cs rename to src/Chapter18.Tests/Listing18.29.DynamicProgrammingUsingReflection.Tests.cs index 9a866d02..71124abd 100644 --- a/src/Chapter18.Tests/Listing18.28.DynamicProgrammingUsingReflection.Tests.cs +++ b/src/Chapter18.Tests/Listing18.29.DynamicProgrammingUsingReflection.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_29.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter18.Tests/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs b/src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs similarity index 95% rename from src/Chapter18.Tests/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs rename to src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs index 8316cfc9..cd8167d9 100644 --- a/src/Chapter18.Tests/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs +++ b/src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLElementsWithoutDynamic.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_29.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_30.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLWithDynamics.Tests.cs b/src/Chapter18.Tests/Listing18.31.RuntimeBindingToXMLWithDynamics.Tests.cs similarity index 95% rename from src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLWithDynamics.Tests.cs rename to src/Chapter18.Tests/Listing18.31.RuntimeBindingToXMLWithDynamics.Tests.cs index 90b2e178..717b594a 100644 --- a/src/Chapter18.Tests/Listing18.30.RuntimeBindingToXMLWithDynamics.Tests.cs +++ b/src/Chapter18.Tests/Listing18.31.RuntimeBindingToXMLWithDynamics.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_30.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_31.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter18/Chapter18.csproj b/src/Chapter18/Chapter18.csproj index f0dfe4c1..4c92fe39 100644 --- a/src/Chapter18/Chapter18.csproj +++ b/src/Chapter18/Chapter18.csproj @@ -1,4 +1,4 @@ - + 18 @@ -14,8 +14,8 @@ - - + + Program.cs @@ -29,6 +29,6 @@ DoWorkEventArgs.cs - + diff --git a/src/Chapter18/Listing18.12.csprojMockFileForResequencingListings.Placeholder.cs b/src/Chapter18/Listing18.13.csprojMockFileForResequencingListings.Placeholder.cs similarity index 96% rename from src/Chapter18/Listing18.12.csprojMockFileForResequencingListings.Placeholder.cs rename to src/Chapter18/Listing18.13.csprojMockFileForResequencingListings.Placeholder.cs index 6a5d1153..f556aeb2 100644 --- a/src/Chapter18/Listing18.12.csprojMockFileForResequencingListings.Placeholder.cs +++ b/src/Chapter18/Listing18.13.csprojMockFileForResequencingListings.Placeholder.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_12; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_13; //Allows for the csproj file listing example to be accounted for when resequencing listings. just rename this diff --git a/src/Chapter18/Listing18.13.DefiningACustomAttribute.cs b/src/Chapter18/Listing18.14.DefiningACustomAttribute.cs similarity index 94% rename from src/Chapter18/Listing18.13.DefiningACustomAttribute.cs rename to src/Chapter18/Listing18.14.DefiningACustomAttribute.cs index 1c8874a4..b2054f8f 100644 --- a/src/Chapter18/Listing18.13.DefiningACustomAttribute.cs +++ b/src/Chapter18/Listing18.14.DefiningACustomAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_13; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_14; #region INCLUDE public class CommandLineSwitchRequiredAttribute : Attribute diff --git a/src/Chapter18/Listing18.14.RetrievingACustomAttribute.cs b/src/Chapter18/Listing18.15.RetrievingACustomAttribute.cs similarity index 98% rename from src/Chapter18/Listing18.14.RetrievingACustomAttribute.cs rename to src/Chapter18/Listing18.15.RetrievingACustomAttribute.cs index de95efd0..cb75dec9 100644 --- a/src/Chapter18/Listing18.14.RetrievingACustomAttribute.cs +++ b/src/Chapter18/Listing18.15.RetrievingACustomAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_14; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_15; #region INCLUDE using System.Reflection; diff --git a/src/Chapter18/Listing18.15.ProvidingAnAttributeConstructor.cs b/src/Chapter18/Listing18.16.ProvidingAnAttributeConstructor.cs similarity index 98% rename from src/Chapter18/Listing18.15.ProvidingAnAttributeConstructor.cs rename to src/Chapter18/Listing18.16.ProvidingAnAttributeConstructor.cs index 4e47f254..6999f221 100644 --- a/src/Chapter18/Listing18.15.ProvidingAnAttributeConstructor.cs +++ b/src/Chapter18/Listing18.16.ProvidingAnAttributeConstructor.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_15; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_16; #region INCLUDE public class CommandLineSwitchAliasAttribute : Attribute diff --git a/src/Chapter18/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.cs b/src/Chapter18/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.cs similarity index 97% rename from src/Chapter18/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.cs rename to src/Chapter18/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.cs index 7f2cfcd5..350d0d66 100644 --- a/src/Chapter18/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.cs +++ b/src/Chapter18/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.cs @@ -1,6 +1,6 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_16; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_17; -using AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_15; +using AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_16; using System.Reflection; public class Program diff --git a/src/Chapter18/Listing18.17.RetrievingCustomAttributeInstances.cs b/src/Chapter18/Listing18.18.RetrievingCustomAttributeInstances.cs similarity index 99% rename from src/Chapter18/Listing18.17.RetrievingCustomAttributeInstances.cs rename to src/Chapter18/Listing18.18.RetrievingCustomAttributeInstances.cs index 1d6d8056..517748ba 100644 --- a/src/Chapter18/Listing18.17.RetrievingCustomAttributeInstances.cs +++ b/src/Chapter18/Listing18.18.RetrievingCustomAttributeInstances.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_17; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_18; #region INCLUDE using System.Reflection; diff --git a/src/Chapter18/Listing18.18.UpdatingCommandLineHandler.TryParseToHandleAliases.cs b/src/Chapter18/Listing18.19.UpdatingCommandLineHandler.TryParseToHandleAliases.cs similarity index 99% rename from src/Chapter18/Listing18.18.UpdatingCommandLineHandler.TryParseToHandleAliases.cs rename to src/Chapter18/Listing18.19.UpdatingCommandLineHandler.TryParseToHandleAliases.cs index 9f345bcd..1a3f1c47 100644 --- a/src/Chapter18/Listing18.18.UpdatingCommandLineHandler.TryParseToHandleAliases.cs +++ b/src/Chapter18/Listing18.19.UpdatingCommandLineHandler.TryParseToHandleAliases.cs @@ -1,6 +1,6 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_18; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_19; -using Listing18_17; +using Listing18_18; #region INCLUDE using System.Reflection; using System.Collections.Generic; diff --git a/src/Chapter18/Listing18.19.RestrictingTheConstructsAnAttributeCanDecorate.cs b/src/Chapter18/Listing18.20.RestrictingTheConstructsAnAttributeCanDecorate.cs similarity index 95% rename from src/Chapter18/Listing18.19.RestrictingTheConstructsAnAttributeCanDecorate.cs rename to src/Chapter18/Listing18.20.RestrictingTheConstructsAnAttributeCanDecorate.cs index d43846bf..a5d6d6c3 100644 --- a/src/Chapter18/Listing18.19.RestrictingTheConstructsAnAttributeCanDecorate.cs +++ b/src/Chapter18/Listing18.20.RestrictingTheConstructsAnAttributeCanDecorate.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_19; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_20; #region INCLUDE [AttributeUsage(AttributeTargets.Property)] diff --git a/src/Chapter18/Listing18.20.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs b/src/Chapter18/Listing18.21.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs similarity index 96% rename from src/Chapter18/Listing18.20.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs rename to src/Chapter18/Listing18.21.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs index 606196aa..dd697828 100644 --- a/src/Chapter18/Listing18.20.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs +++ b/src/Chapter18/Listing18.21.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_20; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_21; // Will not compile if uncommented /* diff --git a/src/Chapter18/Listing18.21.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs b/src/Chapter18/Listing18.22.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs similarity index 97% rename from src/Chapter18/Listing18.21.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs rename to src/Chapter18/Listing18.22.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs index e050de1f..3676b082 100644 --- a/src/Chapter18/Listing18.21.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs +++ b/src/Chapter18/Listing18.22.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_21; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_22; #region INCLUDE // Restrict the attribute to properties and methods diff --git a/src/Chapter18/Listing18.22.UsingANamedParameter.cs b/src/Chapter18/Listing18.23.UsingANamedParameter.cs similarity index 95% rename from src/Chapter18/Listing18.22.UsingANamedParameter.cs rename to src/Chapter18/Listing18.23.UsingANamedParameter.cs index 4e6997b3..c035f7ee 100644 --- a/src/Chapter18/Listing18.22.UsingANamedParameter.cs +++ b/src/Chapter18/Listing18.23.UsingANamedParameter.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_22; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_23; #region INCLUDE [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)] diff --git a/src/Chapter18/Listing18.23.UsingFlagsAttribute.cs b/src/Chapter18/Listing18.24.UsingFlagsAttribute.cs similarity index 98% rename from src/Chapter18/Listing18.23.UsingFlagsAttribute.cs rename to src/Chapter18/Listing18.24.UsingFlagsAttribute.cs index 15afe8c2..137200e8 100644 --- a/src/Chapter18/Listing18.23.UsingFlagsAttribute.cs +++ b/src/Chapter18/Listing18.24.UsingFlagsAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_23; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_24; #region INCLUDE /* diff --git a/src/Chapter18/Listing18.24.UsingConditionalAttributeToEliminateACall.cs b/src/Chapter18/Listing18.25.UsingConditionalAttributeToEliminateACall.cs similarity index 98% rename from src/Chapter18/Listing18.24.UsingConditionalAttributeToEliminateACall.cs rename to src/Chapter18/Listing18.25.UsingConditionalAttributeToEliminateACall.cs index 0cf0353d..daba8cc6 100644 --- a/src/Chapter18/Listing18.24.UsingConditionalAttributeToEliminateACall.cs +++ b/src/Chapter18/Listing18.25.UsingConditionalAttributeToEliminateACall.cs @@ -1,7 +1,7 @@ #region INCLUDE #define CONDITION_A #region EXCLUDE -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_24; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_25; #endregion EXCLUDE using System.Diagnostics; diff --git a/src/Chapter18/Listing18.25.UsingObsoleteAttribute.cs b/src/Chapter18/Listing18.26.UsingObsoleteAttribute.cs similarity index 96% rename from src/Chapter18/Listing18.25.UsingObsoleteAttribute.cs rename to src/Chapter18/Listing18.26.UsingObsoleteAttribute.cs index 8eecc596..2f8ca541 100644 --- a/src/Chapter18/Listing18.25.UsingObsoleteAttribute.cs +++ b/src/Chapter18/Listing18.26.UsingObsoleteAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_25; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26; #region INCLUDE public class Program diff --git a/src/Chapter18/Listing18.26.GenericAttributes.cs b/src/Chapter18/Listing18.27.GenericException.cs similarity index 94% rename from src/Chapter18/Listing18.26.GenericAttributes.cs rename to src/Chapter18/Listing18.27.GenericException.cs index fb5a72ef..0eafbe33 100644 --- a/src/Chapter18/Listing18.26.GenericAttributes.cs +++ b/src/Chapter18/Listing18.27.GenericException.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27; #if NET7_0_OR_GREATER #region INCLUDE @@ -19,7 +19,6 @@ public class ExpectedException : Attribute where TException : Exception #endregion HIGHLIGHT { - #region EXCLUDE public static TException AssertExceptionThrown(Action testMethod) { try @@ -34,10 +33,8 @@ public static TException AssertExceptionThrown(Action testMethod) return exception; } } - - // Attribute detection - #endregion EXCLUDE + // Attribute detection // ... } #endregion INCLUDE diff --git a/src/Chapter18/Listing18.27.CallerArgumentExpression.cs b/src/Chapter18/Listing18.28.CallerArgumentExpression.cs similarity index 99% rename from src/Chapter18/Listing18.27.CallerArgumentExpression.cs rename to src/Chapter18/Listing18.28.CallerArgumentExpression.cs index b0e255be..8391d837 100644 --- a/src/Chapter18/Listing18.27.CallerArgumentExpression.cs +++ b/src/Chapter18/Listing18.28.CallerArgumentExpression.cs @@ -1,6 +1,6 @@ using System.Runtime.CompilerServices; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28; #if NET7_0_OR_GREATER #region INCLUDE diff --git a/src/Chapter18/Listing18.28.DynamicProgrammingUsingReflection.cs b/src/Chapter18/Listing18.29.DynamicProgrammingUsingReflection.cs similarity index 98% rename from src/Chapter18/Listing18.28.DynamicProgrammingUsingReflection.cs rename to src/Chapter18/Listing18.29.DynamicProgrammingUsingReflection.cs index 1d54f707..3fe54e47 100644 --- a/src/Chapter18/Listing18.28.DynamicProgrammingUsingReflection.cs +++ b/src/Chapter18/Listing18.29.DynamicProgrammingUsingReflection.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_29; public class Program { diff --git a/src/Chapter18/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.cs b/src/Chapter18/Listing18.30.RuntimeBindingToXMLElementsWithoutDynamic.cs similarity index 98% rename from src/Chapter18/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.cs rename to src/Chapter18/Listing18.30.RuntimeBindingToXMLElementsWithoutDynamic.cs index 2a87e91e..b5f54511 100644 --- a/src/Chapter18/Listing18.29.RuntimeBindingToXMLElementsWithoutDynamic.cs +++ b/src/Chapter18/Listing18.30.RuntimeBindingToXMLElementsWithoutDynamic.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_29; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_30; #region INCLUDE using System.Xml.Linq; diff --git a/src/Chapter18/Listing18.30.RuntimeBindingToXMLWithDynamics.cs b/src/Chapter18/Listing18.31.RuntimeBindingToXMLWithDynamics.cs similarity index 93% rename from src/Chapter18/Listing18.30.RuntimeBindingToXMLWithDynamics.cs rename to src/Chapter18/Listing18.31.RuntimeBindingToXMLWithDynamics.cs index a5ad6808..8feda5ce 100644 --- a/src/Chapter18/Listing18.30.RuntimeBindingToXMLWithDynamics.cs +++ b/src/Chapter18/Listing18.31.RuntimeBindingToXMLWithDynamics.cs @@ -1,6 +1,6 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_30; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_31; -using Listing18_31; +using Listing18_32; public class Program { public static void Main() diff --git a/src/Chapter18/Listing18.31.ImplementingACustomDynamicObject.cs b/src/Chapter18/Listing18.32.ImplementingACustomDynamicObject.cs similarity index 99% rename from src/Chapter18/Listing18.31.ImplementingACustomDynamicObject.cs rename to src/Chapter18/Listing18.32.ImplementingACustomDynamicObject.cs index c02a24c5..9f934d2d 100644 --- a/src/Chapter18/Listing18.31.ImplementingACustomDynamicObject.cs +++ b/src/Chapter18/Listing18.32.ImplementingACustomDynamicObject.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_31; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_32; #region INCLUDE using System.Dynamic; diff --git a/src/Chapter18/Listing18.32.OverridableMembersOnSystem.Dynamic.DynamicObject.cs b/src/Chapter18/Listing18.33.OverridableMembersOnSystem.Dynamic.DynamicObject.cs similarity index 99% rename from src/Chapter18/Listing18.32.OverridableMembersOnSystem.Dynamic.DynamicObject.cs rename to src/Chapter18/Listing18.33.OverridableMembersOnSystem.Dynamic.DynamicObject.cs index 46b23bb9..e68a6f8b 100644 --- a/src/Chapter18/Listing18.32.OverridableMembersOnSystem.Dynamic.DynamicObject.cs +++ b/src/Chapter18/Listing18.33.OverridableMembersOnSystem.Dynamic.DynamicObject.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_32 +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_33 { #region INCLUDE using System.Collections.Generic; From 77f4eddea206e6e1ad63e7128ec0d1ebd7b76ff8 Mon Sep 17 00:00:00 2001 From: Mark Michaelis Date: Thu, 21 Sep 2023 10:51:57 +0100 Subject: [PATCH 6/7] Renumbered Chapter 18 and added missing listing (#557) --- ...buteAndCheckingItsInitialization.Tests.cs} | 2 +- ...itionalAttributeToEliminateACall.Tests.cs} | 2 +- ...=> Listing18.26.GenericException.Tests.cs} | 2 +- ...ng18.27.CallerArgumentExpression.Tests.cs} | 25 +---------------- src/Chapter18.Tests/Listing18.28a.Tests.cs | 27 +++++++++++++++++++ ...ileForResequencingListings.Placeholder.cs} | 0 ... Listing18.13.DefiningACustomAttribute.cs} | 2 +- ...isting18.14.RetrievingACustomAttribute.cs} | 2 +- ...g18.15.ProvidingAnAttributeConstructor.cs} | 2 +- ...cAttributeAndCheckingItsInitialization.cs} | 4 +-- ....17.RetrievingCustomAttributeInstances.cs} | 2 +- ...andLineHandler.TryParseToHandleAliases.cs} | 4 +-- ...ingTheConstructsAnAttributeCanDecorate.cs} | 2 +- ...buteRestrictingWhereToApplyAnAttribute.cs} | 2 +- ...ibutesUsageWithAttributeUsageAttribute.cs} | 2 +- ...s => Listing18.22.UsingANamedParameter.cs} | 2 +- ...cs => Listing18.23.UsingFlagsAttribute.cs} | 2 +- ...ngConditionalAttributeToEliminateACall.cs} | 2 +- ...=> Listing18.25.UsingObsoleteAttribute.cs} | 2 +- ...on.cs => Listing18.26.GenericException.cs} | 2 +- ... Listing18.27.CallerArgumentExpression.cs} | 8 +----- ...ing18.28.InvokingCallerAttributesMethod.cs | 16 +++++++++++ 22 files changed, 64 insertions(+), 50 deletions(-) rename src/Chapter18.Tests/{Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs => Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs} (95%) rename src/Chapter18.Tests/{Listing18.25.UsingConditionalAttributeToEliminateACall.Tests.cs => Listing18.24.UsingConditionalAttributeToEliminateACall.Tests.cs} (96%) rename src/Chapter18.Tests/{Listing18.27.GenericException.Tests.cs => Listing18.26.GenericException.Tests.cs} (97%) rename src/Chapter18.Tests/{Listing18.28.CallerArgumentExpression.Tests.cs => Listing18.27.CallerArgumentExpression.Tests.cs} (56%) create mode 100644 src/Chapter18.Tests/Listing18.28a.Tests.cs rename src/Chapter18/{Listing18.13.csprojMockFileForResequencingListings.Placeholder.cs => Listing18.12.csprojMockFileForResequencingListings.Placeholder.cs} (100%) rename src/Chapter18/{Listing18.14.DefiningACustomAttribute.cs => Listing18.13.DefiningACustomAttribute.cs} (94%) rename src/Chapter18/{Listing18.15.RetrievingACustomAttribute.cs => Listing18.14.RetrievingACustomAttribute.cs} (98%) rename src/Chapter18/{Listing18.16.ProvidingAnAttributeConstructor.cs => Listing18.15.ProvidingAnAttributeConstructor.cs} (98%) rename src/Chapter18/{Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.cs => Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.cs} (97%) rename src/Chapter18/{Listing18.18.RetrievingCustomAttributeInstances.cs => Listing18.17.RetrievingCustomAttributeInstances.cs} (99%) rename src/Chapter18/{Listing18.19.UpdatingCommandLineHandler.TryParseToHandleAliases.cs => Listing18.18.UpdatingCommandLineHandler.TryParseToHandleAliases.cs} (99%) rename src/Chapter18/{Listing18.20.RestrictingTheConstructsAnAttributeCanDecorate.cs => Listing18.19.RestrictingTheConstructsAnAttributeCanDecorate.cs} (95%) rename src/Chapter18/{Listing18.21.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs => Listing18.20.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs} (96%) rename src/Chapter18/{Listing18.22.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs => Listing18.21.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs} (97%) rename src/Chapter18/{Listing18.23.UsingANamedParameter.cs => Listing18.22.UsingANamedParameter.cs} (95%) rename src/Chapter18/{Listing18.24.UsingFlagsAttribute.cs => Listing18.23.UsingFlagsAttribute.cs} (98%) rename src/Chapter18/{Listing18.25.UsingConditionalAttributeToEliminateACall.cs => Listing18.24.UsingConditionalAttributeToEliminateACall.cs} (98%) rename src/Chapter18/{Listing18.26.UsingObsoleteAttribute.cs => Listing18.25.UsingObsoleteAttribute.cs} (96%) rename src/Chapter18/{Listing18.27.GenericException.cs => Listing18.26.GenericException.cs} (98%) rename src/Chapter18/{Listing18.28.CallerArgumentExpression.cs => Listing18.27.CallerArgumentExpression.cs} (90%) create mode 100644 src/Chapter18/Listing18.28.InvokingCallerAttributesMethod.cs diff --git a/src/Chapter18.Tests/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs b/src/Chapter18.Tests/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs similarity index 95% rename from src/Chapter18.Tests/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs rename to src/Chapter18.Tests/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs index 385d1494..8b36398f 100644 --- a/src/Chapter18.Tests/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs +++ b/src/Chapter18.Tests/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_17.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_16.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter18.Tests/Listing18.25.UsingConditionalAttributeToEliminateACall.Tests.cs b/src/Chapter18.Tests/Listing18.24.UsingConditionalAttributeToEliminateACall.Tests.cs similarity index 96% rename from src/Chapter18.Tests/Listing18.25.UsingConditionalAttributeToEliminateACall.Tests.cs rename to src/Chapter18.Tests/Listing18.24.UsingConditionalAttributeToEliminateACall.Tests.cs index 1fe007a7..433efe51 100644 --- a/src/Chapter18.Tests/Listing18.25.UsingConditionalAttributeToEliminateACall.Tests.cs +++ b/src/Chapter18.Tests/Listing18.24.UsingConditionalAttributeToEliminateACall.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_25.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_24.Tests; [TestClass] public class ProgramTests diff --git a/src/Chapter18.Tests/Listing18.27.GenericException.Tests.cs b/src/Chapter18.Tests/Listing18.26.GenericException.Tests.cs similarity index 97% rename from src/Chapter18.Tests/Listing18.27.GenericException.Tests.cs rename to src/Chapter18.Tests/Listing18.26.GenericException.Tests.cs index b4f07bb6..902709e4 100644 --- a/src/Chapter18.Tests/Listing18.27.GenericException.Tests.cs +++ b/src/Chapter18.Tests/Listing18.26.GenericException.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26.Tests; #if NET7_0_OR_GREATER [TestClass] diff --git a/src/Chapter18.Tests/Listing18.28.CallerArgumentExpression.Tests.cs b/src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs similarity index 56% rename from src/Chapter18.Tests/Listing18.28.CallerArgumentExpression.Tests.cs rename to src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs index 9eb8b2c5..6901536f 100644 --- a/src/Chapter18.Tests/Listing18.28.CallerArgumentExpression.Tests.cs +++ b/src/Chapter18.Tests/Listing18.27.CallerArgumentExpression.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28.Tests; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27.Tests; #if NET7_0_OR_GREATER [TestClass] @@ -27,29 +27,6 @@ public void VerifyExpectedExceptionMessage() } } - [TestMethod] - public void Method() - { - try - { - SampleTests.Method(); - } - catch (InvalidOperationException exception) - { - Assert.IsTrue( - exception.Message.Contains("'() => { }'") && - exception.Message.Contains("'Method'") && - exception.Message.Contains("'./FileName.cs'")); - // The expected exception, System.DivideByZeroException, - // was not thrown by the expression, 'Method' in the method, './FileName.cs', and file 'C:\Git\EssentialCSharp\src\Chapter18\Listing18.25b.CallerArgumentExpression.cs'. - } - } - - private object PassingMethodNameAndFileName() - { - throw new NotImplementedException(); - } - [TestMethod] [ExpectedException(typeof(InvalidOperationException))] public void ExpectedExceptionIsNotThrown() diff --git a/src/Chapter18.Tests/Listing18.28a.Tests.cs b/src/Chapter18.Tests/Listing18.28a.Tests.cs new file mode 100644 index 00000000..f78c728e --- /dev/null +++ b/src/Chapter18.Tests/Listing18.28a.Tests.cs @@ -0,0 +1,27 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28.Tests; + +#if NET7_0_OR_GREATER +[TestClass] +public class GenericExceptionTests +{ + [TestMethod] + public void Method() + { + try + { + Program.Main(); + } + catch (InvalidOperationException exception) + { + Assert.IsTrue( + exception.Message.Contains("'() => { }'") && + exception.Message.Contains("'Method'") && + exception.Message.Contains("'./FileName.cs'")); + // The expected exception, System.DivideByZeroException, + // was not thrown by the expression, 'Method' in the method, './FileName.cs', and file 'C:\Git\EssentialCSharp\src\Chapter18\Listing18.25b.CallerArgumentExpression.cs'. + } + } +} +#endif // NET7_0_OR_GREATER diff --git a/src/Chapter18/Listing18.13.csprojMockFileForResequencingListings.Placeholder.cs b/src/Chapter18/Listing18.12.csprojMockFileForResequencingListings.Placeholder.cs similarity index 100% rename from src/Chapter18/Listing18.13.csprojMockFileForResequencingListings.Placeholder.cs rename to src/Chapter18/Listing18.12.csprojMockFileForResequencingListings.Placeholder.cs diff --git a/src/Chapter18/Listing18.14.DefiningACustomAttribute.cs b/src/Chapter18/Listing18.13.DefiningACustomAttribute.cs similarity index 94% rename from src/Chapter18/Listing18.14.DefiningACustomAttribute.cs rename to src/Chapter18/Listing18.13.DefiningACustomAttribute.cs index b2054f8f..1c8874a4 100644 --- a/src/Chapter18/Listing18.14.DefiningACustomAttribute.cs +++ b/src/Chapter18/Listing18.13.DefiningACustomAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_14; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_13; #region INCLUDE public class CommandLineSwitchRequiredAttribute : Attribute diff --git a/src/Chapter18/Listing18.15.RetrievingACustomAttribute.cs b/src/Chapter18/Listing18.14.RetrievingACustomAttribute.cs similarity index 98% rename from src/Chapter18/Listing18.15.RetrievingACustomAttribute.cs rename to src/Chapter18/Listing18.14.RetrievingACustomAttribute.cs index cb75dec9..de95efd0 100644 --- a/src/Chapter18/Listing18.15.RetrievingACustomAttribute.cs +++ b/src/Chapter18/Listing18.14.RetrievingACustomAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_15; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_14; #region INCLUDE using System.Reflection; diff --git a/src/Chapter18/Listing18.16.ProvidingAnAttributeConstructor.cs b/src/Chapter18/Listing18.15.ProvidingAnAttributeConstructor.cs similarity index 98% rename from src/Chapter18/Listing18.16.ProvidingAnAttributeConstructor.cs rename to src/Chapter18/Listing18.15.ProvidingAnAttributeConstructor.cs index 6999f221..4e47f254 100644 --- a/src/Chapter18/Listing18.16.ProvidingAnAttributeConstructor.cs +++ b/src/Chapter18/Listing18.15.ProvidingAnAttributeConstructor.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_16; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_15; #region INCLUDE public class CommandLineSwitchAliasAttribute : Attribute diff --git a/src/Chapter18/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.cs b/src/Chapter18/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.cs similarity index 97% rename from src/Chapter18/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.cs rename to src/Chapter18/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.cs index 350d0d66..7f2cfcd5 100644 --- a/src/Chapter18/Listing18.17.RetrievingASpecificAttributeAndCheckingItsInitialization.cs +++ b/src/Chapter18/Listing18.16.RetrievingASpecificAttributeAndCheckingItsInitialization.cs @@ -1,6 +1,6 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_17; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_16; -using AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_16; +using AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_15; using System.Reflection; public class Program diff --git a/src/Chapter18/Listing18.18.RetrievingCustomAttributeInstances.cs b/src/Chapter18/Listing18.17.RetrievingCustomAttributeInstances.cs similarity index 99% rename from src/Chapter18/Listing18.18.RetrievingCustomAttributeInstances.cs rename to src/Chapter18/Listing18.17.RetrievingCustomAttributeInstances.cs index 517748ba..1d6d8056 100644 --- a/src/Chapter18/Listing18.18.RetrievingCustomAttributeInstances.cs +++ b/src/Chapter18/Listing18.17.RetrievingCustomAttributeInstances.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_18; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_17; #region INCLUDE using System.Reflection; diff --git a/src/Chapter18/Listing18.19.UpdatingCommandLineHandler.TryParseToHandleAliases.cs b/src/Chapter18/Listing18.18.UpdatingCommandLineHandler.TryParseToHandleAliases.cs similarity index 99% rename from src/Chapter18/Listing18.19.UpdatingCommandLineHandler.TryParseToHandleAliases.cs rename to src/Chapter18/Listing18.18.UpdatingCommandLineHandler.TryParseToHandleAliases.cs index 1a3f1c47..9f345bcd 100644 --- a/src/Chapter18/Listing18.19.UpdatingCommandLineHandler.TryParseToHandleAliases.cs +++ b/src/Chapter18/Listing18.18.UpdatingCommandLineHandler.TryParseToHandleAliases.cs @@ -1,6 +1,6 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_19; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_18; -using Listing18_18; +using Listing18_17; #region INCLUDE using System.Reflection; using System.Collections.Generic; diff --git a/src/Chapter18/Listing18.20.RestrictingTheConstructsAnAttributeCanDecorate.cs b/src/Chapter18/Listing18.19.RestrictingTheConstructsAnAttributeCanDecorate.cs similarity index 95% rename from src/Chapter18/Listing18.20.RestrictingTheConstructsAnAttributeCanDecorate.cs rename to src/Chapter18/Listing18.19.RestrictingTheConstructsAnAttributeCanDecorate.cs index a5d6d6c3..d43846bf 100644 --- a/src/Chapter18/Listing18.20.RestrictingTheConstructsAnAttributeCanDecorate.cs +++ b/src/Chapter18/Listing18.19.RestrictingTheConstructsAnAttributeCanDecorate.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_20; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_19; #region INCLUDE [AttributeUsage(AttributeTargets.Property)] diff --git a/src/Chapter18/Listing18.21.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs b/src/Chapter18/Listing18.20.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs similarity index 96% rename from src/Chapter18/Listing18.21.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs rename to src/Chapter18/Listing18.20.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs index dd697828..606196aa 100644 --- a/src/Chapter18/Listing18.21.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs +++ b/src/Chapter18/Listing18.20.AttributeUsageAttributeRestrictingWhereToApplyAnAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_21; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_20; // Will not compile if uncommented /* diff --git a/src/Chapter18/Listing18.22.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs b/src/Chapter18/Listing18.21.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs similarity index 97% rename from src/Chapter18/Listing18.22.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs rename to src/Chapter18/Listing18.21.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs index 3676b082..e050de1f 100644 --- a/src/Chapter18/Listing18.22.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs +++ b/src/Chapter18/Listing18.21.LimitingAnAttributesUsageWithAttributeUsageAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_22; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_21; #region INCLUDE // Restrict the attribute to properties and methods diff --git a/src/Chapter18/Listing18.23.UsingANamedParameter.cs b/src/Chapter18/Listing18.22.UsingANamedParameter.cs similarity index 95% rename from src/Chapter18/Listing18.23.UsingANamedParameter.cs rename to src/Chapter18/Listing18.22.UsingANamedParameter.cs index c035f7ee..4e6997b3 100644 --- a/src/Chapter18/Listing18.23.UsingANamedParameter.cs +++ b/src/Chapter18/Listing18.22.UsingANamedParameter.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_23; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_22; #region INCLUDE [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)] diff --git a/src/Chapter18/Listing18.24.UsingFlagsAttribute.cs b/src/Chapter18/Listing18.23.UsingFlagsAttribute.cs similarity index 98% rename from src/Chapter18/Listing18.24.UsingFlagsAttribute.cs rename to src/Chapter18/Listing18.23.UsingFlagsAttribute.cs index 137200e8..15afe8c2 100644 --- a/src/Chapter18/Listing18.24.UsingFlagsAttribute.cs +++ b/src/Chapter18/Listing18.23.UsingFlagsAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_24; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_23; #region INCLUDE /* diff --git a/src/Chapter18/Listing18.25.UsingConditionalAttributeToEliminateACall.cs b/src/Chapter18/Listing18.24.UsingConditionalAttributeToEliminateACall.cs similarity index 98% rename from src/Chapter18/Listing18.25.UsingConditionalAttributeToEliminateACall.cs rename to src/Chapter18/Listing18.24.UsingConditionalAttributeToEliminateACall.cs index daba8cc6..0cf0353d 100644 --- a/src/Chapter18/Listing18.25.UsingConditionalAttributeToEliminateACall.cs +++ b/src/Chapter18/Listing18.24.UsingConditionalAttributeToEliminateACall.cs @@ -1,7 +1,7 @@ #region INCLUDE #define CONDITION_A #region EXCLUDE -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_25; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_24; #endregion EXCLUDE using System.Diagnostics; diff --git a/src/Chapter18/Listing18.26.UsingObsoleteAttribute.cs b/src/Chapter18/Listing18.25.UsingObsoleteAttribute.cs similarity index 96% rename from src/Chapter18/Listing18.26.UsingObsoleteAttribute.cs rename to src/Chapter18/Listing18.25.UsingObsoleteAttribute.cs index 2f8ca541..8eecc596 100644 --- a/src/Chapter18/Listing18.26.UsingObsoleteAttribute.cs +++ b/src/Chapter18/Listing18.25.UsingObsoleteAttribute.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_25; #region INCLUDE public class Program diff --git a/src/Chapter18/Listing18.27.GenericException.cs b/src/Chapter18/Listing18.26.GenericException.cs similarity index 98% rename from src/Chapter18/Listing18.27.GenericException.cs rename to src/Chapter18/Listing18.26.GenericException.cs index 0eafbe33..7d29d06c 100644 --- a/src/Chapter18/Listing18.27.GenericException.cs +++ b/src/Chapter18/Listing18.26.GenericException.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_26; #if NET7_0_OR_GREATER #region INCLUDE diff --git a/src/Chapter18/Listing18.28.CallerArgumentExpression.cs b/src/Chapter18/Listing18.27.CallerArgumentExpression.cs similarity index 90% rename from src/Chapter18/Listing18.28.CallerArgumentExpression.cs rename to src/Chapter18/Listing18.27.CallerArgumentExpression.cs index 8391d837..86ce31dd 100644 --- a/src/Chapter18/Listing18.28.CallerArgumentExpression.cs +++ b/src/Chapter18/Listing18.27.CallerArgumentExpression.cs @@ -1,6 +1,6 @@ using System.Runtime.CompilerServices; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27; #if NET7_0_OR_GREATER #region INCLUDE @@ -13,12 +13,6 @@ public static void ThrowArgumentNullExceptionTest() { var result = 1/"".Length; } - -public static void Method() -{ - ExpectedException.AssertExceptionThrown( - () => throw new DivideByZeroException()); -} } [AttributeUsage(AttributeTargets.Method)] diff --git a/src/Chapter18/Listing18.28.InvokingCallerAttributesMethod.cs b/src/Chapter18/Listing18.28.InvokingCallerAttributesMethod.cs new file mode 100644 index 00000000..3e2c627a --- /dev/null +++ b/src/Chapter18/Listing18.28.InvokingCallerAttributesMethod.cs @@ -0,0 +1,16 @@ +using AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_27; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_28; + +#if NET7_0_OR_GREATER +public class Program +{ + public static void Main() + { + #region INCLUDE + ExpectedException.AssertExceptionThrown( + () => throw new DivideByZeroException()); + #endregion INCLUDE + } +} +#endif // NET7_0_OR_GREATER From 362874abb2b28ad38c4bebf2359afcfdbe4a14f2 Mon Sep 17 00:00:00 2001 From: Daniel Olvera <139163393+danOIntellitect@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:37:16 -0700 Subject: [PATCH 7/7] Feat: Review Spelling of Listing Code (#552) ## Summary Added a spell check editor config along with a exlusion.dic file that contains the strings that we determine are spelled correctly. Then I went through the source code and corrected the misspelled words. Fixes 1618 from the other repo : https://github.com/IntelliTect-dev/EssentialCSharp.Tooling/issues/1618 --- .editorconfig | 368 ++++++++++++++++++ exclusion.dic | 64 +++ .../Listing01.21.CommentingYourCode.cs | 2 +- src/Chapter03.Tests/Table03.03.Tests.cs | 6 +- ...able03.01.TupleDeclarationAndAssignment.cs | 4 +- .../Table03.03.a.CommonArrayCodingErrors.cs | 2 +- .../Table03.03.c.CommonArrayCodingErrors.cs | 2 +- .../Table03.03.d.CommonArrayCodingErrors.cs | 2 +- .../Table03.03.e.CommonArrayCodingErrors.cs | 2 +- .../Table03.03.f.CommonArrayCodingErrors.cs | 2 +- .../Table03.03.g.CommonArrayCodingErrors.cs | 2 +- .../Table03.03.h.CommonArrayCodingErrors.cs | 2 +- .../Table03.03.i.CommonArrayCodingErrors.cs | 2 +- .../Table03.03.j.CommonArrayCodingErrors.cs | 2 +- .../Listing06.03.InstantiatingAClass.cs | 2 +- ...ting06.15.UsingThePrivateAccessModifier.cs | 2 +- .../Listing06.17.DefiningProperties.cs | 2 +- ...ngPropertiesWithExpressionBodiedMembers.cs | 2 +- ...sting06.22.DefiningCalculatedProperties.cs | 2 +- ....23.ConstantPatternWithSwitchExpression.cs | 6 +- .../Listing07.25.LogicalPatternExamples.cs | 2 +- ...sting07.26.ParenthesizedPatternExamples.cs | 4 +- .../Listing07.31.SwitchWithPatternMatching.cs | 4 +- .../Listing07.32.RecursivePatternMatching.cs | 2 +- ...gExplicitInterfaceMemberImplementations.cs | 2 +- ...8.12.DefaultImplementedInterfaceMembers.cs | 8 +- ....14.ForcingTheDesirableRunEncapsulation.cs | 2 +- ...8.01.DefaultImplementedInterfaceMembers.cs | 4 +- .../Listing10.02.AddingAnOperator.cs | 2 +- ...verloadingTheMinusAndPlusUnaryOperators.cs | 2 +- ...nitializingAFieldWithTheDefaultOperator.cs | 4 +- .../Listing12.46.StackDeclaration.cs | 2 +- .../Listing12.49.StackIntDefinition.cs | 2 +- .../Listing13.18.UsingVarianceForDelegates.cs | 2 +- .../Listing14.05.InvokingADelegate.cs | 2 +- ...Listing14.14.FiringTheEventNotification.cs | 2 +- ...Listing14.17.CustomAddAndRemoveHandlers.cs | 2 +- ...ing17.10.ChangingTheIndexersDefaultName.cs | 4 +- ...17.15.UsingPair.GetEnumeratorViaForeach.cs | 4 +- ...PlacingYieldReturnStatementsWithinALoop.cs | 2 +- ...coratingAPropertyWithMultipleAttributes.cs | 4 +- .../Listing18.23.UsingFlagsAttribute.cs | 2 +- ...isting20.16.IteratingOverAwaitOperation.cs | 2 +- .../Listing21.10.CancelingParallelLoop.cs | 6 +- ...isting22.08.ThreadSafeEventNotification.cs | 2 +- src/Shared/Cryptographer.cs | 4 +- src/Shared/Program.cs | 2 +- 47 files changed, 495 insertions(+), 63 deletions(-) create mode 100644 .editorconfig create mode 100644 exclusion.dic diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..3b3dd080 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,368 @@ +root = true + +# All files +[*] +indent_style = space + +# Xml files +[*.xml] +indent_size = 2 + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### +[*.{cs,vb}] + +# Organize usings +dotnet_separate_import_directive_groups = true +dotnet_sort_system_directives_first = true +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:silent +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_property = false:silent + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent + +# Expression-level preferences +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_object_initializer = true:suggestion +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion + +# Field preferences +dotnet_style_readonly_field = true:warning + +# Parameter preferences +dotnet_code_quality_unused_parameters = all:suggestion + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +#### C# Coding Conventions #### +[*.cs] + +# var preferences +csharp_style_var_elsewhere = false:silent +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_switch_expression = true:suggestion + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:suggestion + +# Modifier preferences +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### +[*.{cs,vb}] + +# Naming rules + +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion +dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces +dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase + +dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion +dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters +dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase + +dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods +dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties +dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.events_should_be_pascalcase.symbols = events +dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables +dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase + +dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants +dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase + +dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion +dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters +dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase + +dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields +dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion +dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields +dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase + +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase + +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums +dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase + +# Symbol specifications + +dotnet_naming_symbols.interfaces.applicable_kinds = interface +dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interfaces.required_modifiers = + +dotnet_naming_symbols.enums.applicable_kinds = enum +dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.enums.required_modifiers = + +dotnet_naming_symbols.events.applicable_kinds = event +dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.events.required_modifiers = + +dotnet_naming_symbols.methods.applicable_kinds = method +dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.methods.required_modifiers = + +dotnet_naming_symbols.properties.applicable_kinds = property +dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.properties.required_modifiers = + +dotnet_naming_symbols.public_fields.applicable_kinds = field +dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_fields.required_modifiers = + +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_fields.required_modifiers = + +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_fields.required_modifiers = static + +dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum +dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types_and_namespaces.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +dotnet_naming_symbols.type_parameters.applicable_kinds = namespace +dotnet_naming_symbols.type_parameters.applicable_accessibilities = * +dotnet_naming_symbols.type_parameters.required_modifiers = + +dotnet_naming_symbols.private_constant_fields.applicable_kinds = field +dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_constant_fields.required_modifiers = const + +dotnet_naming_symbols.local_variables.applicable_kinds = local +dotnet_naming_symbols.local_variables.applicable_accessibilities = local +dotnet_naming_symbols.local_variables.required_modifiers = + +dotnet_naming_symbols.local_constants.applicable_kinds = local +dotnet_naming_symbols.local_constants.applicable_accessibilities = local +dotnet_naming_symbols.local_constants.required_modifiers = const + +dotnet_naming_symbols.parameters.applicable_kinds = parameter +dotnet_naming_symbols.parameters.applicable_accessibilities = * +dotnet_naming_symbols.parameters.required_modifiers = + +dotnet_naming_symbols.public_constant_fields.applicable_kinds = field +dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_constant_fields.required_modifiers = const + +dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function +dotnet_naming_symbols.local_functions.applicable_accessibilities = * +dotnet_naming_symbols.local_functions.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascalcase.required_prefix = +dotnet_naming_style.pascalcase.required_suffix = +dotnet_naming_style.pascalcase.word_separator = +dotnet_naming_style.pascalcase.capitalization = pascal_case + +dotnet_naming_style.ipascalcase.required_prefix = I +dotnet_naming_style.ipascalcase.required_suffix = +dotnet_naming_style.ipascalcase.word_separator = +dotnet_naming_style.ipascalcase.capitalization = pascal_case + +dotnet_naming_style.tpascalcase.required_prefix = T +dotnet_naming_style.tpascalcase.required_suffix = +dotnet_naming_style.tpascalcase.word_separator = +dotnet_naming_style.tpascalcase.capitalization = pascal_case + +dotnet_naming_style._camelcase.required_prefix = _ +dotnet_naming_style._camelcase.required_suffix = +dotnet_naming_style._camelcase.word_separator = +dotnet_naming_style._camelcase.capitalization = camel_case + +dotnet_naming_style.camelcase.required_prefix = +dotnet_naming_style.camelcase.required_suffix = +dotnet_naming_style.camelcase.word_separator = +dotnet_naming_style.camelcase.capitalization = camel_case + +dotnet_naming_style.s_camelcase.required_prefix = s_ +dotnet_naming_style.s_camelcase.required_suffix = +dotnet_naming_style.s_camelcase.word_separator = +dotnet_naming_style.s_camelcase.capitalization = camel_case + +spelling_exclusion_path = .\exclusion.dic +spelling_checkable_types = strings,identifiers,comments +spelling_error_severity = error + diff --git a/exclusion.dic b/exclusion.dic new file mode 100644 index 00000000..05736362 --- /dev/null +++ b/exclusion.dic @@ -0,0 +1,64 @@ +valerie +ansi +specialname +awaitable +csproj +Usings +warnaserror +lpfl +cpuid +retq +vmax +decryptor +Abidal +Barthez +Coupet +Landreau +Boumsong +Chimbonda +Gallas +Givet +Sagnol +Thuram +Dhorasoo +Diarra +Makelele +Djibril Cisse +Saha +Trezeguet +Wiltord +Saha +Zaccardo +Zambrotta +Cannavaro +Oddo +Gattuso +Camoranesi +Gilardino +Iaquinta +beforefieldinit +mscorlib +Dever +Stokesbary +Heavey +enumtest +Equatable +Fireswamp +spokane +urls +iassist +Infos +IntelliTect +typelib +partnersintl +Wylam +attrs +deconstructor +Deconstructors +Hartfelt +Lindherst +Parksdale +Monteray +inigo +Machava +Uncompress \ No newline at end of file diff --git a/src/Chapter01/Listing01.21.CommentingYourCode.cs b/src/Chapter01/Listing01.21.CommentingYourCode.cs index a03aaade..510748e5 100644 --- a/src/Chapter01/Listing01.21.CommentingYourCode.cs +++ b/src/Chapter01/Listing01.21.CommentingYourCode.cs @@ -17,7 +17,7 @@ public static void Main() lastName = Console.ReadLine(); /* Display a greeting to the console - using composite fomatting. */ + using composite formatting. */ Console.WriteLine("Your full name is {1}, {0}.", firstName, lastName); diff --git a/src/Chapter03.Tests/Table03.03.Tests.cs b/src/Chapter03.Tests/Table03.03.Tests.cs index 1c923808..e180c402 100644 --- a/src/Chapter03.Tests/Table03.03.Tests.cs +++ b/src/Chapter03.Tests/Table03.03.Tests.cs @@ -25,7 +25,7 @@ public async Task ParseAndCompile(string fileNameSuffix, params string[] errorId [ExpectedException(typeof(IndexOutOfRangeException))] public void IndexingOffTheEndOfArrayTest() { - CommonArayCodingErrors.IndexingOffTheEndOfArray(); + CommonArrayCodingErrors.IndexingOffTheEndOfArray(); } // 7. @@ -33,7 +33,7 @@ public void IndexingOffTheEndOfArrayTest() [ExpectedException(typeof(IndexOutOfRangeException))] public void Hat0IsOnePastTheEndOfTheArray1Test() { - CommonArayCodingErrors.Hat0IsOnePastTheEndOfTheArray1(); + CommonArrayCodingErrors.Hat0IsOnePastTheEndOfTheArray1(); } // 8. @@ -41,6 +41,6 @@ public void Hat0IsOnePastTheEndOfTheArray1Test() [ExpectedException(typeof(IndexOutOfRangeException))] public void Hat0IsOnePastTheEndOfTheArray2Test() { - CommonArayCodingErrors.LastItemIsLengthMinus1(); + CommonArrayCodingErrors.LastItemIsLengthMinus1(); } } \ No newline at end of file diff --git a/src/Chapter03/Table03.01.TupleDeclarationAndAssignment.cs b/src/Chapter03/Table03.01.TupleDeclarationAndAssignment.cs index 0cb87b02..21611e4a 100644 --- a/src/Chapter03/Table03.01.TupleDeclarationAndAssignment.cs +++ b/src/Chapter03/Table03.01.TupleDeclarationAndAssignment.cs @@ -1,9 +1,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_01; -public class TupleDeclarationAndAssigment +public class TupleDeclarationAndAssignment { // 1. - public void AssignTupleToIndividuallyDeclaredVaraibles() + public void AssignTupleToIndividuallyDeclaredVariables() { (string country, string capital, double gdpPerCapita) = ("Burundi", "Bujumbura", 263.67); diff --git a/src/Chapter03/Table03.03.a.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.a.CommonArrayCodingErrors.cs index ef8b9ec5..ade797eb 100644 --- a/src/Chapter03/Table03.03.a.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.a.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 1. static public void SquareBracketsOnVariableRatherThanType() diff --git a/src/Chapter03/Table03.03.c.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.c.CommonArrayCodingErrors.cs index 88f5dcf6..4cac251a 100644 --- a/src/Chapter03/Table03.03.c.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.c.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 3. static public void ArraySizeCannotBeSpecifiedInDataType() diff --git a/src/Chapter03/Table03.03.d.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.d.CommonArrayCodingErrors.cs index 3e42e804..18af207c 100644 --- a/src/Chapter03/Table03.03.d.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.d.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 4. static public void ArraySizeOrInitializerIsRequired() diff --git a/src/Chapter03/Table03.03.e.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.e.CommonArrayCodingErrors.cs index 2cc9dfdf..a0231a6e 100644 --- a/src/Chapter03/Table03.03.e.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.e.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 5. static public void ArraySizeWithEmptyInitializer() diff --git a/src/Chapter03/Table03.03.f.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.f.CommonArrayCodingErrors.cs index 0cc8d38d..18caf793 100644 --- a/src/Chapter03/Table03.03.f.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.f.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 6. static public void IndexingOffTheEndOfArray() diff --git a/src/Chapter03/Table03.03.g.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.g.CommonArrayCodingErrors.cs index 02be04c1..6d7bbd05 100644 --- a/src/Chapter03/Table03.03.g.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.g.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 7. static public void Hat0IsOnePastTheEndOfTheArray1() diff --git a/src/Chapter03/Table03.03.h.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.h.CommonArrayCodingErrors.cs index ec701061..d3255c39 100644 --- a/src/Chapter03/Table03.03.h.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.h.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 8. static public void LastItemIsLengthMinus1() diff --git a/src/Chapter03/Table03.03.i.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.i.CommonArrayCodingErrors.cs index d4a3b75c..12cd0ee3 100644 --- a/src/Chapter03/Table03.03.i.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.i.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 9. static public void MultiDimensionalArrayWithInconsistentSize() diff --git a/src/Chapter03/Table03.03.j.CommonArrayCodingErrors.cs b/src/Chapter03/Table03.03.j.CommonArrayCodingErrors.cs index f6d9886b..84c7d3b8 100644 --- a/src/Chapter03/Table03.03.j.CommonArrayCodingErrors.cs +++ b/src/Chapter03/Table03.03.j.CommonArrayCodingErrors.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03; -public partial class CommonArayCodingErrors +public partial class CommonArrayCodingErrors { // 10. static public void MembersInJaggedArraysMustBeInstantiated() diff --git a/src/Chapter06/Listing06.03.InstantiatingAClass.cs b/src/Chapter06/Listing06.03.InstantiatingAClass.cs index dfe92270..24d29077 100644 --- a/src/Chapter06/Listing06.03.InstantiatingAClass.cs +++ b/src/Chapter06/Listing06.03.InstantiatingAClass.cs @@ -1,4 +1,4 @@ -// Justificaiton: only partial implementation provided for elucidation. +// Justification: only partial implementation provided for elucidation. #pragma warning disable IDE0060 // Remove unused parameter namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_03; diff --git a/src/Chapter06/Listing06.15.UsingThePrivateAccessModifier.cs b/src/Chapter06/Listing06.15.UsingThePrivateAccessModifier.cs index 0f4aea7a..6c28482a 100644 --- a/src/Chapter06/Listing06.15.UsingThePrivateAccessModifier.cs +++ b/src/Chapter06/Listing06.15.UsingThePrivateAccessModifier.cs @@ -2,7 +2,7 @@ #pragma warning disable CS8618 // Our Main doesn't leverage everything in our Employee implementation - in production it would #pragma warning disable CS0649 -// Disabled pending introductin to object initializers +// Disabled pending introduction to object initializers #pragma warning disable IDE0017 // Add readonly modifier ignored pending introduction of the concept #pragma warning disable IDE0044 diff --git a/src/Chapter06/Listing06.17.DefiningProperties.cs b/src/Chapter06/Listing06.17.DefiningProperties.cs index 3f849140..106373de 100644 --- a/src/Chapter06/Listing06.17.DefiningProperties.cs +++ b/src/Chapter06/Listing06.17.DefiningProperties.cs @@ -1,6 +1,6 @@ // Non-nullable field is uninitialized. Consider declaring as nullable. #pragma warning disable CS8618 -// Disabled pending introductin to object initializers +// Disabled pending introduction to object initializers #pragma warning disable IDE0017 namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_17; diff --git a/src/Chapter06/Listing06.18.DefiningPropertiesWithExpressionBodiedMembers.cs b/src/Chapter06/Listing06.18.DefiningPropertiesWithExpressionBodiedMembers.cs index b3e1b96f..9e96e73b 100644 --- a/src/Chapter06/Listing06.18.DefiningPropertiesWithExpressionBodiedMembers.cs +++ b/src/Chapter06/Listing06.18.DefiningPropertiesWithExpressionBodiedMembers.cs @@ -1,6 +1,6 @@ // Non-nullable field is uninitialized. Consider declaring as nullable. #pragma warning disable CS8618 -// Disabled pending introductin to object initializers +// Disabled pending introduction to object initializers #pragma warning disable IDE0017 namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_18; diff --git a/src/Chapter06/Listing06.22.DefiningCalculatedProperties.cs b/src/Chapter06/Listing06.22.DefiningCalculatedProperties.cs index 6abbffb4..d8e7a438 100644 --- a/src/Chapter06/Listing06.22.DefiningCalculatedProperties.cs +++ b/src/Chapter06/Listing06.22.DefiningCalculatedProperties.cs @@ -1,6 +1,6 @@ // Non-nullable field is uninitialized. Consider declaring as nullable. #pragma warning disable CS8618 // Pending a constructors -// Disabled pending introductin to object initializers +// Disabled pending introduction to object initializers #pragma warning disable IDE0017 namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_22; diff --git a/src/Chapter07/Listing07.23.ConstantPatternWithSwitchExpression.cs b/src/Chapter07/Listing07.23.ConstantPatternWithSwitchExpression.cs index e39cba8a..869700c1 100644 --- a/src/Chapter07/Listing07.23.ConstantPatternWithSwitchExpression.cs +++ b/src/Chapter07/Listing07.23.ConstantPatternWithSwitchExpression.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter07.Listing07_23; #region INCLUDE using System.Diagnostics.CodeAnalysis; -public static class SolisticeHelper +public static class SolsticeHelper { public static bool IsSolstice( DateTime date) @@ -30,8 +30,8 @@ public static bool TryGetSolstice(DateTime date, { if ((solstice = date.Month switch { - 12 => "Winter Solistice", - 6 => "Summer Solistice", + 12 => "Winter Solstice", + 6 => "Summer Solstice", _ => null }) is not null) return true; } diff --git a/src/Chapter07/Listing07.25.LogicalPatternExamples.cs b/src/Chapter07/Listing07.25.LogicalPatternExamples.cs index 2eddc4cf..af2b5aa3 100644 --- a/src/Chapter07/Listing07.25.LogicalPatternExamples.cs +++ b/src/Chapter07/Listing07.25.LogicalPatternExamples.cs @@ -19,7 +19,7 @@ static bool TryGetPhoneButton( { '1' => '1', '2' or >= 'a' and <= 'c' => '2', - // not operator and parethesis example (C# 10) + // not operator and parenthesis example (C# 10) '3' or not (< 'd' or > 'f') => '3', '4' or >= 'g' and <= 'i' => '4', '5' or >= 'j' and <= 'l' => '5', diff --git a/src/Chapter07/Listing07.26.ParenthesizedPatternExamples.cs b/src/Chapter07/Listing07.26.ParenthesizedPatternExamples.cs index 47e208e5..c33abfeb 100644 --- a/src/Chapter07/Listing07.26.ParenthesizedPatternExamples.cs +++ b/src/Chapter07/Listing07.26.ParenthesizedPatternExamples.cs @@ -8,7 +8,7 @@ public class PeriodsOfTheDay public bool IsOutsideOfStandardWorkHours( TimeOnly time) => time.Hour is not - (> 8 and < 17 and not 12); // Parentbhesis Pattern - C# 10. + (> 8 and < 17 and not 12); // Parenthesis Pattern - C# 10. #endregion INCLUDE static bool TryGetPhoneButton( @@ -19,7 +19,7 @@ static bool TryGetPhoneButton( { '1' => '1', '2' or >= 'a' and <= 'c' => '2', - // not operator and parethesis example (C# 10) + // not operator and parenthesis example (C# 10) '3' or not (< 'd' or > 'f') => '3', '4' or >= 'g' and <= 'i' => '4', '5' or >= 'j' and <= 'l' => '5', diff --git a/src/Chapter07/Listing07.31.SwitchWithPatternMatching.cs b/src/Chapter07/Listing07.31.SwitchWithPatternMatching.cs index f4cb14dd..ebed5e07 100644 --- a/src/Chapter07/Listing07.31.SwitchWithPatternMatching.cs +++ b/src/Chapter07/Listing07.31.SwitchWithPatternMatching.cs @@ -4,7 +4,7 @@ public class Program { #region INCLUDE public static string? CompositeFormatDate( - object input, string compositFormatString) => + object input, string compositeFormatString) => input switch { DateTime @@ -24,7 +24,7 @@ public class Program ((int Year, int Month, int Day)?) null, _ => null } is (int, int, int) date ? string.Format( - compositFormatString, date.Year, date.Month, date.Day) : null; + compositeFormatString, date.Year, date.Month, date.Day) : null; #endregion INCLUDE } file static class DateDeconstructors diff --git a/src/Chapter07/Listing07.32.RecursivePatternMatching.cs b/src/Chapter07/Listing07.32.RecursivePatternMatching.cs index 90109771..e77fcfcc 100644 --- a/src/Chapter07/Listing07.32.RecursivePatternMatching.cs +++ b/src/Chapter07/Listing07.32.RecursivePatternMatching.cs @@ -29,7 +29,7 @@ public static void Main() (inigo, buttercup); if (couple is - ( // Tuple: Retrived from deconstructor of Person + ( // Tuple: Retrieved from deconstructor of Person ( // Positional: Select left side or tuple { // Property of firstName Length: int inigoFirstNameLength diff --git a/src/Chapter08/Listing08.04.CallingExplicitInterfaceMemberImplementations.cs b/src/Chapter08/Listing08.04.CallingExplicitInterfaceMemberImplementations.cs index f321a9e8..f20148b7 100644 --- a/src/Chapter08/Listing08.04.CallingExplicitInterfaceMemberImplementations.cs +++ b/src/Chapter08/Listing08.04.CallingExplicitInterfaceMemberImplementations.cs @@ -1,4 +1,4 @@ -// Justification: Only a aartial implmentation provided for elucidation purposes. +// Justification: Only a partial implementation provided for elucidation purposes. #pragma warning disable IDE0059 // Unnecessary assignment of a value namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter08.Listing08_04; diff --git a/src/Chapter08/Listing08.12.DefaultImplementedInterfaceMembers.cs b/src/Chapter08/Listing08.12.DefaultImplementedInterfaceMembers.cs index 00710dd4..ddf55fa6 100644 --- a/src/Chapter08/Listing08.12.DefaultImplementedInterfaceMembers.cs +++ b/src/Chapter08/Listing08.12.DefaultImplementedInterfaceMembers.cs @@ -240,8 +240,8 @@ private static int[] DisplayHeaders(string[] headers) private static void DisplayItemRow( int[] columnWidths, IListable item) { - string?[] columValues = item.CellValues; - if (columnWidths.Length != columValues.Length) + string?[] columnValues = item.CellValues; + if (columnWidths.Length != columnValues.Length) { throw new ArgumentOutOfRangeException( $"{ nameof(columnWidths) },{ nameof(item) }.{nameof(item.CellColors) }", @@ -251,9 +251,9 @@ private static void DisplayItemRow( // Exception handling excluded for elucidation ConsoleColor originalColor = Console.ForegroundColor; ConsoleColor[] itemColors = ((IListable)item).CellColors; - for (int index = 0; index < columValues.Length; index++) + for (int index = 0; index < columnValues.Length; index++) { - string itemToPrint = (columValues[index] ?? "").PadRight(columnWidths[index], ' '); + string itemToPrint = (columnValues[index] ?? "").PadRight(columnWidths[index], ' '); Console.ForegroundColor = itemColors[index]; Console.Write(itemToPrint); } diff --git a/src/Chapter08/Listing08.14.ForcingTheDesirableRunEncapsulation.cs b/src/Chapter08/Listing08.14.ForcingTheDesirableRunEncapsulation.cs index 2ec47774..b8002a0e 100644 --- a/src/Chapter08/Listing08.14.ForcingTheDesirableRunEncapsulation.cs +++ b/src/Chapter08/Listing08.14.ForcingTheDesirableRunEncapsulation.cs @@ -75,7 +75,7 @@ public static void Run() // implemented in the class. // ((IWorkflowActivity)this).InternalRun(); // activity.RedirectStandardInOut(); - // activity.ExecuteProcss(); + // activity.ExecuteProcess(); Console.WriteLine( @$"Executing non-polymorphic Run() with process '{ activity.ExecutableName}'."); diff --git a/src/Chapter08/Table08.01.DefaultImplementedInterfaceMembers.cs b/src/Chapter08/Table08.01.DefaultImplementedInterfaceMembers.cs index 40d07686..24dbb772 100644 --- a/src/Chapter08/Table08.01.DefaultImplementedInterfaceMembers.cs +++ b/src/Chapter08/Table08.01.DefaultImplementedInterfaceMembers.cs @@ -92,7 +92,7 @@ namespace ProtectedAccessModifiers } // 5. - namespace ProvateAccessModifiers + namespace PrivateAccessModifiers { public interface IPerson { @@ -158,7 +158,7 @@ private protected string GetName() => } public interface IEmployee: IPerson { - int EmpoyeeId => GetName().GetHashCode(); + int EmployeeId => GetName().GetHashCode(); } public class Person : IPerson { diff --git a/src/Chapter10/Listing10.02.AddingAnOperator.cs b/src/Chapter10/Listing10.02.AddingAnOperator.cs index 7b6caba3..6d1a2e50 100644 --- a/src/Chapter10/Listing10.02.AddingAnOperator.cs +++ b/src/Chapter10/Listing10.02.AddingAnOperator.cs @@ -54,7 +54,7 @@ public Coordinate(Longitude longitude, Latitude latitude) { // There is no need to check of null in this - // case because Coordinate is a valye type. + // case because Coordinate is a value type. return (leftHandSide.Equals(rightHandSide)); } diff --git a/src/Chapter10/Listing10.04.OverloadingTheMinusAndPlusUnaryOperators.cs b/src/Chapter10/Listing10.04.OverloadingTheMinusAndPlusUnaryOperators.cs index 97fa4373..d3d0cd23 100644 --- a/src/Chapter10/Listing10.04.OverloadingTheMinusAndPlusUnaryOperators.cs +++ b/src/Chapter10/Listing10.04.OverloadingTheMinusAndPlusUnaryOperators.cs @@ -36,7 +36,7 @@ public Coordinate(Longitude longitude, Latitude latitude) { // There is no need to check of null in this - // case because Coordinate is a valye type. + // case because Coordinate is a value type. return (leftHandSide.Equals(rightHandSide)); } diff --git a/src/Chapter12/Listing12.13.InitializingAFieldWithTheDefaultOperator.cs b/src/Chapter12/Listing12.13.InitializingAFieldWithTheDefaultOperator.cs index c3cff171..6941feda 100644 --- a/src/Chapter12/Listing12.13.InitializingAFieldWithTheDefaultOperator.cs +++ b/src/Chapter12/Listing12.13.InitializingAFieldWithTheDefaultOperator.cs @@ -1,4 +1,4 @@ -// Justification: Only showing partial implementaiton. +// Justification: Only showing partial implementation. #pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter12.Listing12_13; @@ -11,7 +11,7 @@ public Pair(T first) { First = first; #region EXCLUDE - // Justifiction: Ignore warning pending struct/class constraints, later on in the chapter, + // Justification: Ignore warning pending struct/class constraints, later on in the chapter, // so that Second can be declared as T?. #pragma warning disable CS8601 // Possible null reference assignment. #endregion EXCLUDE diff --git a/src/Chapter12/Listing12.46.StackDeclaration.cs b/src/Chapter12/Listing12.46.StackDeclaration.cs index 933b1acd..beecf787 100644 --- a/src/Chapter12/Listing12.46.StackDeclaration.cs +++ b/src/Chapter12/Listing12.46.StackDeclaration.cs @@ -1,4 +1,4 @@ -// Justification: Only showing partial implementaiton. +// Justification: Only showing partial implementation. #pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter12.Listing12_46; diff --git a/src/Chapter12/Listing12.49.StackIntDefinition.cs b/src/Chapter12/Listing12.49.StackIntDefinition.cs index 2affd30e..f58e9871 100644 --- a/src/Chapter12/Listing12.49.StackIntDefinition.cs +++ b/src/Chapter12/Listing12.49.StackIntDefinition.cs @@ -1,4 +1,4 @@ -// Justification: Only showing partial implementaiton. +// Justification: Only showing partial implementation. #pragma warning disable CS0168 // Variable is declared but never used diff --git a/src/Chapter13/Listing13.18.UsingVarianceForDelegates.cs b/src/Chapter13/Listing13.18.UsingVarianceForDelegates.cs index c24bdfb3..a1d3824e 100644 --- a/src/Chapter13/Listing13.18.UsingVarianceForDelegates.cs +++ b/src/Chapter13/Listing13.18.UsingVarianceForDelegates.cs @@ -1,4 +1,4 @@ -// Justification: Left as lamda to elucidate generic types. +// Justification: Left as lambda to elucidate generic types. #pragma warning disable IDE0039 // Use local function namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_18; diff --git a/src/Chapter14/Listing14.05.InvokingADelegate.cs b/src/Chapter14/Listing14.05.InvokingADelegate.cs index ed860aea..bc75a579 100644 --- a/src/Chapter14/Listing14.05.InvokingADelegate.cs +++ b/src/Chapter14/Listing14.05.InvokingADelegate.cs @@ -17,7 +17,7 @@ public float CurrentTemperature _CurrentTemperature = value; // If there are any subscribers, // notify them of changes in - // temperature by invoking said subcribers + // temperature by invoking said subscribers #region HIGHLIGHT OnTemperatureChange?.Invoke(value); // C# 6.0 #endregion HIGHLIGHT diff --git a/src/Chapter14/Listing14.14.FiringTheEventNotification.cs b/src/Chapter14/Listing14.14.FiringTheEventNotification.cs index 37ea0fcc..eac50253 100644 --- a/src/Chapter14/Listing14.14.FiringTheEventNotification.cs +++ b/src/Chapter14/Listing14.14.FiringTheEventNotification.cs @@ -30,7 +30,7 @@ public float CurrentTemperature _CurrentTemperature = value; // If there are any subscribers, // notify them of changes in - // temperature by invoking said subcribers + // temperature by invoking said subscribers #region HIGHLIGHT OnTemperatureChange?.Invoke( this, new TemperatureArgs(value)); diff --git a/src/Chapter14/Listing14.17.CustomAddAndRemoveHandlers.cs b/src/Chapter14/Listing14.17.CustomAddAndRemoveHandlers.cs index c928053f..1d0ad82b 100644 --- a/src/Chapter14/Listing14.17.CustomAddAndRemoveHandlers.cs +++ b/src/Chapter14/Listing14.17.CustomAddAndRemoveHandlers.cs @@ -48,7 +48,7 @@ public float CurrentTemperature _CurrentTemperature = value; // If there are any subscribers, // notify them of changes in - // temperature by invoking said subcribers + // temperature by invoking said subscribers _OnTemperatureChange?.Invoke( // C# 6.0 this, new TemperatureArgs(value)); } diff --git a/src/Chapter17/Listing17.10.ChangingTheIndexersDefaultName.cs b/src/Chapter17/Listing17.10.ChangingTheIndexersDefaultName.cs index 90b9b50f..2cd5b948 100644 --- a/src/Chapter17/Listing17.10.ChangingTheIndexersDefaultName.cs +++ b/src/Chapter17/Listing17.10.ChangingTheIndexersDefaultName.cs @@ -31,9 +31,9 @@ public Pair(T first, T second) Second = second; } - public T First { get; } // C# 6.0 Getter-Only Autoproperty + public T First { get; } // C# 6.0 Getter-Only AutoProperty - public T Second { get; } // C# 6.0 Getter-Only Autoproperty + public T Second { get; } // C# 6.0 Getter-Only AutoProperty #region INCLUDE [System.Runtime.CompilerServices.IndexerName("Entry")] public T this[PairItem index] diff --git a/src/Chapter17/Listing17.15.UsingPair.GetEnumeratorViaForeach.cs b/src/Chapter17/Listing17.15.UsingPair.GetEnumeratorViaForeach.cs index 375d0973..f743547a 100644 --- a/src/Chapter17/Listing17.15.UsingPair.GetEnumeratorViaForeach.cs +++ b/src/Chapter17/Listing17.15.UsingPair.GetEnumeratorViaForeach.cs @@ -8,8 +8,8 @@ public class Program public static void Main() { #region INCLUDE - var fullname = new Pair("Inigo", "Montoya"); - foreach(string name in fullname) + var fullName = new Pair("Inigo", "Montoya"); + foreach(string name in fullName) { Console.WriteLine(name); } diff --git a/src/Chapter17/Listing17.16.PlacingYieldReturnStatementsWithinALoop.cs b/src/Chapter17/Listing17.16.PlacingYieldReturnStatementsWithinALoop.cs index 07c7047a..825d9842 100644 --- a/src/Chapter17/Listing17.16.PlacingYieldReturnStatementsWithinALoop.cs +++ b/src/Chapter17/Listing17.16.PlacingYieldReturnStatementsWithinALoop.cs @@ -45,7 +45,7 @@ public IEnumerator GetEnumerator() } #endregion #region EXCLUDE - public T Value { get; } // C# 6.0 Getter-only Autoproperty + public T Value { get; } // C# 6.0 Getter-only AutoProperty public Pair> SubItems { get; set; } #endregion EXCLUDE diff --git a/src/Chapter18/Listing18.09.DecoratingAPropertyWithMultipleAttributes.cs b/src/Chapter18/Listing18.09.DecoratingAPropertyWithMultipleAttributes.cs index cfd38a55..f0a795be 100644 --- a/src/Chapter18/Listing18.09.DecoratingAPropertyWithMultipleAttributes.cs +++ b/src/Chapter18/Listing18.09.DecoratingAPropertyWithMultipleAttributes.cs @@ -23,13 +23,13 @@ public System.Diagnostics.ProcessPriorityClass Priority #pragma warning disable CA1018 // Mark attributes with AttributeUsageAttribute internal class CommandLineSwitchRequiredAttribute : Attribute { - //not implimented + //not implemented } internal class CommandLineSwitchAliasAttribute : Attribute { public CommandLineSwitchAliasAttribute(string _) { - //not implimented + //not implemented } } diff --git a/src/Chapter18/Listing18.23.UsingFlagsAttribute.cs b/src/Chapter18/Listing18.23.UsingFlagsAttribute.cs index 15afe8c2..267a8a57 100644 --- a/src/Chapter18/Listing18.23.UsingFlagsAttribute.cs +++ b/src/Chapter18/Listing18.23.UsingFlagsAttribute.cs @@ -3,7 +3,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter18.Listing18_23; #region INCLUDE /* [Flags] -public enun FileAttributes +public enum FileAttributes { ReadOnly = 0x0001, Hidden = 0x0002, diff --git a/src/Chapter20/Listing20.16.IteratingOverAwaitOperation.cs b/src/Chapter20/Listing20.16.IteratingOverAwaitOperation.cs index 00e78ea1..13286545 100644 --- a/src/Chapter20/Listing20.16.IteratingOverAwaitOperation.cs +++ b/src/Chapter20/Listing20.16.IteratingOverAwaitOperation.cs @@ -18,7 +18,7 @@ private async void PingButton_Click( "www.partnersintl.org", "www.iassist.org", "www.fh.org", - "www.worldvision.org" + "www.worldVision.org" }; IPStatus status; diff --git a/src/Chapter21/Listing21.10.CancelingParallelLoop.cs b/src/Chapter21/Listing21.10.CancelingParallelLoop.cs index c45b14dd..621061c8 100644 --- a/src/Chapter21/Listing21.10.CancelingParallelLoop.cs +++ b/src/Chapter21/Listing21.10.CancelingParallelLoop.cs @@ -14,17 +14,17 @@ public static List ParallelEncrypt( List data, CancellationToken cancellationToken) { - int govener = 0; + int governor = 0; return data.AsParallel().WithCancellation( cancellationToken).Select( (item) => { if (Interlocked.CompareExchange( - ref govener, 0, 100) % 100 == 0) + ref governor, 0, 100) % 100 == 0) { Console.Write('.'); } - Interlocked.Increment(ref govener); + Interlocked.Increment(ref governor); return Encrypt(item); }).ToList(); } diff --git a/src/Chapter22/Listing22.08.ThreadSafeEventNotification.cs b/src/Chapter22/Listing22.08.ThreadSafeEventNotification.cs index 71033212..f4551c0d 100644 --- a/src/Chapter22/Listing22.08.ThreadSafeEventNotification.cs +++ b/src/Chapter22/Listing22.08.ThreadSafeEventNotification.cs @@ -28,7 +28,7 @@ public void Main() #endif } - // Justification: Lowercase to simulate the value keyword form a stetter. + // Justification: Lowercase to simulate the value keyword form a setter. #pragma warning disable IDE1006 // Naming Styles public object? value { get; set; } #pragma warning restore IDE1006 // Naming Styles diff --git a/src/Shared/Cryptographer.cs b/src/Shared/Cryptographer.cs index 1c26cd55..82d315dc 100644 --- a/src/Shared/Cryptographer.cs +++ b/src/Shared/Cryptographer.cs @@ -10,9 +10,9 @@ public class Cryptographer : IDisposable #endregion PROPERTIES #region CONSTRUCTORS - public Cryptographer(SymmetricAlgorithm cryptoAlgoritym) + public Cryptographer(SymmetricAlgorithm cryptoAlgorithm) { - CryptoAlgorithm = cryptoAlgoritym; + CryptoAlgorithm = cryptoAlgorithm; } public Cryptographer() diff --git a/src/Shared/Program.cs b/src/Shared/Program.cs index f34a0e29..2f04ec4e 100644 --- a/src/Shared/Program.cs +++ b/src/Shared/Program.cs @@ -140,7 +140,7 @@ public static async Task Main(string[] args) public static async ValueTask InvokeMethodUsingReflectionAsync(MethodInfo method, string[]? arguments) { - // Note: 'arguments' here are the array of commandline args, so + // Note: 'arguments' here are the array of commandLine args, so // it is the first item in the "parameters" array specified to the // Invoke method. object? result = method.Invoke(null,