-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #469 from ikvmnet/srm
Use System.Reflection.Metadata to write assemblies in IKVM.Reflection. Enable win-arm64 Framework tools and images.
- Loading branch information
Showing
132 changed files
with
3,294 additions
and
5,931 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net472;net6.0;net7.0</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CliWrap" Version="3.4.1" /> | ||
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.11.0" /> | ||
<PackageReference Include="System.Reflection.Metadata" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)..\..\IKVM.deps.targets" /> | ||
<Import Project="$(MSBuildThisFileDirectory)..\..\IKVM.refs.targets" /> | ||
</Project> |
2 changes: 1 addition & 1 deletion
2
src/IKVM.Tests.Util/InMemoryCodeUnit.cs → src/IKVM.Java.Tests.Util/InMemoryCodeUnit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace IKVM.Reflection.Tests | ||
{ | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="Tfm"></param> | ||
/// <param name="TargetFrameworkIdentifier"></param> | ||
/// <param name="TargetFrameworkVersion"></param> | ||
public record struct FrameworkSpec(string Tfm, string TargetFrameworkIdentifier, string TargetFrameworkVersion) | ||
{ | ||
|
||
/// <summary> | ||
/// Individual Frameworks to test. | ||
/// </summary> | ||
public static IEnumerable<object[]> GetFrameworkTestData() | ||
{ | ||
yield return new object[] { new FrameworkSpec("net472", ".NETFramework", "4.7.2") }; | ||
yield return new object[] { new FrameworkSpec("net48", ".NETFramework", "4.8") }; | ||
yield return new object[] { new FrameworkSpec("net6.0", ".NETCore", "6.0") }; | ||
yield return new object[] { new FrameworkSpec("net7.0", ".NETCore", "7.0") }; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net472;net6.0;net7.0</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.8.0" /> | ||
<PackageReference Include="Microsoft.CodeCoverage" Version="17.4.0" /> | ||
<PackageReference Include="Microsoft.ILVerification" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" /> | ||
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="8.0.0" /> | ||
<PackageReference Include="xunit" Version="2.6.5" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="sample.ico" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="sample.ico" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\IKVM.Reflection\IKVM.Reflection.csproj" /> | ||
<ProjectReference Include="..\IKVM.Tests.Util\IKVM.Tests.Util.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
using FluentAssertions; | ||
|
||
using IKVM.Tests.Util; | ||
|
||
using Xunit; | ||
|
||
namespace IKVM.Reflection.Tests | ||
{ | ||
public class ModuleReaderTests | ||
{ | ||
|
||
/// <summary> | ||
/// Initializes the variables requires to execute tests. | ||
/// </summary | ||
/// <param name="framework"></param> | ||
/// <param name="universe"></param> | ||
/// <param name="resolver"></param> | ||
bool Init(FrameworkSpec framework, out Universe universe, out TestAssemblyResolver resolver) | ||
{ | ||
universe = null; | ||
resolver = null; | ||
|
||
// no reference assemblies for NetFX on Unix | ||
if (framework.TargetFrameworkIdentifier == ".NETFramework") | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) == false) | ||
return false; | ||
|
||
// initialize primary classes | ||
universe = new Universe(DotNetSdkUtil.GetCoreLibName(framework.Tfm, framework.TargetFrameworkIdentifier, framework.TargetFrameworkVersion)); | ||
resolver = new TestAssemblyResolver(universe, framework.Tfm, framework.TargetFrameworkIdentifier, framework.TargetFrameworkVersion); | ||
|
||
return true; | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(FrameworkSpec.GetFrameworkTestData), MemberType = typeof(FrameworkSpec))] | ||
public void CanMakeGenericType(FrameworkSpec framework) | ||
{ | ||
if (Init(framework, out var universe, out var resolver) == false) | ||
return; | ||
|
||
var t = universe.Import(typeof(IEnumerable<>)); | ||
t.IsGenericType.Should().BeTrue(); | ||
t.IsGenericTypeDefinition.Should().BeTrue(); | ||
t.IsConstructedGenericType.Should().BeFalse(); | ||
var g = t.MakeGenericType(universe.Import(typeof(object))); | ||
g.IsGenericTypeDefinition.Should().BeFalse(); | ||
g.IsConstructedGenericType.Should().BeTrue(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(FrameworkSpec.GetFrameworkTestData), MemberType = typeof(FrameworkSpec))] | ||
public void CanGetGenericPropertyOfGenericType(FrameworkSpec framework) | ||
{ | ||
if (Init(framework, out var universe, out var resolver) == false) | ||
return; | ||
|
||
// simple generic with a single property | ||
var nullableType = universe.Import(typeof(Nullable<>)); | ||
nullableType.IsGenericType.Should().BeTrue(); | ||
nullableType.IsGenericTypeDefinition.Should().BeTrue(); | ||
nullableType.IsConstructedGenericType.Should().BeFalse(); | ||
nullableType.GetGenericArguments().Should().HaveCount(1); | ||
nullableType.GetGenericArguments()[0].Should().NotBeNull(); | ||
|
||
// make generic instance | ||
var nullableOfObjectType = nullableType.MakeGenericType(universe.Import(typeof(object))); | ||
nullableOfObjectType.IsGenericTypeDefinition.Should().BeFalse(); | ||
nullableOfObjectType.IsConstructedGenericType.Should().BeTrue(); | ||
|
||
// check for expected property | ||
var valueProperty = nullableOfObjectType.GetProperty("Value"); | ||
valueProperty.PropertyType.Should().Be(universe.Import(typeof(object))); | ||
var valueGetter = valueProperty.GetGetMethod(); | ||
valueGetter.ReturnType.Should().Be(universe.Import(typeof(object))); | ||
valueGetter.GetParameters().Should().BeEmpty(); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.