Added a Listing 01.01A as a top level statement.
MODIFY
src/Chapter01.Tests/Chapter01.Tests.csproj
src/Chapter01.Tests/Chapter01.Tests.csproj
<ChapterNumber>01</ChapterNumber>
</PropertyGroup>
<Import Project="..\ChapterTests.props" />
+ <ItemGroup>
+ <Compile Include="..\Shared\Tests\PowerShellTestUtilities.cs" Link="PowerShellTestUtilities.cs" />
+ </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Chapter01\Chapter01.csproj" />
</ItemGroup>

RENAME
src/Chapter01.Tests/Listing01.01.Tests.cs
src/Chapter01.Tests/Listing01.01B.Tests.cs
MODIFY
src/Chapter01/Chapter01.csproj
src/Chapter01/Chapter01.csproj
<!-- CS8600: Trust that null assignment doesn't cause
unexpected exception as concept to check for null hasn't been explained yet-->
<IgnoredWarnings>$(IgnoredWarnings),CS8600,CA1052,IDE0059,IDE0060</IgnoredWarnings>
+ <StartupObject>AddisonWesley.Michaelis.EssentialCSharp.Shared.Program</StartupObject>
</PropertyGroup>
<Import Project="..\Chapter.props" />
<ItemGroup>

MODIFY
src/Chapter01/Listing01.01.HelloWorldInC#.ps1
src/Chapter01/Listing01.01.HelloWorldInC#.ps1
param(
[int]$traceLevel
)
-if($traceLevel -notin $PSBoundParameters.Keys) {
+
+if('traceLevel' -notin $PSBoundParameters.Keys) {
$traceLevel = Read-Host -Prompt @"
Specifiy the trace level:
- 0: Turn script tracing off.
@@ -35,7 +36,11 @@ class HelloWorld
$codeListing > Program.cs
Get-Content Program.cs
- dotnet run
+
+ Write-Warning "Remove dotnet build step once we upgrade to version 10"
+ # Build with version 10 because dotnet version 6 defaults to an ImplicitUsings element in the project file.
+ dotnet build /property:LangVersion=10
+ dotnet run --no-build
}
finally {
Set-PSDebug -Off

MODIFY
src/Shared/Program.cs
src/Shared/Program.cs
@@ -45,6 +45,15 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Shared
{
input = ParseListingName(input);
+ // We handle listing 1.1 specially since the listing is a top level statement and
+ // the file (Listing01.01.HelloWorldInC#.cs) is set to not build as part of the project.
+ if(input == "01_01")
+ {
+ throw new InvalidOperationException(
+ "This listing (HelloWorld) is left as an exercise for the reader on the command line. ");
+ }
+
+
Regex reg = new Regex($"Listing{input}\\.+");
IEnumerable<Type?> targets = assembly.GetTypes().Where(type =>

Added a Listing 01.01A as a top level statement.