Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase ResolvingNullabilityUpdates onto V8 #91

Merged
merged 13 commits into from
Aug 31, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<Project>
<PropertyGroup>
<CSharp8Nullable Condition=" '$(CSharp8Nullable)' == ''">disable</CSharp8Nullable>
<NullableContextOptions>$(CSharp8Nullable)</NullableContextOptions>
<TreatWarningsAsErrors>$(TreatWarningsAsErrors)</TreatWarningsAsErrors>
<Nullable Condition="'$(Nullable)'==''">disable</Nullable>
<TreatWarningsAsErrors Condition="'$(TreatWarningsAsErrors)'==''">true</TreatWarningsAsErrors>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Authors>Mark Michaelis</Authors>
<Company>Addison Wesley</Company>
<Copyright>Copyright © Addison Wesley 2003</Copyright>
</PropertyGroup>
</Project>
4 changes: 4 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project>
<PropertyGroup>
<NoWarn Condition="'$(IgnoreExpectedWarnings)'!=''">$(ExpectedWarnings)</NoWarn>
<WarningsNotAsErrors>$(ExpectedWarnings)</WarningsNotAsErrors>
</PropertyGroup>
<Target Name="VSTestIfTestProject">
<CallTarget Targets="VSTest" Condition="'$(IsTestProject)' == 'true'" />
</Target>
Expand Down
5 changes: 3 additions & 2 deletions RenumberListings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Function PadNumber {
[string]$number
)

# Should use string.PadLeft(2, '0') instead.
if($number -match '(?<Number>\d?\d)(?<Suffix>.*)') {
return "{0:D2}$($Matches.Suffix)" -f ([int]$Matches.Number)
}
Expand Down Expand Up @@ -199,7 +200,7 @@ Function Update-CodeListingSequence {
$NewChapterNumber = $NewChapterNumber.PadLeft(2, '0')

if(!$listingNumber) {
$ListingNumber = Get-Item (Join-Path (Join-Path $PSScriptRoot "Chapter$ChapterNumber") "Listing$ChapterNumber.*cs") | Select -ExpandProperty Name |
$ListingNumber = Get-Item (Join-Path (Join-Path $PSScriptRoot 'src' "Chapter$ChapterNumber") "Listing$ChapterNumber.*cs") | Select-Object -ExpandProperty Name |
ForEach-Object{
if($_ -match "Listing$ChapterNumber\.(?<Listing>\d\d)(?<Suffix>.*)") {
Write-Output $Matches.Listing
Expand Down Expand Up @@ -282,7 +283,7 @@ Function Update-CodeListingSequence {
# $oldFilePathPattern = (Join-Path (Join-Path $PSScriptRoot "Chapter$ChapterNumber") "Listing$ChapterNumber.$eachListingNumber*.cs")
#}
#else {
$oldFilePathPattern = (Join-Path (Join-Path $PSScriptRoot "Chapter$ChapterNumber") "Listing$(if($IsIntermediateName.IsPresent){"$ChapterNumber"}else{"$NewChapterNumber.TEMP"}).$eachListingNumber*.cs")
$oldFilePathPattern = (Join-Path (Join-Path $PSScriptRoot 'src' "Chapter$ChapterNumber") "Listing$(if($IsIntermediateName.IsPresent){"$ChapterNumber"}else{"$NewChapterNumber.TEMP"}).$eachListingNumber*.cs")
#}

$files = @(Get-Item $oldFilePathPattern)
Expand Down
6 changes: 6 additions & 0 deletions src/Chapter.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<StartupObject>AddisonWesley.Michaelis.EssentialCSharp.Shared.Program</StartupObject>
</PropertyGroup>
</Project>
19 changes: 3 additions & 16 deletions src/Chapter01.Tests/Chapter01.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PropertyGroup>
<ProductName>Chapter01.Tests</ProductName>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\ChapterTests.targets" />
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0-preview-20190606-02" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0-beta4" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0-beta4" />
</ItemGroup>
<Import Project="..\ChapterTests.props" />
<ItemGroup>
<ProjectReference Include="..\Chapter01\Chapter01.csproj" />
</ItemGroup>

</Project>
</Project>
9 changes: 2 additions & 7 deletions src/Chapter01/Chapter01.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProductName>Chapter01</ProductName>
<StartupObject>AddisonWesley.Michaelis.EssentialCSharp.Shared.Program</StartupObject>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\Chapter.props" />
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<Compile Include="..\Shared\Program.cs">
<Link>Program.cs</Link>
</Compile>
</ItemGroup>
</Project>
</Project>
48 changes: 0 additions & 48 deletions src/Chapter01/Chapter01.sln

This file was deleted.

17 changes: 2 additions & 15 deletions src/Chapter02.Tests/Chapter02.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProductName>Chapter02.Tests</ProductName>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\ChapterTests.targets" />
<Import Project="..\ChapterTests.props" />
<ItemGroup>
<Compile Include="..\Shared\NetCore.cs" Link="NetCore.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0-preview-20190606-02" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0-beta4" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0-beta4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Chapter02\Chapter02.csproj" />
</ItemGroup>
</Project>
</Project>
9 changes: 2 additions & 7 deletions src/Chapter02/Chapter02.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProductName>Chapter02</ProductName>
<StartupObject>AddisonWesley.Michaelis.EssentialCSharp.Shared.Program</StartupObject>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\Chapter.props" />
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<Compile Include="..\Shared\Program.cs">
<Link>Program.cs</Link>
</Compile>
</ItemGroup>
</Project>
</Project>
17 changes: 2 additions & 15 deletions src/Chapter03.Tests/Chapter03.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProductName>Chapter03.Tests</ProductName>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\ChapterTests.targets" />
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0-preview-20190606-02" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0-beta4" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0-beta4" />
</ItemGroup>
<Import Project="..\ChapterTests.props" />
<ItemGroup>
<ProjectReference Include="..\Chapter03\Chapter03.csproj" />
</ItemGroup>
</Project>
</Project>
12 changes: 5 additions & 7 deletions src/Chapter03/Chapter03.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProductName>Chapter03</ProductName>
<StartupObject>AddisonWesley.Michaelis.EssentialCSharp.Shared.Program</StartupObject>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\Chapter.props" />
<ItemGroup>
<Compile Remove="Listing03.01B.DereferencingAnUnassignedVariable.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\Program.cs">
<Link>Program.cs</Link>
</Compile>
</ItemGroup>
</Project>
</Project>
23 changes: 23 additions & 0 deletions src/Chapter03/Listing03.01.CheckingForNull.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Listing03_01
{
public class Program
{
public static void Main()
{
int? number = null;
// ...
if (number is null)
{
System.Console.WriteLine(
$"{ nameof(number) } requires a value and cannot be null");
}
else
{
System.Console.WriteLine(
$"{ nameof(number) } is of type { number.GetType() }.");
}

}
}
}

15 changes: 0 additions & 15 deletions src/Chapter03/Listing03.01.UsingTheNullableModifier.cs

This file was deleted.

13 changes: 13 additions & 0 deletions src/Chapter03/Listing03.01B.DereferencingAnUnassignedVariable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Listing03_01B
{
public class Program
{
public static void Main()
{
string? text;
// ...
// Compile Error: Use of unassigned local variable 'text'
// System.Console.WriteLine(text.length);
}
}
}
17 changes: 2 additions & 15 deletions src/Chapter04.Tests/Chapter04.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProductName>Chapter04.Tests</ProductName>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\ChapterTests.targets" />
<Import Project="..\ChapterTests.props" />
<ItemGroup>
<Compile Include="..\Shared\NetCore.cs" Link="NetCore.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0-preview-20190606-02" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0-beta4" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0-beta4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Chapter04\Chapter04.csproj" />
</ItemGroup>
</Project>
</Project>
13 changes: 4 additions & 9 deletions src/Chapter04/Chapter04.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProductName>Chapter04</ProductName>
<StartupObject>AddisonWesley.Michaelis.EssentialCSharp.Shared.Program</StartupObject>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<WarningsNotAsErrors>1030</WarningsNotAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(IgnoreExpectedWarnings)'=='true'">
<NoWarn>1030</NoWarn>
<PropertyGroup>
<!-- CS1030 results from an explicit #warning preprocessor command -->
<ExpectedWarnings>1030</ExpectedWarnings>
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\Chapter.props" />
<ItemGroup>
<Compile Include="..\Shared\Program.cs">
<Link>Program.cs</Link>
Expand Down
17 changes: 2 additions & 15 deletions src/Chapter05.Tests/Chapter05.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProductName>Chapter05.Tests</ProductName>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<Import Project="..\Versioning.targets" />
<Import Project="..\ChapterTests.targets" />
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0-preview-20190606-02" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0-beta4" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0-beta4" />
</ItemGroup>
<Import Project="..\ChapterTests.props" />
<ItemGroup>
<ProjectReference Include="..\Chapter05\Chapter05.csproj" />
</ItemGroup>
Expand All @@ -30,4 +17,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Compile>
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Main_GoodArgs_DownloadFile()
{
Assert.AreEqual(0, Program.Main(args));
}
catch (AggregateException exception) when(exception.InnerException?.GetType() == typeof(System.Net.Http.HttpRequestException))
catch (AggregateException exception) when (exception.InnerException!.GetType() == typeof(System.Net.Http.HttpRequestException))
{
Assert.Inconclusive("Unable to download the file. Check your Internet connection.");
}
Expand Down
Loading