Skip to content

Commit

Permalink
Merge branch 'release/3.0.1' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
craigfowler committed Feb 20, 2021
2 parents 478ec72 + 4f7648c commit 715a637
Show file tree
Hide file tree
Showing 35 changed files with 243 additions and 317 deletions.
6 changes: 5 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: '{branch}-{build}'
image: Visual Studio 2017
image: Visual Studio 2019

environment:
JAVA_HOME: "C:\\Program Files\\Java\\jdk13"

init:
- cmd: git config --global core.autocrlf true
Expand All @@ -18,6 +21,7 @@ build_script:

test_script:
- cmd: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=\"json,opencover\" /p:CoverletOutput=\"TestResults/\" --test-adapter-path:. --logger:\"nunit\"
- cmd: dotnet test -c NetFramework

after_test:
- cmd: dotnet-sonarscanner end /d:"sonar.login=%SONARCLOUD_SECRET_KEY%"
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ solution: CSF.ORM.sln

jobs:
include:
- dotnet: 2.2.207
- dotnet: 3.1.403
mono: latest

script:
- dotnet build
- dotnet test
- dotnet test -c NetFramework
49 changes: 49 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "test",
"command": "dotnet",
"type": "shell",
"args": [
"test",
"/property:GenerateFullPaths=true"
],
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": "$msCompile"
},
{
"label": "test with .NET Framework 4.7.2",
"command": "dotnet",
"type": "shell",
"args": [
"test",
"/property:GenerateFullPaths=true",
"-c:NetFramework"
],
"group": "test",
"problemMatcher": "$msCompile"
}
]
}
17 changes: 5 additions & 12 deletions CSF.Entities/CSF.Entities.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="'$(Configuration)' != 'Debug_SingleTarget'">
<TargetFrameworks>netstandard2.0;net45;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug_SingleTarget'">
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<PackageId>CSF.Entities</PackageId>
<Authors>craigfowler</Authors>
<Title>Entity &amp; identity types</Title>
<Description>Interfaces &amp; base types to describe ORM-mapped entities and their identities.</Description>
<ReleaseVersion>3.0.0</ReleaseVersion>
<ReleaseVersion>3.0.1</ReleaseVersion>
<Version>$(ReleaseVersion)</Version>
<PackageVersion>$(ReleaseVersion)</PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -30,12 +25,10 @@
<DebugType></DebugType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.Entities.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_SingleTarget|AnyCPU' ">
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.Entities.xml</DocumentationFile>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>

<Import Project="..\Tools\EnableNet45BuildOnUnix.targets" />
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Condition=" '$(EnableDefaultEmbeddedResourceItems)' == 'true' " Update="Resources\ExceptionMessages.resx">
Expand Down
2 changes: 1 addition & 1 deletion CSF.Entities/Entity`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object IEntity.IdentityValue
/// </summary>
/// <returns>The converted value.</returns>
/// <param name="value">The value to convert.</param>
TIdentity ToIdentityType(object value)
static TIdentity ToIdentityType(object value)
{
var formatter = System.Globalization.CultureInfo.InvariantCulture;
var converted = Convert.ChangeType(value, typeof(TIdentity), formatter);
Expand Down
14 changes: 7 additions & 7 deletions CSF.Entities/IdentityFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public class IdentityFactory : ICreatesIdentity
{
static readonly IGetsIdentityType identityTypeProvider = new IdentityTypeProvider();

/// <summary>
/// Create an identity from the specified parameters.
/// </summary>
/// <returns>The created identity, or a <c>null</c> reference if the identity value is equal to the default of its data-type.</returns>
/// <param name="entityType">The entity type.</param>
/// <param name="identityValue">The identity value.</param>
/// <summary>
/// Create an identity from the specified parameters.
/// </summary>
/// <returns>The created identity, or a <c>null</c> reference if the identity value is equal to the default of its data-type.</returns>
/// <param name="entityType">The entity type.</param>
/// <param name="identityValue">The identity value.</param>
public IIdentity Create(Type entityType, object identityValue)
{
if (entityType == null)
Expand Down Expand Up @@ -79,7 +79,7 @@ public IIdentity Create(Type entityType, Type identityType, object identityValue
return (IIdentity)Activator.CreateInstance(closedIdentityType, new[] { convertedValue });
}

object GetDefaultValue(Type identityType)
static object GetDefaultValue(Type identityType)
=> identityType.IsValueType ? Activator.CreateInstance(identityType) : null;
}
}
19 changes: 5 additions & 14 deletions CSF.ORM.Entities/CSF.ORM.Entities.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">


<PropertyGroup Condition="'$(Configuration)' != 'Debug_SingleTarget'">
<TargetFrameworks>netstandard2.0;net45;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug_SingleTarget'">
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<PackageId>CSF.ORM.Entities</PackageId>
<Authors>craigfowler</Authors>
<Title>ORM abstractions: Entity integration</Title>
<Description>An integration between CSF.ORM and CSF.Entities, providing convenience functionality for projects which use both.</Description>
<ReleaseVersion>3.0.0</ReleaseVersion>
<ReleaseVersion>3.0.1</ReleaseVersion>
<Version>$(ReleaseVersion)</Version>
<PackageVersion>$(ReleaseVersion)</PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -25,7 +18,9 @@
<RootNamespace>CSF.ORM</RootNamespace>
</PropertyGroup>

<Import Project="..\Tools\EnableNet45BuildOnUnix.targets" />
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.Entities.xml</DocumentationFile>
Expand All @@ -35,10 +30,6 @@
<DebugType></DebugType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.Entities.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_SingleTarget|AnyCPU' ">
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.Entities.xml</DocumentationFile>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\CSF.Entities\CSF.Entities.csproj" />
<ProjectReference Include="..\CSF.ORM\CSF.ORM.csproj" />
Expand Down
18 changes: 7 additions & 11 deletions CSF.ORM.Entities/EntityData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,17 @@ public void Update<TEntity>(TEntity entity) where TEntity : class, IEntity
if (entity == null)
throw new ArgumentNullException(nameof(entity));

return AddAsyncInternal(entity, token);
return AddInternalAsync(entity, token);
}

async Task<IIdentity<TEntity>> AddAsyncInternal<TEntity>(TEntity entity, CancellationToken token = default(CancellationToken)) where TEntity : class, IEntity
async Task<IIdentity<TEntity>> AddInternalAsync<TEntity>(TEntity entity, CancellationToken token = default(CancellationToken)) where TEntity : class, IEntity
{
var identity = entity.GetIdentity();
object idValue;
if (identity != null)
{
idValue = await persister.AddAsync(entity, identity.Value, token);
return ReferenceEquals(idValue, null) ? null : (IIdentity<TEntity>)idFactory.Create(typeof(TEntity), idValue);
}
var currentIdentity = entity.GetIdentity();
var currentIdentityValue = (currentIdentity != null)? currentIdentity.Value : null;

idValue = await persister.AddAsync(entity, null, token);
return ReferenceEquals(idValue, null) ? null : (IIdentity<TEntity>)idFactory.Create(typeof(TEntity), idValue);
var newIdentityValue = await persister.AddAsync(entity, currentIdentityValue, token)
.ConfigureAwait(false);
return (newIdentityValue is null) ? null : (IIdentity<TEntity>) idFactory.Create(typeof(TEntity), newIdentityValue);
}

/// <summary>
Expand Down
8 changes: 5 additions & 3 deletions CSF.ORM.Entities/IdentityGeneratingPersisterDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,17 @@ public void Delete<T>(T item, object identity) where T : class
public async Task<object> AddAsync<T>(T item, object identity = null, CancellationToken token = default(CancellationToken)) where T : class
{
if (identity != null)
return await wrapped.AddAsync<T>(item, identity, token);
return await wrapped.AddAsync<T>(item, identity, token).ConfigureAwait(false);

if (item is IEntity entity)
{
identityGenerator.UpdateWithIdentity(entity);
return await wrapped.AddAsync<T>((T)entity, entity.IdentityValue, token);
return await wrapped.AddAsync<T>((T)entity, entity.IdentityValue, token)
.ConfigureAwait(false);
}

return await wrapped.AddAsync<T>(item, identity, token);
return await wrapped.AddAsync<T>(item, identity, token)
.ConfigureAwait(false);
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion CSF.ORM.Entities/IdentityPopulatingTheoryQueryDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public TQueried Theorise<TQueried>(object identityValue) where TQueried : class
/// <typeparam name="TQueried">The type of object to retrieve.</typeparam>
public async Task<TQueried> TheoriseAsync<TQueried>(object identityValue, CancellationToken token = default(CancellationToken)) where TQueried : class
{
var output = await wrapped.TheoriseAsync<TQueried>(identityValue, token);
var output = await wrapped.TheoriseAsync<TQueried>(identityValue, token)
.ConfigureAwait(false);

if (output is IEntity entity && !entity.HasIdentity)
entity.IdentityValue = identityValue;
Expand Down
26 changes: 5 additions & 21 deletions CSF.ORM.NHibernate.Common/CSF.ORM.NHibernate.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="'$(Configuration)' != 'Debug_SingleTarget'">
<TargetFrameworks>netstandard2.0;net45;net461;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug_SingleTarget'">
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net461</TargetFrameworks>
<IsPackable>false</IsPackable>
<ReleaseVersion>3.0.0</ReleaseVersion>
<ReleaseVersion>3.0.1</ReleaseVersion>
<Version>$(ReleaseVersion)</Version>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\CSF-Software-OSS.snk</AssemblyOriginatorKeyFile>
Expand All @@ -24,25 +17,16 @@
<DebugType></DebugType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.NHibernate.Common.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_SingleTarget|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.NHibernate.Common.xml</DocumentationFile>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>

<Import Project="..\Tools\EnableNet45BuildOnUnix.targets" />
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'" />
</ItemGroup>

<ItemGroup>
<Reference Include="System.Runtime" Condition="$(TargetFramework.StartsWith('net4'))" />
<Reference Include="System.Configuration" Condition="$(TargetFramework.StartsWith('net4'))" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" Condition="$(TargetFramework) == 'netstandard2.0'" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.112" Condition="$(TargetFramework) == 'netstandard2.0'" />
<PackageReference Include="System.Security.Permissions" Version="4.4.0" Condition="$(TargetFramework) == 'netstandard2.0'" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.0" Condition="$(TargetFramework) == 'netstandard2.0'">
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="NHibernate" Version="4.0.0.4000">
<NoWarn>NU1701</NoWarn>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions CSF.ORM.NHibernate.Common/EagerFetchingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public IQueryableWithEagerFetching<TQueried, TGrandchild> FetchGrandchildren<TQu
return new QueryableWithFetchingAdapter<TQueried, TGrandchild>(nhFetchRequest);
}

IQueryable<T> GetUnderlyingQueryIfAvailable<T>(IQueryable<T> query)
static IQueryable<T> GetUnderlyingQueryIfAvailable<T>(IQueryable<T> query)
=> (query is IProvidesQueryable<T> queryProvider) ? queryProvider.GetQueryable() : query;

INhFetchRequest<TQueried, TFetched> GetNhFetchRequest<TQueried, TFetched>(IQueryable<TQueried> query)
static INhFetchRequest<TQueried, TFetched> GetNhFetchRequest<TQueried, TFetched>(IQueryable<TQueried> query)
=> GetUnderlyingQueryIfAvailable(query) as INhFetchRequest<TQueried, TFetched>;

}
Expand Down
25 changes: 5 additions & 20 deletions CSF.ORM.NHibernate4/CSF.ORM.NHibernate4.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="'$(Configuration)' != 'Debug_SingleTarget'">
<TargetFrameworks>netstandard2.0;net45;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug_SingleTarget'">
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<PackageId>CSF.ORM.NHibernate4</PackageId>
<Authors>craigfowler</Authors>
<Title>ORM abstractions: Implementation for NHibernate 4</Title>
<Description>Implementation of the ORM abstractions for users of NHibernate version 4.x.</Description>
<ReleaseVersion>3.0.0</ReleaseVersion>
<ReleaseVersion>3.0.1</ReleaseVersion>
<Version>$(ReleaseVersion)</Version>
<PackageVersion>$(ReleaseVersion)</PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -34,12 +27,10 @@
<DebugType></DebugType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.NHibernate4.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_SingleTarget|AnyCPU' ">
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.NHibernate4.xml</DocumentationFile>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>

<Import Project="..\Tools\EnableNet45BuildOnUnix.targets" />
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Condition=" '$(EnableDefaultEmbeddedResourceItems)' == 'true' " Update="Resources\ExceptionMessages.resx">
Expand All @@ -61,12 +52,6 @@
<Reference Include="System.Configuration" Condition="$(TargetFramework.StartsWith('net4'))" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" Condition="$(TargetFramework) == 'netstandard2.0'" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.112" Condition="$(TargetFramework) == 'netstandard2.0'" />
<PackageReference Include="System.Security.Permissions" Version="4.4.0" Condition="$(TargetFramework) == 'netstandard2.0'" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.0" Condition="$(TargetFramework) == 'netstandard2.0'">
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="NHibernate" Version="4.0.0.4000">
<NoWarn>NU1701</NoWarn>
</PackageReference>
Expand Down
Loading

0 comments on commit 715a637

Please sign in to comment.