mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Enable nullable ref types in common library
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Games.Common.IO;
|
||||
|
||||
public class InsufficientInputException : Exception
|
||||
{
|
||||
public InsufficientInputException()
|
||||
: base("Insufficient input was supplied")
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user