Attempt to ignore possible null warnings in chapters 1-2
Ignore because topic isn't introduced until 4.36
MODIFY
src/Chapter01/Chapter01.csproj
src/Chapter01/Chapter01.csproj
<!-- CA1052: Suggest Program is static which hasn't been explained yet. -->
<!-- IDE0059: Unnecessary assignment of a value ignored since listing is not complete. -->
<!-- IDE0060: Remove unused parameter suggestion ignored since listing is not complete -->
- <ExpectedWarnings>$(ExpectedWarnings),CA1052,IDE0059,IDE0060</ExpectedWarnings>
+ <ExpectedWarnings>$(ExpectedWarnings),CS8600,CS8602,CA1052,IDE0059,IDE0060</ExpectedWarnings>
</PropertyGroup>
<Import Project="..\Chapter.props" />
<ItemGroup>

MODIFY
src/Chapter02/Chapter02.csproj
src/Chapter02/Chapter02.csproj
<!-- CA1052: Suggest Program is static which hasn't been explained yet. -->
<!-- IDE0059: Unnecessary assignment of a value ignored since listing is not complete. -->
<!-- IDE0054: Use compound assignment because '+=" is not yet explained-->
- <ExpectedWarnings>$(ExpectedWarnings),CA1052,IDE0059,IDE0054</ExpectedWarnings>
+ <ExpectedWarnings>$(ExpectedWarnings),CS8600,CS8602,CS8604,CA1052,IDE0059,IDE0054</ExpectedWarnings>
</PropertyGroup>
<Import Project="..\Chapter.props" />
<ItemGroup>

MODIFY
src/Shared/Program.cs
src/Shared/Program.cs
@@ -21,14 +21,14 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Shared
{
throw new InvalidOperationException("Unable to retrieve the EntryAssembly.");
}
- string regexMatch = Regex.Match(assembly.GetName().Name, "\\d{1,2}").Value;
+ string regexMatch = Regex.Match(assembly.GetName().Name!, "\\d{1,2}").Value;
int chapterNumber = int.Parse(regexMatch);
if (args.Length == 0)
{
Console.Write(
$"Enter the listing number to execute (e.g. For Listing {chapterNumber}.1 enter \"{chapterNumber}.1\"): ");
- input = Console.ReadLine();
+ input = Console.ReadLine() ?? string.Empty;
}
else
{
@@ -228,7 +228,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Shared
Console.WriteLine();
Console.WriteLine(
"Listing uses arguments for main method provided by user. Please see the listing and enter arguments or hit enter to pass in null: ");
- string userArguments = Console.ReadLine();
+ string? userArguments = Console.ReadLine();
Console.WriteLine();
Console.WriteLine();

Attempt to ignore possible null warnings in chapters 1-2

Ignore because topic isn't introduced until 4.36