Enable nullable ref types in common library

This commit is contained in:
Andrew Cooper
2022-04-15 21:30:16 +10:00
parent 235e6484de
commit 01492a697f
4 changed files with 15 additions and 3 deletions

View File

@@ -1,7 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,9 @@
namespace Games.Common.IO;
public class InsufficientInputException : Exception
{
public InsufficientInputException()
: base("Insufficient input was supplied")
{
}
}

View File

@@ -93,7 +93,7 @@ public class TextIO : IReadWrite
internal string ReadLine(string prompt)
{
Write(prompt + "? ");
return _input.ReadLine();
return _input.ReadLine() ?? throw new InsufficientInputException();
}
public void Write(string value) => _output.Write(value);

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>