Skip to content

Commit 715a637

Browse files
committed
Merge branch 'release/3.0.1' into production
2 parents 478ec72 + 4f7648c commit 715a637

35 files changed

Lines changed: 243 additions & 317 deletions

.appveyor.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
version: '{branch}-{build}'
2-
image: Visual Studio 2017
2+
image: Visual Studio 2019
3+
4+
environment:
5+
JAVA_HOME: "C:\\Program Files\\Java\\jdk13"
36

47
init:
58
- cmd: git config --global core.autocrlf true
@@ -18,6 +21,7 @@ build_script:
1821

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

2226
after_test:
2327
- cmd: dotnet-sonarscanner end /d:"sonar.login=%SONARCLOUD_SECRET_KEY%"

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ solution: CSF.ORM.sln
33

44
jobs:
55
include:
6-
- dotnet: 2.2.207
6+
- dotnet: 3.1.403
77
mono: latest
88

99
script:
1010
- dotnet build
1111
- dotnet test
12+
- dotnet test -c NetFramework

.vscode/tasks.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "shell",
8+
"args": [
9+
"build",
10+
"/property:GenerateFullPaths=true",
11+
"/consoleloggerparameters:NoSummary"
12+
],
13+
"group": {
14+
"kind": "build",
15+
"isDefault": true
16+
},
17+
"presentation": {
18+
"reveal": "silent"
19+
},
20+
"problemMatcher": "$msCompile"
21+
},
22+
{
23+
"label": "test",
24+
"command": "dotnet",
25+
"type": "shell",
26+
"args": [
27+
"test",
28+
"/property:GenerateFullPaths=true"
29+
],
30+
"group": {
31+
"kind": "test",
32+
"isDefault": true
33+
},
34+
"problemMatcher": "$msCompile"
35+
},
36+
{
37+
"label": "test with .NET Framework 4.7.2",
38+
"command": "dotnet",
39+
"type": "shell",
40+
"args": [
41+
"test",
42+
"/property:GenerateFullPaths=true",
43+
"-c:NetFramework"
44+
],
45+
"group": "test",
46+
"problemMatcher": "$msCompile"
47+
}
48+
]
49+
}

CSF.Entities/CSF.Entities.csproj

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup Condition="'$(Configuration)' != 'Debug_SingleTarget'">
4-
<TargetFrameworks>netstandard2.0;net45;netcoreapp2.0</TargetFrameworks>
5-
</PropertyGroup>
6-
<PropertyGroup Condition="'$(Configuration)' == 'Debug_SingleTarget'">
7-
<TargetFramework>netstandard2.0</TargetFramework>
8-
</PropertyGroup>
93
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
105
<PackageId>CSF.Entities</PackageId>
116
<Authors>craigfowler</Authors>
127
<Title>Entity &amp; identity types</Title>
138
<Description>Interfaces &amp; base types to describe ORM-mapped entities and their identities.</Description>
14-
<ReleaseVersion>3.0.0</ReleaseVersion>
9+
<ReleaseVersion>3.0.1</ReleaseVersion>
1510
<Version>$(ReleaseVersion)</Version>
1611
<PackageVersion>$(ReleaseVersion)</PackageVersion>
1712
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -30,12 +25,10 @@
3025
<DebugType></DebugType>
3126
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.Entities.xml</DocumentationFile>
3227
</PropertyGroup>
33-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_SingleTarget|AnyCPU' ">
34-
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.Entities.xml</DocumentationFile>
35-
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
36-
</PropertyGroup>
3728

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

4033
<ItemGroup>
4134
<EmbeddedResource Condition=" '$(EnableDefaultEmbeddedResourceItems)' == 'true' " Update="Resources\ExceptionMessages.resx">

CSF.Entities/Entity`1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ object IEntity.IdentityValue
7474
/// </summary>
7575
/// <returns>The converted value.</returns>
7676
/// <param name="value">The value to convert.</param>
77-
TIdentity ToIdentityType(object value)
77+
static TIdentity ToIdentityType(object value)
7878
{
7979
var formatter = System.Globalization.CultureInfo.InvariantCulture;
8080
var converted = Convert.ChangeType(value, typeof(TIdentity), formatter);

CSF.Entities/IdentityFactory.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public class IdentityFactory : ICreatesIdentity
3333
{
3434
static readonly IGetsIdentityType identityTypeProvider = new IdentityTypeProvider();
3535

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

82-
object GetDefaultValue(Type identityType)
82+
static object GetDefaultValue(Type identityType)
8383
=> identityType.IsValueType ? Activator.CreateInstance(identityType) : null;
8484
}
8585
}

CSF.ORM.Entities/CSF.ORM.Entities.csproj

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
4-
<PropertyGroup Condition="'$(Configuration)' != 'Debug_SingleTarget'">
5-
<TargetFrameworks>netstandard2.0;net45;netcoreapp2.0</TargetFrameworks>
6-
</PropertyGroup>
7-
<PropertyGroup Condition="'$(Configuration)' == 'Debug_SingleTarget'">
8-
<TargetFramework>netstandard2.0</TargetFramework>
9-
</PropertyGroup>
10-
113
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
125
<PackageId>CSF.ORM.Entities</PackageId>
136
<Authors>craigfowler</Authors>
147
<Title>ORM abstractions: Entity integration</Title>
158
<Description>An integration between CSF.ORM and CSF.Entities, providing convenience functionality for projects which use both.</Description>
16-
<ReleaseVersion>3.0.0</ReleaseVersion>
9+
<ReleaseVersion>3.0.1</ReleaseVersion>
1710
<Version>$(ReleaseVersion)</Version>
1811
<PackageVersion>$(ReleaseVersion)</PackageVersion>
1912
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -25,7 +18,9 @@
2518
<RootNamespace>CSF.ORM</RootNamespace>
2619
</PropertyGroup>
2720

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

3025
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
3126
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.Entities.xml</DocumentationFile>
@@ -35,10 +30,6 @@
3530
<DebugType></DebugType>
3631
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.Entities.xml</DocumentationFile>
3732
</PropertyGroup>
38-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_SingleTarget|AnyCPU' ">
39-
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\CSF.ORM.Entities.xml</DocumentationFile>
40-
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
41-
</PropertyGroup>
4233
<ItemGroup>
4334
<ProjectReference Include="..\CSF.Entities\CSF.Entities.csproj" />
4435
<ProjectReference Include="..\CSF.ORM\CSF.ORM.csproj" />

CSF.ORM.Entities/EntityData.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,17 @@ public void Update<TEntity>(TEntity entity) where TEntity : class, IEntity
162162
if (entity == null)
163163
throw new ArgumentNullException(nameof(entity));
164164

165-
return AddAsyncInternal(entity, token);
165+
return AddInternalAsync(entity, token);
166166
}
167167

168-
async Task<IIdentity<TEntity>> AddAsyncInternal<TEntity>(TEntity entity, CancellationToken token = default(CancellationToken)) where TEntity : class, IEntity
168+
async Task<IIdentity<TEntity>> AddInternalAsync<TEntity>(TEntity entity, CancellationToken token = default(CancellationToken)) where TEntity : class, IEntity
169169
{
170-
var identity = entity.GetIdentity();
171-
object idValue;
172-
if (identity != null)
173-
{
174-
idValue = await persister.AddAsync(entity, identity.Value, token);
175-
return ReferenceEquals(idValue, null) ? null : (IIdentity<TEntity>)idFactory.Create(typeof(TEntity), idValue);
176-
}
170+
var currentIdentity = entity.GetIdentity();
171+
var currentIdentityValue = (currentIdentity != null)? currentIdentity.Value : null;
177172

178-
idValue = await persister.AddAsync(entity, null, token);
179-
return ReferenceEquals(idValue, null) ? null : (IIdentity<TEntity>)idFactory.Create(typeof(TEntity), idValue);
173+
var newIdentityValue = await persister.AddAsync(entity, currentIdentityValue, token)
174+
.ConfigureAwait(false);
175+
return (newIdentityValue is null) ? null : (IIdentity<TEntity>) idFactory.Create(typeof(TEntity), newIdentityValue);
180176
}
181177

182178
/// <summary>

CSF.ORM.Entities/IdentityGeneratingPersisterDecorator.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,17 @@ public void Delete<T>(T item, object identity) where T : class
9494
public async Task<object> AddAsync<T>(T item, object identity = null, CancellationToken token = default(CancellationToken)) where T : class
9595
{
9696
if (identity != null)
97-
return await wrapped.AddAsync<T>(item, identity, token);
97+
return await wrapped.AddAsync<T>(item, identity, token).ConfigureAwait(false);
9898

9999
if (item is IEntity entity)
100100
{
101101
identityGenerator.UpdateWithIdentity(entity);
102-
return await wrapped.AddAsync<T>((T)entity, entity.IdentityValue, token);
102+
return await wrapped.AddAsync<T>((T)entity, entity.IdentityValue, token)
103+
.ConfigureAwait(false);
103104
}
104105

105-
return await wrapped.AddAsync<T>(item, identity, token);
106+
return await wrapped.AddAsync<T>(item, identity, token)
107+
.ConfigureAwait(false);
106108
}
107109

108110
/// <summary>

CSF.ORM.Entities/IdentityPopulatingTheoryQueryDecorator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public TQueried Theorise<TQueried>(object identityValue) where TQueried : class
9191
/// <typeparam name="TQueried">The type of object to retrieve.</typeparam>
9292
public async Task<TQueried> TheoriseAsync<TQueried>(object identityValue, CancellationToken token = default(CancellationToken)) where TQueried : class
9393
{
94-
var output = await wrapped.TheoriseAsync<TQueried>(identityValue, token);
94+
var output = await wrapped.TheoriseAsync<TQueried>(identityValue, token)
95+
.ConfigureAwait(false);
9596

9697
if (output is IEntity entity && !entity.HasIdentity)
9798
entity.IdentityValue = identityValue;

0 commit comments

Comments
 (0)