Skip to content

Commit

Permalink
- net core 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
eben-roux committed Jun 20, 2019
1 parent 7831112 commit 10999c1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void Should_be_able_to_get_configuration()

Assert.That(() => provider.Get("not-defined"), Throws.TypeOf<InvalidOperationException>());

#if (!NETCOREAPP2_0 && !NETSTANDARD2_0)
#if (!NETCOREAPP2_1)
var configuration = provider.Get("Shuttle");

Assert.That(configuration.Name, Is.EqualTo("Shuttle"));
Expand Down
7 changes: 1 addition & 6 deletions Shuttle.Core.Data.Tests/DatabaseContextFactoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ public void Should_be_able_to_create_a_database_context()

private IDatabaseContextFactory GetDefaultDatabaseContextFactory()
{
#if (!NETCOREAPP2_0 && !NETSTANDARD2_0)
var connectionFactory = new DbConnectionFactory();
#else
var connectionFactory = new DbConnectionFactory(new DefaultDbProviderFactories());
#endif
return new DatabaseContextFactory(
GetConnectionConfigurationProvider(),
connectionFactory,
new DbConnectionFactory(),
new DbCommandFactory(),
new ThreadStaticDatabaseContextCache());
}
Expand Down
13 changes: 9 additions & 4 deletions Shuttle.Core.Data.Tests/Fixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using Moq;
using NUnit.Framework;

Expand All @@ -11,13 +13,16 @@ public abstract class Fixture
protected static string DefaultProviderName = "System.Data.SqlClient";
protected static string DefaultConnectionString = "Data Source=.\\sqlexpress;Initial Catalog=Shuttle;Integrated Security=SSPI";

protected Fixture()
{
#if NETCOREAPP2_1
DbProviderFactories.RegisterFactory("System.Data.SqlClient", SqlClientFactory.Instance);
#endif
}

protected DbConnectionFactory GetDbConnectionFactory()
{
#if (!NETCOREAPP2_0 && !NETSTANDARD2_0)
return new DbConnectionFactory();
#else
return new DbConnectionFactory(new DefaultDbProviderFactories());
#endif
}

protected IDatabaseContext GetDatabaseContext()
Expand Down
11 changes: 5 additions & 6 deletions Shuttle.Core.Data.Tests/Shuttle.Core.Data.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
Expand All @@ -21,17 +21,16 @@
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Shuttle.Core.Data\Shuttle.Core.Data.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Remove="ConnectionConfigurationProvider.cs" Condition="'$(TargetFramework)' != 'net46'" />
<Compile Remove="DefaultDbProviderFactories.cs" Condition="'$(TargetFramework)' != 'netcoreapp2.0'" />
<Compile Remove="ConnectionConfigurationProvider.cs" Condition="'$(TargetFramework)' != 'net461'" />
<Compile Remove="DefaultDbProviderFactories.cs" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions Shuttle.Core.Data/.build/package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@
<dependency id="Shuttle.Core.Configuration" version="{Shuttle.Core.Configuration-version}" />
<dependency id="Shuttle.Core.Container" version="{Shuttle.Core.Container-version}" />
<dependency id="Shuttle.Core.Logging" version="{Shuttle.Core.Logging-version}" />
<dependency id="Shuttle.Core.Threading" version="{Shuttle.Core.Threading-version}" />
</group>

<group targetFramework="netstandard2.0">
<dependency id="System.Configuration.ConfigurationManager" version="{System.Configuration.ConfigurationManager-version}" />
<dependency id="Shuttle.Core.Configuration" version="{Shuttle.Core.Configuration-version}" />
<dependency id="Shuttle.Core.Container" version="{Shuttle.Core.Container-version}" />
<dependency id="Shuttle.Core.Logging" version="{Shuttle.Core.Logging-version}" />
<dependency id="Shuttle.Core.Threading" version="{Shuttle.Core.Threading-version}" />
</group>

<group targetFramework="netcoreapp2.1">
<dependency id="System.Configuration.ConfigurationManager" version="{System.Configuration.ConfigurationManager-version}" />
<dependency id="Shuttle.Core.Configuration" version="{Shuttle.Core.Configuration-version}" />
<dependency id="Shuttle.Core.Container" version="{Shuttle.Core.Container-version}" />
<dependency id="Shuttle.Core.Logging" version="{Shuttle.Core.Logging-version}" />
<dependency id="Shuttle.Core.Threading" version="{Shuttle.Core.Threading-version}" />
</group>
</dependencies>
</metadata>
Expand Down
6 changes: 0 additions & 6 deletions Shuttle.Core.Data/DatabaseContextFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,9 @@ public IDatabaseContextFactory ConfigureWith(IDbConnection dbConnection)
return this;
}

#if (!NETCOREAPP2_0 && !NETSTANDARD2_0)
public static IDatabaseContextFactory Default()
{
var dbConnectionFactory = new DbConnectionFactory();
#else
public static IDatabaseContextFactory Default(IDbProviderFactories dbProviderFactories)
{
var dbConnectionFactory = new DbConnectionFactory(dbProviderFactories);
#endif

return new DatabaseContextFactory(new ConnectionConfigurationProvider(), dbConnectionFactory, new DbCommandFactory(), new ThreadStaticDatabaseContextCache());
}
Expand Down
18 changes: 0 additions & 18 deletions Shuttle.Core.Data/DbConnectionFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Data;
using System.Data.Common;
using Shuttle.Core.Contract;
using Shuttle.Core.Logging;

namespace Shuttle.Core.Data
Expand All @@ -9,31 +8,14 @@ public class DbConnectionFactory : IDbConnectionFactory
{
private readonly ILog _log;

#if (!NETCOREAPP2_0 && !NETSTANDARD2_0)
public DbConnectionFactory()
{
_log = Log.For(this);
}
#else
private readonly IDbProviderFactories _providerFactories;

public DbConnectionFactory(IDbProviderFactories providerFactories)
{
Guard.AgainstNull(providerFactories, nameof(providerFactories));

_providerFactories = providerFactories;
_log = Log.For(this);
}
#endif

public IDbConnection CreateConnection(string providerName, string connectionString)
{
#if (!NETCOREAPP2_0 && !NETSTANDARD2_0)
var dbProviderFactory = DbProviderFactories.GetFactory(providerName);
#else
var dbProviderFactory = _providerFactories.GetFactory(providerName);
#endif

var connection = dbProviderFactory.CreateConnection();

if (connection == null)
Expand Down
20 changes: 0 additions & 20 deletions Shuttle.Core.Data/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
using System.Reflection;
using System.Runtime.InteropServices;

#if NET46
[assembly: AssemblyTitle(".NET Framework 4.6")]
#endif

#if NET461
[assembly: AssemblyTitle(".NET Framework 4.6.1")]
#endif

#if NET462
[assembly: AssemblyTitle(".NET Framework 4.6.2")]
#endif

#if NET47
[assembly: AssemblyTitle(".NET Framework 4.7")]
#endif

#if NET471
[assembly: AssemblyTitle(".NET Framework 4.7.1")]
#endif

#if NETCOREAPP2_0
[assembly: AssemblyTitle(".NET Core 2.0")]
#endif

#if NETCOREAPP2_1
[assembly: AssemblyTitle(".NET Core 2.1")]
#endif
Expand Down

0 comments on commit 10999c1

Please sign in to comment.