Skip to content
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

Open
wants to merge 20 commits into
base: v0.46
Choose a base branch
from
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
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.vs/
.idea/
openjdk/**/*.class
/classpath/**/*.class
bin/
openjdk/*.dll
packages/
bin/
obj/
/CommonAssemblyInfo.cs
/awt/AssemblyInfo.cs
/openjdk/*.jar
*.user
/tools/*.exe
/jvm/jvm_h.il
/openjdk/AssemblyInfo.java
*.gen.txt
/openjdk/tools.gen.rsp
/openjdk/vfs.zip
/openjdk/allsources.gen.lst
/openjdk/java/lang/PropertyConstants.java
/runtime/AssemblyInfo.cs
/runtime/JniAssemblyInfo.cs
/openjdk/resources.zip
/runtime/IKVM.Runtime.dll
/runtime/IKVM.OpenJDK.Core.dll
/lib/ikvm-api.jar
/tools/pubkey.txt
/bin-x86/JVM.DLL
/bin-x64/JVM.DLL
/runtime/IKVM.Runtime.JNI.dll
4 changes: 4 additions & 0 deletions CommonAssemblyInfo.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ using System.Reflection;
#pragma warning disable 1699
[assembly: AssemblyKeyName("ikvm-key")]
#endif

#if NETSTANDARD
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
#endif
3 changes: 3 additions & 0 deletions app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
6 changes: 3 additions & 3 deletions awt/AssemblyInfo.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@

Jeroen Frijters
jeroen@frijters.net

*/
using System.Reflection;
using System.Runtime.CompilerServices;

//
// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("IKVM.NET AWT Support")]
[assembly: AssemblyDescription("Winforms peers and 'native' code")]

[assembly: System.Security.AllowPartiallyTrustedCallers]
//[assembly: System.Security.AllowPartiallyTrustedCallers]

#if SIGNCODE
[assembly: InternalsVisibleTo("IKVM.OpenJDK.SwingAWT, PublicKey=@PUBLICKEY@")]
Expand Down
157 changes: 38 additions & 119 deletions awt/IKVM.AWT.WinForms.8.csproj
Original file line number Diff line number Diff line change
@@ -1,159 +1,78 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<Project Sdk="Microsoft.NET.Sdk">

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>
<ProjectType>Local</ProjectType>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E00A0FA2-1FD7-4DD9-8C06-7202CE366102}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<ApplicationIcon />
<AssemblyKeyContainerName />
<AssemblyName>IKVM.AWT.WinForms</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AssemblyOriginatorKeyFile />
<RootNamespace>awt</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG;WHIDBEY</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>672,612</NoWarn>
<Optimize>false</Optimize>
<DocumentationFile />
<OutputPath>bin\$(Configuration)\</OutputPath>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoStdLib>false</NoStdLib>
<ConfigurationOverrideFile />
<FileAlignment>4096</FileAlignment>
<DefineConstants>TRACE;DEBUG;WHIDBEY</DefineConstants>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<PreBuildEvent />
<PostBuildEvent />
<Configurations>Debug;Release;Debug FIRST PASS</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent />
<PostBuildEvent />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug FIRST PASS' ">
<DebugSymbols Condition=" '$(DebugSymbols)' == '' ">true</DebugSymbols>
<Optimize Condition=" '$(Optimize)' == '' ">false</Optimize>
<DefineConstants>TRACE;DEBUG;FIRST_PASS</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="IKVM.OpenJDK.Core, Version=0.39.3280.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.Core.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="IKVM.OpenJDK.Media, Version=0.41.3440.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.Media.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="IKVM.OpenJDK.Misc, Version=0.39.3280.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.Misc.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="IKVM.OpenJDK.SwingAWT, Version=0.39.3280.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.SwingAWT.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="IKVM.OpenJDK.Text, Version=0.39.3280.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\IKVM.OpenJDK.Text.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
<Reference Include="IKVM.Runtime, Version=0.47.0.2, Culture=neutral, PublicKeyToken=null">
<HintPath>..\bin\IKVM.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="composite.cs" />
<Compile Include="converter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="fonts-0.95.cs" />
<Compile Include="graphics.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="images.cs">
<Compile Include="..\CommonAssemblyInfo.cs" >
<SubType>Code</SubType>
</Compile>
<Compile Include="native.cs" />
<Compile Include="printing.cs" />
<Compile Include="robot.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ShellApi.cs" />
<Compile Include="toolkit-0.95.cs">
<Compile Update="toolkit-0.95.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\runtime\IKVM.Runtime.8.csproj">
<Project>{F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}</Project>
<Name>IKVM.Runtime.8</Name>
</ProjectReference>
<ProjectReference Include="..\runtime\IKVM.Runtime.8.csproj" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<PackageReference Include="System.Drawing.Common" Version="4.6.0" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>
14 changes: 8 additions & 6 deletions awt/awt.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@
</target>
<target name="first-pass" depends="AssemblyInfo.cs">
<property overwrite="false" name="signed" value="" />
<csc target="library" output="../bin/IKVM.AWT.WinForms.dll" define="FIRST_PASS;${signed}" rebuild="true">
<csc target="library" output="../bin/IKVM.AWT.WinForms.dll" define="FIRST_PASS;NETSTANDARD;${signed}" rebuild="true" nostdlib="true">
<sources>
<include name="../CommonAssemblyInfo.cs" />
<include name="AssemblyInfo.cs" />
<include name="native.cs" />
<include name="ShellApi.cs" />
</sources>
<references>
<include name="System.Windows.Forms.dll" asis="true" />
<include name="System.Drawing.dll" asis="true" />
<include name="netstandard.dll" />
<include name="..\packages\system.drawing.common.4.6.0\ref\netstandard2.0\System.Drawing.Common.dll" />
<!-- <include name="System.Windows.Forms.dll" asis="true" />
<include name="System.Drawing.dll" asis="true" /> -->
</references>
</csc>
</target>
<target name="awt" depends="AssemblyInfo.cs">
<property overwrite="false" name="signed" value="" />
<csc target="library" output="../bin/IKVM.AWT.WinForms.dll" define="TRACE;${signed}" rebuild="true">
<csc target="library" output="../bin/IKVM.AWT.WinForms.dll" define="NETSTANDARD;TRACE;${signed}" rebuild="true">
<sources>
<include name="../CommonAssemblyInfo.cs" />
<include name="AssemblyInfo.cs" />
Expand All @@ -50,8 +52,8 @@
<include name="../bin/IKVM.OpenJDK.Media.dll" asis="true" />
<include name="../bin/IKVM.OpenJDK.Misc.dll" asis="true" />
<include name="../bin/IKVM.Runtime.dll" asis="true" />
<include name="System.Windows.Forms.dll" asis="true" />
<include name="System.Drawing.dll" asis="true" />
<include name="netstandard.dll" />
<include name="..\packages\system.drawing.common.4.6.0\ref\netstandard2.0\System.Drawing.Common.dll" />
</references>
<nowarn>
<!-- disable warnings about obsolete members (because the peer API has lots of those) -->
Expand Down
3 changes: 1 addition & 2 deletions awt/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Jeroen Frijters
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.ComponentModel;
using System.Reflection;
using System.Text;
Expand Down Expand Up @@ -387,4 +386,4 @@ internal static java.awt.Shape ConvertShape(GraphicsPath path) {
return shape;
}
}
}
}
13 changes: 11 additions & 2 deletions awt/graphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ Jeroen Frijters
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Globalization;
#if !NETSTANDARD
using System.Windows.Forms;
#endif
using java.awt.image;
using java.util;

Expand Down Expand Up @@ -85,6 +87,7 @@ public override void copyArea(int x, int y, int width, int height, int dx, int d
}
}

#if !NETSTANDARD
internal class ComponentGraphics : NetGraphics
{
private readonly Control control;
Expand Down Expand Up @@ -123,6 +126,7 @@ public override void copyArea(int x, int y, int width, int height, int dx, int d
this.g.CopyFromScreen(src, dest, new Size(width, height));
}
}
#endif

internal class PrintGraphicsContext
{
Expand Down Expand Up @@ -1323,7 +1327,11 @@ public override bool hit(java.awt.Rectangle rect, java.awt.Shape s, bool onStrok

public override java.awt.GraphicsConfiguration getDeviceConfiguration()
{
#if NETSTANDARD
throw new NotImplementedException("Windows Forms is not available in .NET Standard");
#else
return new NetGraphicsConfiguration(Screen.PrimaryScreen);
#endif
}

public override void setComposite(java.awt.Composite comp)
Expand Down Expand Up @@ -1922,6 +1930,7 @@ public override void drawGlyphVector(java.awt.font.GlyphVector gv, float x, floa
}
}

#if !NETSTANDARD
sealed class NetGraphicsConfiguration : java.awt.GraphicsConfiguration
{
internal readonly Screen screen;
Expand Down Expand Up @@ -2136,5 +2145,5 @@ public override java.awt.GraphicsDevice[] getScreenDevices()
return devices;
}
}

}
#endif
}
4 changes: 3 additions & 1 deletion awt/robot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Jeroen Frijters

*/

#if !NETSTANDARD
using System;
using System.Drawing;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -401,4 +402,5 @@ IntPtr dwExtraInfo // application-defined information


}
}
}
#endif
Loading