Skip to content

Commit 5672441

Browse files
committed
feat(netcore2): add netcore2 with netstandard serialization
1 parent 07d329b commit 5672441

File tree

46 files changed

+605
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+605
-231
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33
[![Build status](https://ci.appveyor.com/api/projects/status/3uk49dtw8u4hdt7w/branch/master?svg=true)](https://ci.appveyor.com/project/jrogalan/fluent-nhibernate/branch/master)
44
[![NuGet](https://img.shields.io/nuget/v/FluentNHibernate.svg)](https://www.nuget.org/packages/FluentNHibernate)
55

6+
## What is FluentNHibernate?
67
Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate. *Get your fluent on.*
78

9+
## Where can I get it?
810

9-
Getting started
10-
---------------------------------------------
11+
Install using the [FluentNHibernate NuGet package](https://www.nuget.org/packages/FluentNHibernate):
12+
13+
```
14+
dotnet add package FluentNHibernate
15+
```
16+
17+
## How do I use it?
1118

1219
* Read the [introduction](https://github.com/FluentNHibernate/fluent-nhibernate/wiki/Getting-started).
1320
* Get latest version from NuGet
14-
- [.NET 4.6.1 with NHibernate 5.x](https://www.nuget.org/packages/FluentNHibernate)
21+
- [.NETCore2.0, NETStandard2.0 or NET 4.6.1 with NHibernate 5.x](https://www.nuget.org/packages/FluentNHibernate)
1522
- [.NET 4.0 with NHibernate 4.x](https://www.nuget.org/packages/FluentNHibernate/2.0.3)
1623
- [.NET 3.5 with NHibernate 3 if you like it vintage](https://www.nuget.org/packages/FluentNHibernate.Net35)
1724

1825
* Create your [first project](https://github.com/FluentNHibernate/fluent-nhibernate/wiki/Getting-started#wiki-yourfirstproject).
1926

20-
Further reading
21-
---------------------------------------------
27+
## Further reading
2228

2329
Once you've followed the above, you can compare our [auto mapping](https://github.com/FluentNHibernate/fluent-nhibernate/wiki/Auto-mapping) to our [fluent interface](https://github.com/FluentNHibernate/fluent-nhibernate/wiki/Fluent-mapping) to see which suits your application, read through our [API documentation](https://github.com/FluentNHibernate/fluent-nhibernate/wiki/Fluent-configuration), or just see what's available for reading in our [wiki](https://github.com/FluentNHibernate/fluent-nhibernate/wiki).
2430

25-
26-
Building
27-
---------------------------------------------
28-
29-
Follow the instructions from the [wiki page](https://github.com/FluentNHibernate/fluent-nhibernate/wiki/Building) to build the project.
30-
3131
Contributors
3232
---------------------------------------------
3333

build.cake

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,41 @@ Task("Build")
7575
Task("Test")
7676
.IsDependentOn("Build")
7777
.Does(() =>
78-
{
79-
var frameworks = new [] { "net461"};
80-
foreach (var framework in frameworks)
81-
{
82-
var testAssemblies = $"./src/**/bin/{parameters.Configuration}/{framework}/*.Testing.dll";
83-
NUnit3(testAssemblies, new NUnit3Settings {
84-
NoResults = true
85-
});
78+
{
79+
var unitProjects = GetFiles("./src/**/*.Testing.csproj");
80+
var specProjects = GetFiles("./src/**/*.Specs.csproj");
81+
var testProjects = unitProjects.Union(specProjects).ToArray();
8682

87-
testAssemblies = $"./src/**/bin/{parameters.Configuration}/{framework}/*.Specs.dll";
88-
MSpec(testAssemblies, new MSpecSettings {
89-
Silent = true
90-
});
91-
}
92-
/* Tests not working in netcoreapp2.0
93-
foreach(var project in TestProjects)
94-
{
95-
var projectPath = File($"./src/{project}/{project}.csproj");
96-
DotNetCoreTest(projectPath, new DotNetCoreTestSettings
97-
{
98-
Framework = "netcoreapp2.0",
99-
NoBuild = true,
100-
NoRestore = true,
101-
Configuration = parameters.Configuration
102-
});
83+
// foreach (var framework in frameworks)
84+
// {
85+
// var testAssemblies = $"./src/**/bin/{parameters.Configuration}/{framework}/*.Testing.dll";
86+
// NUnit3(testAssemblies, new NUnit3Settings {
87+
// NoResults = true
88+
// });
89+
90+
// testAssemblies = $"./src/**/bin/{parameters.Configuration}/{framework}/*.Specs.dll";
91+
// MSpec(testAssemblies, new MSpecSettings {
92+
// Silent = true
93+
// });
94+
// }
95+
foreach(var project in testProjects)
96+
{
97+
DotNetCoreTest(project.ToString(), new DotNetCoreTestSettings
98+
{
99+
Framework = "net461",
100+
NoBuild = true,
101+
NoRestore = true,
102+
Configuration = parameters.Configuration
103+
});
104+
105+
DotNetCoreTest(project.ToString(), new DotNetCoreTestSettings
106+
{
107+
Framework = "netcoreapp2.0",
108+
NoBuild = true,
109+
NoRestore = true,
110+
Configuration = parameters.Configuration
111+
});
103112
}
104-
*/
105113
});
106114

107115
Task("Copy-Files")

src/FluentNHibernate.Specs.ExternalFixtures/FluentNHibernate.Specs.ExternalFixtures.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<PropertyGroup>
33
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
44
<NoWarn>1591</NoWarn>
5-
<PlatformTarget>AnyCpu</PlatformTarget>
65
</PropertyGroup>
76

87
<Import Project="..\Shared.msbuild" />
@@ -15,12 +14,8 @@
1514
<ProjectReference Include="..\FluentNHibernate\FluentNHibernate.csproj" />
1615
</ItemGroup>
1716

18-
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
19-
<PackageReference Include="NHibernate" Version="5.1.0" />
20-
</ItemGroup>
21-
22-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
17+
<ItemGroup>
2318
<PackageReference Include="NHibernate" Version="5.1.0" />
2419
</ItemGroup>
25-
20+
2621
</Project>

src/FluentNHibernate.Specs/Automapping/AutoPersistenceModelSpecs.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using FluentNHibernate.Automapping;
66
using FluentNHibernate.Cfg;
77
using FluentNHibernate.Cfg.Db;
8-
using FluentNHibernate.MappingModel;
98
using FluentNHibernate.MappingModel.ClassBased;
109
using FluentNHibernate.Specs.Automapping.Fixtures;
1110
using FluentNHibernate.Specs.ExternalFixtures;
@@ -48,8 +47,10 @@ public class when_the_automapper_is_told_to_map_a_single_type
4847
public class when_the_automapper_is_ran_to_completion
4948
{
5049
Establish context = () =>
50+
5151
setup = Fluently.Configure()
52-
.Database(SQLiteConfiguration.Standard.InMemory)
52+
.Database(
53+
CreateStandardInMemoryConfiguration())
5354
.Mappings(x => x.AutoMappings.Add(AutoMap.Source(new StubTypeSource(typeof(Entity)))));
5455

5556
Because of = () =>
@@ -60,6 +61,18 @@ public class when_the_automapper_is_ran_to_completion
6061

6162
static FluentConfiguration setup;
6263
static Exception ex;
64+
65+
private static IPersistenceConfigurer CreateStandardInMemoryConfiguration()
66+
{
67+
#if NETFX
68+
var configuration = SQLiteConfiguration.Standard.InMemory();
69+
#endif
70+
71+
#if NETCORE
72+
var configuration = MsSqliteConfiguration.Standard.InMemory();
73+
#endif
74+
return configuration;
75+
}
6376
}
6477

6578
public class when_the_automapper_is_told_to_map_an_inheritance_hierarchy
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System.Linq;
1+
using FluentAssertions;
22
using FluentNHibernate.Conventions;
33
using FluentNHibernate.Conventions.Instances;
44
using FluentNHibernate.Mapping;
55
using FluentNHibernate.MappingModel.ClassBased;
66
using Machine.Specifications;
7-
using FluentAssertions;
7+
using System.Linq;
88

99
namespace FluentNHibernate.Specs.Conventions
1010
{
@@ -14,26 +14,25 @@ public class when_specifying_component_convention
1414
{
1515
model = new FluentNHibernate.PersistenceModel();
1616
model.Conventions.Add<ComponentConvention>();
17-
model.Add(new EntityWithComponentMap());
1817
model.Add(new AddressMap());
18+
model.Add(new EntityWithComponentMap());
1919
};
2020

2121
Because of = () =>
2222
{
23-
mapping = model.BuildMappingFor<EntityWithComponent>();
23+
mapping = model.BuildMappingFor<EntityWithComponent>();
2424
};
2525

2626
It should_be_able_to_specify_column_name = () =>
2727
{
28-
mapping.Components.First()
29-
.Properties.Single(x => x.Name == "Count")
30-
.Columns.FirstOrDefault().Name.Should().Be("Count");
31-
// TODO (we need to fix this test, is not working as expected)
32-
// .Columns.FirstOrDefault().Name.Should().Be("different");
28+
var property = mapping.Components.First()
29+
.Properties.Single(x => x.Name == "Count");
30+
31+
property.Columns.FirstOrDefault().Name.Should().Be("different");
3332
};
3433

35-
static FluentNHibernate.PersistenceModel model;
36-
static ClassMapping mapping;
34+
private static FluentNHibernate.PersistenceModel model;
35+
private static ClassMapping mapping;
3736
}
3837

3938
public class EntityWithComponent
@@ -50,7 +49,7 @@ public class Address
5049
public string Line2 { get; set; }
5150
}
5251

53-
class AddressMap: ComponentMap<Address>
52+
internal class AddressMap : ComponentMap<Address>
5453
{
5554
public AddressMap()
5655
{
@@ -60,20 +59,19 @@ public AddressMap()
6059
}
6160
}
6261

63-
public class ComponentConvention: IComponentConvention
62+
public class ComponentConvention : IComponentConvention
6463
{
65-
6664
public void Apply(IComponentInstance instance)
6765
{
6866
if (instance.Type == typeof(Address))
6967
{
70-
instance.Properties.First(p => p.Type.GetType() == typeof(int))
71-
.Column("different");
68+
var type = instance.Properties.First(p => p.Type == typeof(int));
69+
type.Column("different");
7270
}
7371
}
7472
}
7573

76-
public class EntityWithComponentMap: ClassMap<EntityWithComponent>
74+
public class EntityWithComponentMap : ClassMap<EntityWithComponent>
7775
{
7876
public EntityWithComponentMap()
7977
{
@@ -82,4 +80,4 @@ public EntityWithComponentMap()
8280
Component(x => x.Address);
8381
}
8482
}
85-
}
83+
}

src/FluentNHibernate.Specs/FluentNHibernate.Specs.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
55
<NoWarn>1591</NoWarn>
6-
<PlatformTarget>AnyCpu</PlatformTarget>
76
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp2.0'">Full</DebugType>
87
</PropertyGroup>
98

@@ -14,11 +13,6 @@
1413
<ProjectReference Include="..\FluentNHibernate\FluentNHibernate.csproj" />
1514
</ItemGroup>
1615

17-
<ItemGroup>
18-
<ProjectReference Include="..\FluentNHibernate.Specs.ExternalFixtures\FluentNHibernate.Specs.ExternalFixtures.csproj" />
19-
<ProjectReference Include="..\FluentNHibernate\FluentNHibernate.csproj" />
20-
</ItemGroup>
21-
2216
<ItemGroup>
2317
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
2418
<PackageReference Include="NHibernate" Version="5.1.0" />

src/FluentNHibernate.Testing/App.config

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<configSections>
4-
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
5-
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
64
</configSections>
75
<startup>
86
<supportedRuntime version="v2.0.50727"></supportedRuntime>
@@ -12,22 +10,9 @@
1210
</appSettings>
1311
<connectionStrings>
1412
<add name="main" connectionString="connection string" />
15-
</connectionStrings>
16-
<entityFramework>
17-
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
18-
<parameters>
19-
<parameter value="v13.0" />
20-
</parameters>
21-
</defaultConnectionFactory>
22-
<providers>
23-
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
24-
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
25-
</providers>
26-
</entityFramework>
13+
</connectionStrings>
2714
<system.data>
2815
<DbProviderFactories>
29-
<remove invariant="System.Data.SQLite.EF6" />
30-
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
3116
<remove invariant="System.Data.SQLite" />
3217
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
3318
</DbProviderFactories>

src/FluentNHibernate.Testing/AutoMapping/BaseAutoMapFixture.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using FluentNHibernate.Automapping;
3-
using FluentNHibernate.Cfg.Db;
43
using NHibernate.Cfg;
54
using NUnit.Framework;
5+
using static FluentNHibernate.Testing.Cfg.SQLiteFrameworkConfigurationFactory;
66

77
namespace FluentNHibernate.Testing.Automapping
88
{
@@ -16,8 +16,7 @@ public void CreateDatabaseCfg()
1616
{
1717
cfg = new Configuration();
1818

19-
SQLiteConfiguration.Standard
20-
.InMemory()
19+
CreateStandardInMemoryConfiguration()
2120
.ConfigureProperties(cfg);
2221
}
2322

src/FluentNHibernate.Testing/Cfg/Db/ConnectionStringBuilderTester.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,23 @@ public void CanExplicitlySetConnectionString()
2222
builder.ConnectionString.ShouldEqual("a string");
2323
}
2424

25+
#if NETFX
2526
[Test]
2627
public void ConnectionStringSetFromAppSetting()
2728
{
2829
builder.FromAppSetting("connectionString");
2930
builder.ConnectionString.ShouldContain("a-connection-string");
3031
}
32+
#endif
3133

34+
#if NETFX
3235
[Test]
3336
public void ConnectionStringSetFromConnectionStrings()
3437
{
3538
builder.FromConnectionStringWithKey("main");
3639
builder.ConnectionString.ShouldContain("connection string");
3740
}
41+
#endif
3842

3943
private class ConnectionStringBuilderDouble : ConnectionStringBuilder
4044
{

src/FluentNHibernate.Testing/Cfg/Db/DB2400ConfigurationTester.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void ConnectionStringSetExplicitly()
3939
.ToProperties().ShouldContain("connection.connection_string", "value");
4040
}
4141

42+
#if NETFX
4243
[Test]
4344
public void ConnectionStringSetFromAppSetting()
4445
{
@@ -47,7 +48,9 @@ public void ConnectionStringSetFromAppSetting()
4748
.FromAppSetting("connectionString"))
4849
.ToProperties().ShouldContain("connection.connection_string", "a-connection-string");
4950
}
51+
#endif
5052

53+
#if NETFX
5154
[Test]
5255
public void ConnectionStringSetFromConnectionStrings()
5356
{
@@ -56,6 +59,7 @@ public void ConnectionStringSetFromConnectionStrings()
5659
.FromConnectionStringWithKey("main"))
5760
.ToProperties().ShouldContain("connection.connection_string", "connection string");
5861
}
62+
#endif
5963

6064
[Test]
6165
public void ShouldBeAbleToSpecifyConnectionStringDirectly()

0 commit comments

Comments
 (0)