Skip to content

Commit

Permalink
Updated ILConverter [m-z].
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed May 21, 2022
1 parent 2782904 commit 34a6957
Show file tree
Hide file tree
Showing 41 changed files with 378 additions and 298 deletions.
10 changes: 0 additions & 10 deletions il2c.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{5710A57F
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IL2C.Runtime", "src\IL2C.Runtime\IL2C.Runtime.vcxproj", "{182A62A4-47AC-4290-8EA5-250AE8131613}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core.Test.Fixture", "tests\IL2C.Core.Test.Fixture\IL2C.Core.Test.Fixture.csproj", "{B0F1010D-8B73-46F7-AF8E-E3C58F68525F}"
ProjectSection(ProjectDependencies) = postProject
{182A62A4-47AC-4290-8EA5-250AE8131613} = {182A62A4-47AC-4290-8EA5-250AE8131613}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Interop", "src\IL2C.Interop\IL2C.Interop.csproj", "{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{3EBFA913-CF51-4A28-9E4D-73CB5AE27D2F}"
Expand Down Expand Up @@ -128,10 +123,6 @@ Global
{678EFB0E-BC0A-4749-AD48-079F98D9468D}.Release|Any CPU.Build.0 = Release|Any CPU
{182A62A4-47AC-4290-8EA5-250AE8131613}.Debug|Any CPU.ActiveCfg = Debug|x64
{182A62A4-47AC-4290-8EA5-250AE8131613}.Release|Any CPU.ActiveCfg = Release|x64
{B0F1010D-8B73-46F7-AF8E-E3C58F68525F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0F1010D-8B73-46F7-AF8E-E3C58F68525F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0F1010D-8B73-46F7-AF8E-E3C58F68525F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0F1010D-8B73-46F7-AF8E-E3C58F68525F}.Release|Any CPU.Build.0 = Release|Any CPU
{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -185,7 +176,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B0F1010D-8B73-46F7-AF8E-E3C58F68525F} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
{A6072CD1-A526-45F2-BB88-D1040AC3A7E8} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
{6811E378-50B3-4206-BB48-1E56A2F2D90E} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
{DC306000-300C-4E65-826C-2E41C6445CA9} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
Expand Down
10 changes: 8 additions & 2 deletions tests/IL2C.Core.Test.BasicTypes/IL2C.Core.Test.BasicTypes.csproj
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,11 +13,17 @@
<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>
<ProjectReference Include="..\..\src\IL2C.Interop\IL2C.Interop.csproj" />
<ProjectReference Include="..\IL2C.Core.Test.Common\IL2C.Core.Test.Common.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\IL2C.Core.Test.Common\*.cs" />
</ItemGroup>

</Project>
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>
58 changes: 56 additions & 2 deletions tests/IL2C.Core.Test.Common/TestCaseAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//
////////////////////////////////////////////////////////////////////////////

#nullable enable

using System;
using System.Linq;

Expand All @@ -21,7 +23,6 @@ public enum TestCaseAsserts
CauseBreak
}

// It's test case attribute contains expected value, method name and argument values at overall.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public sealed class TestCaseAttribute :
NUnit.Framework.TestCaseAttribute, NUnit.Framework.ITestAction
Expand Down Expand Up @@ -65,7 +66,8 @@ public TestCaseAttribute(
public Type[] IncludeTypes { get; set; }
public string[] IgnoreILErrors { get; set; }

public NUnit.Framework.ActionTargets Targets => throw new NotImplementedException();
public NUnit.Framework.ActionTargets Targets =>
NUnit.Framework.ActionTargets.Default;

public void BeforeTest(ITest test)
{
Expand All @@ -77,5 +79,57 @@ public void AfterTest(ITest test)
{
// TODO: delegates to test native code.
}
#if false
private static object?[] ConvertToArgumentsType(object?[] args, Type[] argumentTypes) =>
args.Zip(argumentTypes, ConvertToArgumentType).ToArray();

private static object? ConvertToArgumentType(object? value, Type argumentType)
{
// This is helper function that convert between raw value type and argument type.
// Because .NET attribute can't have complex type arguments.
if (value == null)
{
return null;
}
else if (value.GetType() == argumentType)
{
return value;
}
else if (argumentType == typeof(IntPtr))
{
if (value is int)
{
return new IntPtr((int)value);
}
else if (value is long)
{
return new IntPtr((long)value);
}
else
{
throw new InvalidCastException();
}
}
else if (argumentType == typeof(UIntPtr))
{
if (value is uint)
{
return new UIntPtr((uint)value);
}
else if (value is ulong)
{
return new UIntPtr((ulong)value);
}
else
{
throw new InvalidCastException();
}
}
else
{
return Convert.ChangeType(value, argumentType);
}
}
#endif
}
}
18 changes: 15 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,11 @@
<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="NUnit3TestAdapter" Version="4.2.1" PrivateAssets="All" />
-->
<PackageReference Include="NUnit" Version="3.13.3" />
<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 All @@ -24,9 +26,11 @@

<ItemGroup>
<ProjectReference Include="..\..\src\IL2C.Core\IL2C.Core.csproj" />
<!--
<ProjectReference Include="..\IL2C.Core.Test.BasicTypes\IL2C.Core.Test.BasicTypes.csproj" />
<ProjectReference Include="..\IL2C.Core.Test.ILConverters\IL2C.Core.Test.ILConverters.csproj" />
<ProjectReference Include="..\IL2C.Core.Test.RuntimeSystems\IL2C.Core.Test.RuntimeSystems.csproj" />
-->
</ItemGroup>

<ItemGroup>
Expand All @@ -45,4 +49,12 @@
<EmbeddedResource Include="Templates\test.vcxproj" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Internal\StatisticsDocumentGenerators.cs" />
</ItemGroup>

<ItemGroup>
<None Include="Internal\StatisticsDocumentGenerators.cs" />
</ItemGroup>

</Project>
Loading

0 comments on commit 34a6957

Please sign in to comment.