Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
Add .NET Standard 2.0 Target (#35)
Browse files Browse the repository at this point in the history
2.0 adds some things we were missing.
Primarily, we're interested in System.ICloneable.
Don't bother trying to bootstrap in 2.0, it won't work.
  • Loading branch information
airbreather committed Oct 25, 2017
1 parent 7d16836 commit 134354b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
@@ -1,13 +1,9 @@
language: csharp
sudo: required
dist: trusty
addons:
apt:
packages:
- referenceassemblies-pcl
dotnet: 2.0.0
mono:
- latest
solution: NetTopologySuite.sln
install:
- nuget install NUnit.Runners -version 3.6.0 -OutputDirectory .testRunner
script:
Expand Down
1 change: 1 addition & 0 deletions GeoAPI.nuspec
Expand Up @@ -34,6 +34,7 @@
<dependency id="System.Runtime.Extensions" version="[4.3.0, )" />
<dependency id="System.Threading" version="[4.3.0, )" />
</group>
<group targetFramework=".NETStandard2.0" />
</dependencies>
</metadata>

Expand Down
2 changes: 2 additions & 0 deletions src/GeoAPI/Consts.cs
Expand Up @@ -35,6 +35,8 @@ internal static class Consts
public const string Guid = FullFrameworkGuid;
#elif NETSTANDARD1_0
public const string Product = "GeoAPI.NetStandard10";
#elif NETSTANDARD2_0
public const string Product = "GeoAPI.NetStandard20";
#elif PCL
public const string Product = "GeoAPI.PCL";
#endif
Expand Down
20 changes: 19 additions & 1 deletion src/GeoAPI/GeoAPI.csproj
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<SolutionDir Condition=" '$(SolutionDir)' == '' ">$(ProjectDir)..\..\</SolutionDir>
<TargetFrameworks>net20;net35-client;net35-cf;net40-client;net403-client;net45;netstandard1.0;portable40-net40+sl5+win8+wp8+wpa81;portable40-net403+sl5+win8+wp8+wpa81</TargetFrameworks>
<TargetFrameworks>net20;net35-client;net35-cf;net40-client;net403-client;net45;netstandard1.0;netstandard2.0;portable40-net40+sl5+win8+wp8+wpa81;portable40-net403+sl5+win8+wp8+wpa81</TargetFrameworks>
<NoWarn>1591</NoWarn>
<OutputPath>$(SolutionDir)$(Configuration)\$(Platform)</OutputPath>
<DocumentationFile>$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
Expand Down Expand Up @@ -89,8 +89,15 @@
<RequiresFrameworkAssemblyReferences>true</RequiresFrameworkAssemblyReferences>
<DebugType>full</DebugType>

<!-- NetFX targets set GeometryServiceProvider.Instance using reflection if it's not explicitly
set externally before the first access. This is sketchy at best (it won't work if, e.g.,
someone tries this before the first thing loads NetTopologySuite into the AppDomain), so
other targets need to either explicitly bootstrap or just not use that global variable. -->
<DefineConstants>$(DefineConstants);COMPAT_BOOTSTRAP_USING_REFLECTION</DefineConstants>

<DefineConstants>$(DefineConstants);FEATURE_DEFAULT_PARAMETERS</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_INTERFACE_VARIANCE</DefineConstants>

<DefineConstants>$(DefineConstants);HAS_SYSTEM_APPDOMAIN_GETASSEMBLIES</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_SYSTEM_APPLICATIONEXCEPTION</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_SYSTEM_DOUBLE_TRYPARSE</DefineConstants>
Expand All @@ -105,13 +112,24 @@

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' ">
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' Or '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);FEATURE_DEFAULT_PARAMETERS</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_INTERFACE_VARIANCE</DefineConstants>

<DefineConstants>$(DefineConstants);HAS_SYSTEM_DOUBLE_TRYPARSE</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_SYSTEM_STRING_TOUPPERINVARIANT</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);HAS_SYSTEM_APPDOMAIN_GETASSEMBLIES</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_SYSTEM_APPLICATIONEXCEPTION</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_SYSTEM_ICLONEABLE</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_SYSTEM_SERIALIZABLEATTRIBUTE</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_SYSTEM_STRING_TOUPPER_CULTUREINFO</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(RequiresFrameworkAssemblyReferences)' == 'true' ">
<Reference Include="System" />
<Reference Include="System.Core" Condition=" '$(TargetFramework)' != 'net20' " />
Expand Down
2 changes: 1 addition & 1 deletion src/GeoAPI/GeometryServiceProvider.cs
Expand Up @@ -72,7 +72,7 @@ private static IEnumerable<Type> GetLoadableTypes(Assembly assembly)

private static IGeometryServices ReflectInstance()
{
#if HAS_SYSTEM_APPDOMAIN_GETASSEMBLIES
#if COMPAT_BOOTSTRAP_USING_REFLECTION && HAS_SYSTEM_APPDOMAIN_GETASSEMBLIES
var a = AppDomain.CurrentDomain.GetAssemblies();
foreach (var assembly in a)
{
Expand Down

0 comments on commit 134354b

Please sign in to comment.