-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET Standard support #5
base: v0.46
Are you sure you want to change the base?
Conversation
Incomplete System.Reflection.Emit: https://github.com/dotnet/coreclr/issues/10199
Also contains some small hacks around Java code depending on .NET-specific code, not available in .NET Standard or extensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for great work!
I've taken a look and reviewed some parts of PR.
I hope someone will review this PR too.
@@ -1,159 +1,78 @@ | |||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> | |||
<Project Sdk="Microsoft.NET.Sdk"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now when you use new csproj format, I suggest to use PackageReference instead of direct storing nuget packages folder in git.
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="ICSharpCode.SharpZipLib"> | ||
<Name>ICSharpCode.SharpZipLib</Name> | ||
<HintPath>bin\ICSharpCode.SharpZipLib.dll</HintPath> | ||
</Reference> | ||
<Reference Include="IKVM.Runtime, Version=0.46.0.5, Culture=neutral, PublicKeyToken=null"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that project reference will be better than assembly reference with explicit version specified
@@ -344,6 +346,7 @@ private static void PrintHelp() | |||
Console.Error.WriteLine(" -nostdlib Do not reference standard libraries"); | |||
Console.Error.WriteLine(" -lib:<dir> Additional directories to search for references"); | |||
Console.Error.WriteLine(" -noautoserialization Disable automatic .NET serialization support"); | |||
Console.Error.WriteLine(" -netstandard Generate .NET Standard libraries"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be useful to mark this line with (default)
. Also, here you use two tabs instead of spaces, it may looks ugly in console.
if (peer.assembly.Equals(reference, StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
ArrayAppend(ref target.peerReferences, peer.assembly); | ||
goto next_reference; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may remove ugly goto
and get code more readable if you rewrite code with some LINQ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understood your code right, consider something like:
var peerAssemblies = targets
.Where(peer => target.unresolvedNetStandardReferences.Contains(peer.assembly, StringComparison.InvariantCultureIgnoreCase))
.ToArray();
foreach (var reference in peerAssemblies)
{
ArrayAppend(ref target.peerReferences, peer.assembly);
}
foreach (var reference in target.unresolvedNetStandardReferences.Where(reference => targets.All(peer => !peer.assembly.Equals(reference, StringComparison.InvariantCultureIgnoreCase))))
{
int rc = resolver.ResolveReference(cache, ref target.references, reference, true);
if (rc != 0)
{
return rc;
}
}
int rc = resolver.ResolveReference(cache, ref target.references, reference, true); | ||
if (rc != 0) | ||
{ | ||
return rc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this return statement. Not all peer assemblies could be added to target.peerReferences
sometime.
@@ -8,6 +8,15 @@ | |||
<property name="pathsep" value=";" /> | |||
</if> | |||
|
|||
<target name="all.netstandard"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [email protected] | ||
# | ||
|
||
assembly.class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file supposed to be included in git history?
@@ -0,0 +1,13 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net461" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to remove this file and packages folder due to new csproj format is used. We could use PackageReference in csproj instead.
@@ -1842,7 +1852,11 @@ private void DumpMethod() | |||
|
|||
internal void DefineSymbolDocument(ModuleBuilder module, string url, Guid language, Guid languageVendor, Guid documentType) | |||
{ | |||
#if NETSTANDARD | |||
throw new PlatformNotSupportedException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many potential runtime errors. Could we workaround this sometime?
@@ -1842,7 +1852,11 @@ private void DumpMethod() | |||
|
|||
internal void DefineSymbolDocument(ModuleBuilder module, string url, Guid language, Guid languageVendor, Guid documentType) | |||
{ | |||
#if NETSTANDARD | |||
throw new PlatformNotSupportedException(); | |||
#else | |||
symbols = module.DefineDocument(url, language, languageVendor, documentType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be targeting .net standard 2.1 brings module builder API https://docs.microsoft.com/ru-ru/dotnet/api/system.reflection.emit.modulebuilder
Curious why this excellent work was based on such an old branch as opposed to, say, |
@zgramana Unfortunately we're using this version because trying to use it with Java 8 brings breaking changes (e.g., default implemented method) which we cannot afford right now. However, I might be able to give it a try to apply the changes on a newer branch, but can't promise anything as it's not primary focus. |
Interesting. I’ve used this PR as a guide to add support to master. I haven’t completed all of it yet, as I’m torn between replacing I don’t think that I fully understood your comment about Java 8 breaking changes and “default implemented method”. Could you explain that in a little detail? |
We have many dlls compiled from java6-7 on different projects and need them to be compatible together at runtime (dynamic loading). Switching only one of them to java8 means we need to have two different ikvm version at runtime, but also that we need a version of every dlls for both versions, but also that objects cannot be shared between both runtimes. This was caused indirectly by the way default interfaces methods are handled, which makes interfaces runtime differ, so a class implementing an interface cannot be shared. |
Requires first and foremost adding the .NET Standard framework in the NAnt config (
netstandard.txt
in the root)