Use CompileAssert to verify error behavior.
MODIFY
src/Chapter06.Tests/Chapter06.Tests.csproj
src/Chapter06.Tests/Chapter06.Tests.csproj
<ChapterNumber>06</ChapterNumber>
</PropertyGroup>
<Import Project="..\ChapterTests.props" />
+ <ItemGroup>
+ <Compile Include="..\Shared\CompilerAssert.cs" Link="CompilerAssert.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.4.0" />
+ </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Chapter06\Chapter06.csproj" />
</ItemGroup>

MODIFY
src/Chapter06/Chapter06.csproj
src/Chapter06/Chapter06.csproj
</PropertyGroup>
<Import Project="..\Chapter.props" />
<ItemGroup>
+ <Compile Remove="Listing06.15.UsingThePrivateAccessModifier.cs" />
+ <Compile Remove="Listing06.21.DefiningReadOnlyProperties.cs" />
+ <Compile Remove="Listing06.23.PlacingAccessModifiersOnSetters.cs" />
<Compile Remove="Listing06.24.CILCodeResultingFromProperties.cs" />
<Compile Remove="Listing06.25.PropertiesAreAnExplicitConstructInCIL.cs" />
</ItemGroup>
</Compile>
</ItemGroup>
<ItemGroup>
+ <None Include="Listing06.15.UsingThePrivateAccessModifier.cs">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Listing06.21.DefiningReadOnlyProperties.cs">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Listing06.23.PlacingAccessModifiersOnSetters.cs">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
<None Include="Listing06.24.CILCodeResultingFromProperties.cs" />
<None Include="Listing06.25.PropertiesAreAnExplicitConstructInCIL.cs" />
</ItemGroup>

MODIFY
src/Chapter06/Listing06.15.UsingThePrivateAccessModifier.cs
src/Chapter06/Listing06.15.UsingThePrivateAccessModifier.cs
// Add readonly modifier ignored pending introduction of the concept
#pragma warning disable IDE0044
+using System;
-namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_15
-{
+//namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_15
+//{
#region INCLUDE
public class Employee
{
@@ -54,13 +55,13 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_15
// ...
#region HIGHLIGHT
- // Password is private, so it cannot be
+ // ERROR: Password is private, so it cannot be
// accessed from outside the class
- // Console.WriteLine(
- // ("Password = {0}", employee.Password);
+ Console.WriteLine(
+ "Password = {0}", employee.Password);
#endregion HIGHLIGHT
}
// ...
}
#endregion INCLUDE
-}
+//}

Use CompileAssert to verify error behavior.