Skip to content

Commit

Permalink
Add support for .NET Core
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Massari committed Oct 30, 2018
1 parent 11856fb commit a38338a
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: csharp
mono: latest
dotnet: 2.1.0
sudo: required
env:
global:
Expand Down Expand Up @@ -33,3 +34,5 @@ script:
- xbuild /p:TargetFrameworkProfile="" /p:Configuration=Release ADO.NET.Mono.sln
- mono ConsoleSample/bin/Release/ConsoleSample.exe test
- mono NUnitTestProject/bin/Release/NUnitTestProject.exe
- dotnet build ADO.NET.Core.sln
- dotnet ConsoleSample/bin/Release/netcoreapp2.1/ConsoleSampleCore.dll test
54 changes: 54 additions & 0 deletions ADO.NET.Core.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSample", "ConsoleSample\ConsoleSampleCore.csproj", "{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}"
ProjectSection(ProjectDependencies) = postProject
{3A992E63-061C-47EE-862A-452334D70D90} = {3A992E63-061C-47EE-862A-452334D70D90}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuoDb.Data.Client_4.0", "NuoDb.Data.Client\NuoDb.Data.ClientCore.csproj", "{3A992E63-061C-47EE-862A-452334D70D90}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Debug|Any CPU.ActiveCfg = Debug|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Debug|Any CPU.Build.0 = Debug|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Debug|Mixed Platforms.Build.0 = Debug|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Debug|Win32.ActiveCfg = Debug|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Debug|x86.ActiveCfg = Debug|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Debug|x86.Build.0 = Debug|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Release|Any CPU.ActiveCfg = Release|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Release|Any CPU.Build.0 = Release|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Release|Mixed Platforms.ActiveCfg = Release|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Release|Mixed Platforms.Build.0 = Release|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Release|Win32.ActiveCfg = Release|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Release|x86.ActiveCfg = Release|x86
{51CF36CD-7035-4CF9-A7E7-97C1BA85BB9B}.Release|x86.Build.0 = Release|x86
{3A992E63-061C-47EE-862A-452334D70D90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Debug|Win32.ActiveCfg = Debug|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Debug|x86.ActiveCfg = Debug|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Release|Any CPU.Build.0 = Release|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Release|Win32.ActiveCfg = Release|Any CPU
{3A992E63-061C-47EE-862A-452334D70D90}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
EndGlobal
33 changes: 33 additions & 0 deletions ConsoleSample/ConsoleSampleCore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>ConsoleSample</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputType>Exe</OutputType>
<OutputPath>bin\Release\</OutputPath>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<Reference Include="NuoDb.Data.Client">
<HintPath>..\NuoDb.Data.Client\bin\Release\netcoreapp2.1\NuoDb.Data.ClientCore.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="HelloDB.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

</Project>
99 changes: 99 additions & 0 deletions NuoDb.Data.Client/NuoDb.Data.ClientCore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>NuoDb.Data.Client</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BatchProcessedEventArgs.cs" />
<Compile Include="BatchProcessedEventHandler.cs" />
<Compile Include="ConnectionPoolManager.cs" />
<Compile Include="DataFeeder.cs" />
<Compile Include="NuoDbBulkLoader.cs" />
<Compile Include="NuoDbBulkLoaderColumnMapping.cs" />
<Compile Include="NuoDbBulkLoaderColumnMappingCollection.cs" />
<Compile Include="NuoDbCommandBuilder.cs" />
<Compile Include="NuoDbConnection.cs" />
<Compile Include="NuoDbConnectionStringBuilder.cs" />
<Compile Include="NuoDbDataAdapter.cs" />
<Compile Include="NuoDbDataParameterCollection.cs" />
<Compile Include="NuoDbParameter.cs" />
<Compile Include="NuoDbProviderFactory.cs" />
<Compile Include="NuoDbRowUpdatedEventHandler.cs" />
<Compile Include="NuoDbRowUpdatingEventHandler.cs" />
<Compile Include="NuoDbTransaction.cs" />
<Compile Include="Protocol.cs" />
<Compile Include="RemEncodedStream.cs" />
<Compile Include="NuoDbSqlCode.cs" />
<Compile Include="SQLContext.cs" />
<Compile Include="Util\Extensions.cs" />
<Compile Include="Util\Op.cs" />
<Compile Include="Util\StringUtils.cs" />
<Compile Include="NuoDbCommand.cs" />
<Compile Include="NuoDbMultipleCommands.cs" />
<Compile Include="NuoDbConnectionInternal.cs" />
<Compile Include="NuoDbSqlException.cs" />
<Compile Include="Net\CryptoInputStream.cs" />
<Compile Include="Net\CryptoOutputStream.cs" />
<Compile Include="Net\CryptoSocket.cs" />
<Compile Include="Security\BigInteger.cs" />
<Compile Include="Security\RemoteGroup.cs" />
<Compile Include="Security\RemotePassword.cs" />
<Compile Include="Security\Cypher.cs" />
<Compile Include="Security\CypherRC4.cs" />
<Compile Include="NuoDbDataReader.cs" />
<Compile Include="DataStream.cs" />
<Compile Include="EncodedDataStream.cs" />
<Compile Include="Xml\Attribute.cs" />
<Compile Include="Xml\Doc.cs" />
<Compile Include="Xml\Tag.cs" />
<Compile Include="Value.cs" />
<Compile Include="ValueBoolean.cs" />
<Compile Include="ValueByte.cs" />
<Compile Include="ValueBytes.cs" />
<Compile Include="ValueDate.cs" />
<Compile Include="ValueDouble.cs" />
<Compile Include="ValueInt.cs" />
<Compile Include="ValueLong.cs" />
<Compile Include="ValueNull.cs" />
<Compile Include="ValueNumber.cs" />
<Compile Include="ValueShort.cs" />
<Compile Include="ValueString.cs" />
<Compile Include="ValueTime.cs" />
<Compile Include="ValueTimestamp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="DataTypes.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TimeZones.xml" />
</ItemGroup>

</Project>
12 changes: 11 additions & 1 deletion NuoDb.Data.Client/NuoDbConnectionInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,17 @@ private void doOpen(string hostName)
{
// Save the default at the time the connection was opened
string tzone = TimeZoneInfo.Local.Id;
properties["TimeZone"] = OlsonDatabase.FindOlsonTimeZone(tzone);
if (OlsonDatabase.IsOlsonTimeZone(tzone))
{
// it should mean we are on linux/macOS, where the
// timezone is already an Olson name (and FindSystemTimeZoneById
// can process it correctly)
properties["TimeZone"] = tzone;
}
else
{
properties["TimeZone"] = OlsonDatabase.FindOlsonTimeZone(tzone);
}
// As described in http://msdn.microsoft.com/en-us/library/system.timezoneinfo.local.aspx TimeZoneInfo.Local
// always applies the DST setting of the current time, even if the DST settings of the tested date used different
// rules; so we fetch the complete definition from the database
Expand Down
6 changes: 5 additions & 1 deletion NuoDb.Data.Client/NuoDbProviderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
using System.Data.Common;
using System.Security;
using System.Security.Permissions;
#if !MONO
#if !MONO && !NETCOREAPP
using NuoDb.Data.Client.EntityFramework;
#endif
using System;
Expand Down Expand Up @@ -84,10 +84,12 @@ public override DbParameter CreateParameter()
return new NuoDbParameter();
}

#if !NETCOREAPP
public override CodeAccessPermission CreatePermission(PermissionState state)
{
return null;
}
#endif

#if !MONO
#region IServiceProvider Members
Expand All @@ -97,10 +99,12 @@ public object GetService(Type serviceType)
#if DEBUG
System.Diagnostics.Trace.WriteLine(String.Format("NuoDbProviderFactory::GetService({0})", serviceType));
#endif
#if !NETCOREAPP
if (serviceType == typeof(DbProviderServices))
{
return NuoDbProviderServices.Instance;
}
#endif
return null;
}

Expand Down
5 changes: 5 additions & 0 deletions NuoDb.Data.Client/SQLContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ static OlsonDatabase()
}
}

public static Boolean IsOlsonTimeZone(string PossibleOlsonName)
{
string WindowsZone;
return db.TryGetValue(PossibleOlsonName, out WindowsZone);
}
public static TimeZoneInfo FindWindowsTimeZone(string OlsonTimeZone)
{
string WindowsZone;
Expand Down

0 comments on commit a38338a

Please sign in to comment.