Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions csharp/Platform.Reflection.Tests/NumericTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,23 @@ public void UInt64IsNumericTest()
{
Assert.True(NumericType<ulong>.IsNumeric);
}

[Fact]
public void NullableIntCanBeNumericTest()
{
Assert.True(NumericType<int?>.CanBeNumeric);
}

[Fact]
public void NullableDoubleCanBeNumericTest()
{
Assert.True(NumericType<double?>.CanBeNumeric);
}

[Fact]
public void NullableBoolCanBeNumericTest()
{
Assert.True(NumericType<bool?>.CanBeNumeric);
}
}
}
22 changes: 22 additions & 0 deletions csharp/experiments/NullableTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using Platform.Reflection;

class Program
{
static void Main()
{
Console.WriteLine($"int? CanBeNumeric: {NumericType<int?>.CanBeNumeric}");
Console.WriteLine($"int? IsNumeric: {NumericType<int?>.IsNumeric}");
Console.WriteLine($"int? IsNullable: {NumericType<int?>.IsNullable}");
Console.WriteLine($"int? UnderlyingType: {NumericType<int?>.UnderlyingType}");

Console.WriteLine($"double? CanBeNumeric: {NumericType<double?>.CanBeNumeric}");
Console.WriteLine($"double? IsNumeric: {NumericType<double?>.IsNumeric}");

Console.WriteLine($"bool? CanBeNumeric: {NumericType<bool?>.CanBeNumeric}");
Console.WriteLine($"bool? IsNumeric: {NumericType<bool?>.IsNumeric}");

Console.WriteLine($"string? CanBeNumeric: {NumericType<string?>.CanBeNumeric}");
Console.WriteLine($"string? IsNumeric: {NumericType<string?>.IsNumeric}");
}
}
14 changes: 14 additions & 0 deletions csharp/experiments/NullableTypeTest/NullableTypeTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\Platform.Reflection\Platform.Reflection.csproj" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
16 changes: 16 additions & 0 deletions csharp/experiments/NullableTypeTest/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using Platform.Reflection;

Console.WriteLine($"int? CanBeNumeric: {NumericType<int?>.CanBeNumeric}");
Console.WriteLine($"int? IsNumeric: {NumericType<int?>.IsNumeric}");
Console.WriteLine($"int? IsNullable: {NumericType<int?>.IsNullable}");
Console.WriteLine($"int? UnderlyingType: {NumericType<int?>.UnderlyingType}");

Console.WriteLine($"double? CanBeNumeric: {NumericType<double?>.CanBeNumeric}");
Console.WriteLine($"double? IsNumeric: {NumericType<double?>.IsNumeric}");

Console.WriteLine($"bool? CanBeNumeric: {NumericType<bool?>.CanBeNumeric}");
Console.WriteLine($"bool? IsNumeric: {NumericType<bool?>.IsNumeric}");

Console.WriteLine($"string? CanBeNumeric: {NumericType<string?>.CanBeNumeric}");
Console.WriteLine($"string? IsNumeric: {NumericType<string?>.IsNumeric}");
Loading