mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +08:00
Fix issues with nullability and netstandard2.0
This commit is contained in:

committed by
Patrik Svensson

parent
7dce4af552
commit
a70cc90797
@ -4,14 +4,20 @@ internal static class TypeConverterHelper
|
||||
{
|
||||
public static string ConvertToString<T>(T input)
|
||||
{
|
||||
return GetTypeConverter<T>().ConvertToInvariantString(input);
|
||||
var result = GetTypeConverter<T>().ConvertToInvariantString(input);
|
||||
if (result == null)
|
||||
{
|
||||
throw new InvalidOperationException("Could not convert input to a string");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool TryConvertFromString<T>(string input, [MaybeNull] out T result)
|
||||
public static bool TryConvertFromString<T>(string input, [MaybeNull] out T? result)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = (T)GetTypeConverter<T>().ConvertFromInvariantString(input);
|
||||
result = (T?)GetTypeConverter<T>().ConvertFromInvariantString(input);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
@ -21,7 +27,7 @@ internal static class TypeConverterHelper
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryConvertFromStringWithCulture<T>(string input, CultureInfo? info, [MaybeNull] out T result)
|
||||
public static bool TryConvertFromStringWithCulture<T>(string input, CultureInfo? info, [MaybeNull] out T? result)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -31,7 +37,7 @@ internal static class TypeConverterHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (T)GetTypeConverter<T>().ConvertFromString(null!, info, input);
|
||||
result = (T?)GetTypeConverter<T>().ConvertFromString(null!, info, input);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -17,22 +17,25 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Memory" Version="4.5.5" />
|
||||
<PackageReference Include="Wcwidth.Sources" Version="1.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<AnnotatedReferenceAssemblyVersion>3.0.0</AnnotatedReferenceAssemblyVersion>
|
||||
<GenerateNullableAttributes>False</GenerateNullableAttributes>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" PrivateAssets="all" />
|
||||
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(AnnotatedReferenceAssemblyVersion)]" />
|
||||
<PackageReference Include="Nullable" Version="1.3.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Wcwidth.Sources" Version="1.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<AnnotatedReferenceAssemblyVersion>3.0.0</AnnotatedReferenceAssemblyVersion>
|
||||
<GenerateNullableAttributes>False</GenerateNullableAttributes>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants>$(DefineConstants)TRACE;WCWIDTH_VISIBILITY_INTERNAL</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
@ -5,14 +5,20 @@ internal static class FigletFontParser
|
||||
public static FigletFont Parse(string source)
|
||||
{
|
||||
var lines = source.SplitLines();
|
||||
var header = ParseHeader(lines.FirstOrDefault());
|
||||
|
||||
var characters = new List<FigletCharacter>();
|
||||
var headerLine = lines.FirstOrDefault();
|
||||
if (headerLine == null)
|
||||
{
|
||||
throw new InvalidOperationException("Could not read header line");
|
||||
}
|
||||
|
||||
var header = ParseHeader(headerLine);
|
||||
|
||||
var index = 32;
|
||||
var indexOverridden = false;
|
||||
var hasOverriddenIndex = false;
|
||||
var buffer = new List<string>();
|
||||
var characters = new List<FigletCharacter>();
|
||||
|
||||
foreach (var line in lines.Skip(header.CommentLines + 1))
|
||||
{
|
||||
|
@ -107,8 +107,7 @@ public sealed class TableRowCollection : IReadOnlyList<TableRow>
|
||||
throw new IndexOutOfRangeException("Table row index cannot exceed the number of rows in the table.");
|
||||
}
|
||||
|
||||
var tableRow = _list.ElementAtOrDefault(row);
|
||||
|
||||
var tableRow = _list.ElementAt(row);
|
||||
var currentRenderables = tableRow.ToList();
|
||||
|
||||
if (column < 0)
|
||||
|
Reference in New Issue
Block a user