Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed May 19, 2022
1 parent 2782904 commit 0e4aa38
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<Optimize>False</Optimize>
<Nullable>enable</Nullable>
Expand All @@ -13,6 +13,9 @@
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="ILCompose" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<packagereference Include="NUnit3TestAdapter" Version="4.2.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
22 changes: 11 additions & 11 deletions tests/IL2C.Core.Test.BasicTypes/System_Delegate/System_Delegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static int Remove_DelegateInstance(int value)

// Remove only a tail delegate.
// (dlg1 + dlg2 + dlg1) - dlg1 = (dlg1 + dlg2)
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlg1);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlg1);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -66,7 +66,7 @@ public static int Remove_DelegateTarget(int value)

// Remove only a tail delegate.
// (dlg1 + dlg2 + dlg3[=dlg1]) - dlg1 = (dlg1 + dlg2)
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlg1);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlg1);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -85,7 +85,7 @@ public static int Remove_DelegateMiddle(int value)
dlgA += dlg3;

// (dlg1 + dlg2 + dlg3) - dlg2 = (dlg1 + dlg3)
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlg2);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlg2);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -104,7 +104,7 @@ public static int Remove_DelegateHead(int value)
dlgA += dlg3;

// (dlg1 + dlg2 + dlg3) - dlg1 = (dlg2 + dlg3)
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlg1);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlg1);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -124,7 +124,7 @@ public static int Remove_NotContainsDelegate(int value)
dlgA += dlg3;

// (dlg1 + dlg2 + dlg3) - dlg4 = (dlg1 + dlg2 + dlg3)
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlg4);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlg4);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -138,7 +138,7 @@ public static int Remove_FromNullToDelegate(int value)
var dlg1 = new IntRefDelegate(IntRefImpl1);

// null - dlg1 = null
var dlg = (IntRefDelegate)Delegate.Remove(null, dlg1);
var dlg = (IntRefDelegate?)Delegate.Remove(null, dlg1);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -159,7 +159,7 @@ public static int Remove_ToMulticastDelegate1(int value)
var dlgB = dlg1 + dlg2;

// (dlg1 + dlg2 + dlg3) - (dlg1 + dlg2) = dlg3
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlgB);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlgB);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -180,7 +180,7 @@ public static int Remove_ToMulticastDelegate2(int value)
var dlgB = dlg2 + dlg3;

// (dlg1 + dlg2 + dlg3) - (dlg2 + dlg3) = dlg1
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlgB);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlgB);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -201,7 +201,7 @@ public static int Remove_NotContainsMulticastDelegate(int value)
var dlgB = dlg2 + dlg1;

// (dlg1 + dlg2 + dlg3) - (dlg2 + dlg1) = (dlg1 + dlg2 + dlg3)
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlgB);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlgB);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -223,7 +223,7 @@ public static int Remove_EntireMatchedMulticastDelegate(int value)
dlgB += dlg3;

// (dlg1 + dlg2 + dlg3) - (dlg1 + dlg2 + dlg3) = null
var dlg = (IntRefDelegate)Delegate.Remove(dlgA, dlgB);
var dlg = (IntRefDelegate?)Delegate.Remove(dlgA, dlgB);

var v = value;
dlg?.Invoke(ref v);
Expand All @@ -240,7 +240,7 @@ public static int Remove_FromNullToMulticastDelegate(int value)
var dlgA = dlg1 + dlg2;

// null - (dlg1 + dlg2) = null
var dlg = (IntRefDelegate)Delegate.Remove(null, dlgA);
var dlg = (IntRefDelegate?)Delegate.Remove(null, dlgA);

var v = value;
dlg?.Invoke(ref v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class Format11_CustomProducer

public sealed class Format12_CustomProducer : IFormattable
{
public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
switch (format)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class Format21_CustomProducer

public sealed class Format22_CustomProducer : IFormattable
{
public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
switch (format)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class Format31_CustomProducer

public sealed class Format32_CustomProducer : IFormattable
{
public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
switch (format)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class Format41_CustomProducer

public sealed class Format42_CustomProducer : IFormattable
{
public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
switch (format)
{
Expand Down
8 changes: 4 additions & 4 deletions tests/IL2C.Core.Test.BasicTypes/System_Type/System_Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ public static string ToString(object value)
[TestCase("System.String", "FullName", "ABC")]
public static string FullName(object value)
{
return value.GetType().FullName;
return value.GetType().FullName!;
}

[TestCase("System.ValueType", "BaseType", 123)]
[TestCase("System.Object", "BaseType", "ABC")]
public static string BaseType(object value)
{
return value.GetType().BaseType.FullName;
return value.GetType().BaseType!.FullName!;
}

[TestCase(null, "Object_BaseType")]
public static Type Object_BaseType()
public static Type? Object_BaseType()
{
// TODO: We have to handle GetTypeFromHandle.
//return typeof(object).BaseType;
return 123.GetType().BaseType.BaseType.BaseType;
return 123.GetType().BaseType!.BaseType!.BaseType;
}
}
}
4 changes: 2 additions & 2 deletions tests/IL2C.Core.Test.Common/IL2C.Core.Test.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<Nullable>enable</Nullable>

<AssemblyName>IL2C.Core.Test.Common</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions tests/IL2C.Core.Test.Fixture/IL2C.Core.Test.Fixture.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.ILVerification" Version="5.0.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<packagereference Include="NUnit3TestAdapter" Version="3.17.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<packagereference Include="NUnit3TestAdapter" Version="4.2.1" PrivateAssets="All" />
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
Expand Down
30 changes: 15 additions & 15 deletions tests/IL2C.Core.Test.ILConverters/Box/Box.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed class Box
[TestCase("124", new[] { "Byte", "Box_Byte" }, 123)]
public static string Byte(byte value)
{
return Box_Byte((byte)(value + 1)).ToString();
return Box_Byte((byte)(value + 1)).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -40,7 +40,7 @@ public static string Byte(byte value)
[TestCase("12346", new[] { "Int16", "Box_Int16" }, 12345)]
public static string Int16(short value)
{
return Box_Int16((short)(value + 1)).ToString();
return Box_Int16((short)(value + 1)).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -49,7 +49,7 @@ public static string Int16(short value)
[TestCase("1234568", new[] { "Int32", "Box_Int32" }, 1234567)]
public static string Int32(int value)
{
return Box_Int32(value + 1).ToString();
return Box_Int32(value + 1).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -58,7 +58,7 @@ public static string Int32(int value)
[TestCase("12345678901235", new[] { "Int64", "Box_Int64" }, 12345678901234)]
public static string Int64(long value)
{
return Box_Int64(value + 1).ToString();
return Box_Int64(value + 1).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -67,7 +67,7 @@ public static string Int64(long value)
[TestCase("124", new[] { "SByte", "Box_SByte" }, 123)]
public static string SByte(sbyte value)
{
return Box_SByte((sbyte)(value + 1)).ToString();
return Box_SByte((sbyte)(value + 1)).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -76,7 +76,7 @@ public static string SByte(sbyte value)
[TestCase("12346", new[] { "UInt16", "Box_UInt16" }, 12345)]
public static string UInt16(ushort value)
{
return Box_UInt16((ushort)(value + 1)).ToString();
return Box_UInt16((ushort)(value + 1)).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -85,7 +85,7 @@ public static string UInt16(ushort value)
[TestCase("1234568", new[] { "UInt32", "Box_UInt32" }, 1234567)]
public static string UInt32(uint value)
{
return Box_UInt32(value + 1).ToString();
return Box_UInt32(value + 1).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -94,7 +94,7 @@ public static string UInt32(uint value)
[TestCase("12345678901235", new[] { "UInt64", "Box_UInt64" }, 12345678901234)]
public static string UInt64(ulong value)
{
return Box_UInt64(value + 1).ToString();
return Box_UInt64(value + 1).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -103,7 +103,7 @@ public static string UInt64(ulong value)
[TestCase("1234567", new[] { "IntPtr", "Box_IntPtr" }, 1234567)]
public static string IntPtr(IntPtr value)
{
return Box_IntPtr(value).ToString();
return Box_IntPtr(value).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -112,7 +112,7 @@ public static string IntPtr(IntPtr value)
[TestCase("1234567", new[] { "UIntPtr", "Box_UIntPtr" }, 1234567U)]
public static string UIntPtr(UIntPtr value)
{
return Box_UIntPtr(value).ToString();
return Box_UIntPtr(value).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -121,7 +121,7 @@ public static string UIntPtr(UIntPtr value)
[TestCase("123.456", new[] { "Single", "Box_Single" }, 123.456f)]
public static string Single(float value)
{
return Box_Single(value).ToString();
return Box_Single(value).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -130,7 +130,7 @@ public static string Single(float value)
[TestCase("123.45678901234", new[] { "Double", "Box_Double" }, 123.45678901234)]
public static string Double(double value)
{
return Box_Double(value).ToString();
return Box_Double(value).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -140,7 +140,7 @@ public static string Double(double value)
[TestCase("False", new[] { "Boolean", "Box_Boolean" }, false)]
public static string Boolean(bool value)
{
return Box_Boolean(value).ToString();
return Box_Boolean(value).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -149,7 +149,7 @@ public static string Boolean(bool value)
[TestCase("A", new[] { "Char", "Box_Char" }, 'A')]
public static string Char(char value)
{
return Box_Char(value).ToString();
return Box_Char(value).ToString()!;
}

[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -168,7 +168,7 @@ public static string ValueType(int value1, string value2)
v.Int32Value = value1;
v.StringValue = value2;
object ov = v;
return ov.ToString();
return ov.ToString()!;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<Optimize>False</Optimize>
<Nullable>enable</Nullable>
Expand All @@ -13,6 +13,9 @@
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="ILCompose" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<packagereference Include="NUnit3TestAdapter" Version="4.2.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public FinalzerImplementedWithPinned(FinalizerCalleeHolder holder)

~FinalzerImplementedWithPinned()
{
var holder = (FinalizerCalleeHolder)(handle.Target);
var holder = (FinalizerCalleeHolder)(handle.Target!);
holder.Called = 1;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<Optimize>False</Optimize>
<Nullable>enable</Nullable>
Expand All @@ -13,6 +13,9 @@
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="ILCompose" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<packagereference Include="NUnit3TestAdapter" Version="4.2.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 0e4aa38

Please sign in to comment.