Skip to content

Commit 8229837

Browse files
Merge branch 'master' into tableAlias
2 parents aa97d5c + f076ee4 commit 8229837

31 files changed

+431
-106
lines changed

Tools/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
88
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
99
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
10-
<package id="CSharpAsyncGenerator.CommandLine" version="0.7.0" targetFramework="net461" />
10+
<package id="CSharpAsyncGenerator.CommandLine" version="0.8.1" targetFramework="net461" />
1111
<package id="vswhere" version="2.1.4" targetFramework="net461" />
1212
</packages>

src/AsyncGenerator.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
projects:
22
- filePath: NHibernate/NHibernate.csproj
3+
targetFramework: net461
34
concurrentRun: true
45
applyChanges: true
56
analyzation:
@@ -156,13 +157,15 @@
156157
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
157158
assemblyName: AsyncGenerator.Core
158159
- filePath: NHibernate.DomainModel/NHibernate.DomainModel.csproj
160+
targetFramework: net461
159161
concurrentRun: true
160162
applyChanges: true
161163
analyzation:
162164
scanMethodBody: true
163165
scanForMissingAsyncMembers:
164166
- all: true
165167
- filePath: NHibernate.Test/NHibernate.Test.csproj
168+
targetFramework: net461
166169
concurrentRun: true
167170
applyChanges: true
168171
analyzation:

src/NHibernate.Test/Async/Events/Collections/Association/Bidirectional/ManyToMany/BidirectionalManyToManyBagToSetCollectionEventFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public override Task UpdateParentOneToTwoSameChildrenAsync()
3939
{
4040
Assert.Ignore("Not supported");
4141
return Task.CompletedTask;
42+
// This test need some more deep study if it really work in H3.2
43+
// because <bag> allow duplication.
4244
}
4345
catch (System.Exception ex)
4446
{
4547
return Task.FromException<object>(ex);
4648
}
47-
// This test need some more deep study if it really work in H3.2
48-
// because <bag> allow duplication.
4949
}
5050
}
5151
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using NHibernate.Collection;
12+
using NSubstitute;
13+
using NUnit.Framework;
14+
15+
namespace NHibernate.Test.NHSpecificTest.GH1515
16+
{
17+
using System.Threading.Tasks;
18+
using System.Threading;
19+
[TestFixture]
20+
public class FixtureAsync
21+
{
22+
23+
[Test]
24+
public async Task IntializeForwaredToLazyCollectionAsync()
25+
{
26+
var collection = Substitute.For<ILazyInitializedCollection>();
27+
28+
await (NHibernateUtil.InitializeAsync(collection));
29+
30+
await (collection.Received().ForceInitializationAsync(CancellationToken.None));
31+
}
32+
33+
[Test]
34+
public async Task IntializeForwaredToPersistentCollectionAsync()
35+
{
36+
var collection = Substitute.For<IPersistentCollection>();
37+
38+
await (NHibernateUtil.InitializeAsync(collection));
39+
40+
await (collection.Received().ForceInitializationAsync(CancellationToken.None));
41+
}
42+
43+
44+
}
45+
}

src/NHibernate.Test/MappingExceptions/PropertyNotFoundExceptionFixture.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using NHibernate.Cfg;
3+
using NHibernate.Util;
34
using NUnit.Framework;
45

56
namespace NHibernate.Test.MappingExceptions
@@ -44,5 +45,21 @@ public void ConstructWithNullType()
4445
new PropertyNotFoundException(null, "someField");
4546
new PropertyNotFoundException(null, "SomeProperty", "getter");
4647
}
48+
49+
[Test]
50+
public void IsSerializable()
51+
{
52+
NHAssert.IsSerializable(new PropertyNotFoundException(null, "someField"));
53+
NHAssert.IsSerializable(new PropertyNotFoundException(null, "SomeProperty", "getter"));
54+
}
55+
56+
[Test]
57+
public void SerializeWithType()
58+
{
59+
var bytes = SerializationHelper.Serialize(new PropertyNotFoundException(typeof(PropertyNotFoundExceptionFixture), "SomeProperty", "getter"));
60+
var pnfe = (PropertyNotFoundException) SerializationHelper.Deserialize(bytes);
61+
62+
Assert.That(pnfe.TargetType, Is.EqualTo(typeof(PropertyNotFoundExceptionFixture)));
63+
}
4764
}
48-
}
65+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using NHibernate.Collection;
2+
using NSubstitute;
3+
using NUnit.Framework;
4+
5+
namespace NHibernate.Test.NHSpecificTest.GH1515
6+
{
7+
[TestFixture]
8+
public class Fixture
9+
{
10+
[Test]
11+
public void IsInitializedCallsWasInitializedFromLazyCollection()
12+
{
13+
var collection = Substitute.For<ILazyInitializedCollection>();
14+
15+
NHibernateUtil.IsInitialized(collection);
16+
17+
var assertRes = collection.Received().WasInitialized;
18+
}
19+
20+
[Test]
21+
public void IntializeForwaredToLazyCollection()
22+
{
23+
var collection = Substitute.For<ILazyInitializedCollection>();
24+
25+
NHibernateUtil.Initialize(collection);
26+
27+
collection.Received().ForceInitialization();
28+
}
29+
30+
[Test]
31+
public void IsInitializedCallsWasInitializedFromPersistentCollection()
32+
{
33+
var collection = Substitute.For<IPersistentCollection>();
34+
35+
NHibernateUtil.IsInitialized(collection);
36+
37+
var assertRes = collection.Received().WasInitialized;
38+
}
39+
40+
[Test]
41+
public void IntializeForwaredToPersistentCollection()
42+
{
43+
var collection = Substitute.For<IPersistentCollection>();
44+
45+
NHibernateUtil.Initialize(collection);
46+
47+
collection.Received().ForceInitialization();
48+
}
49+
50+
51+
}
52+
}

src/NHibernate/Async/Action/BulkOperationCleanupAction.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public Task BeforeExecutionsAsync(CancellationToken cancellationToken)
3838
{
3939
return Task.FromException<object>(ex);
4040
}
41-
// nothing to do
4241
}
4342

4443
public Task ExecuteAsync(CancellationToken cancellationToken)
@@ -56,7 +55,6 @@ public Task ExecuteAsync(CancellationToken cancellationToken)
5655
{
5756
return Task.FromException<object>(ex);
5857
}
59-
// nothing to do
6058
}
6159

6260
private async Task EvictCollectionRegionsAsync(CancellationToken cancellationToken)

src/NHibernate/Async/Cache/HashtableCache.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ public Task LockAsync(object key, CancellationToken cancellationToken)
107107
{
108108
return Task.FromException<object>(ex);
109109
}
110-
// local cache, so we use synchronization
111110
}
112111

113112
/// <summary></summary>
@@ -126,7 +125,6 @@ public Task UnlockAsync(object key, CancellationToken cancellationToken)
126125
{
127126
return Task.FromException<object>(ex);
128127
}
129-
// local cache, so we use synchronization
130128
}
131129

132130
#endregion

src/NHibernate/Async/Cache/ReadOnlyCache.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ public Task EvictAsync(CacheKey key, CancellationToken cancellationToken)
169169
{
170170
return Task.FromException<object>(ex);
171171
}
172-
// NOOP
173172
}
174173

175174
/// <summary>

src/NHibernate/Async/Cache/ReadWriteCache.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ public Task EvictAsync(CacheKey key, CancellationToken cancellationToken)
383383
{
384384
return Task.FromException<object>(ex);
385385
}
386-
// NOOP
387386
}
388387

389388
public Task<bool> UpdateAsync(CacheKey key, object value, object currentVersion, object previousVersion, CancellationToken cancellationToken)

src/NHibernate/Async/Collection/AbstractPersistentCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace NHibernate.Collection
2424
{
2525
using System.Threading.Tasks;
2626
using System.Threading;
27-
public abstract partial class AbstractPersistentCollection : IPersistentCollection
27+
public abstract partial class AbstractPersistentCollection : IPersistentCollection, ILazyInitializedCollection
2828
{
2929

3030
/// <summary>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
namespace NHibernate.Collection
12+
{
13+
using System.Threading.Tasks;
14+
using System.Threading;
15+
public partial interface ILazyInitializedCollection
16+
{
17+
18+
/// <summary>
19+
/// Force immediate initialization.
20+
/// </summary>
21+
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
22+
Task ForceInitializationAsync(CancellationToken cancellationToken);
23+
24+
}
25+
}

src/NHibernate/Async/NHibernateUtil.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,17 @@ public static partial class NHibernateUtil
4848
{
4949
return ((INHibernateProxy)proxy).HibernateLazyInitializer.InitializeAsync(cancellationToken);
5050
}
51-
else if (proxy is IPersistentCollection coll)
51+
else if (proxy is ILazyInitializedCollection coll)
5252
{
5353
return coll.ForceInitializationAsync(cancellationToken);
5454
}
55+
// 6.0 TODO: remove once IPersistentCollection derives from ILazyInitializedCollection
56+
else if (proxy is IPersistentCollection persistent)
57+
{
58+
return persistent.ForceInitializationAsync(cancellationToken);
59+
}
5560
return Task.CompletedTask;
61+
5662
}
5763
catch (Exception ex)
5864
{

src/NHibernate/Async/Type/CollectionType.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public override Task NullSafeSetAsync(DbCommand st, object value, int index, boo
6262
{
6363
return Task.FromException<object>(ex);
6464
}
65-
// NOOP
6665
}
6766

6867
public override Task NullSafeSetAsync(DbCommand cmd, object value, int index, ISessionImplementor session, CancellationToken cancellationToken)

src/NHibernate/Async/Type/OneToOneType.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public override Task NullSafeSetAsync(DbCommand st, object value, int index, boo
3737
{
3838
return Task.FromException<object>(ex);
3939
}
40-
//nothing to do
4140
}
4241

4342
public override Task NullSafeSetAsync(DbCommand cmd, object value, int index, ISessionImplementor session, CancellationToken cancellationToken)
@@ -55,7 +54,6 @@ public override Task NullSafeSetAsync(DbCommand cmd, object value, int index, IS
5554
{
5655
return Task.FromException<object>(ex);
5756
}
58-
//nothing to do
5957
}
6058

6159
public override Task<bool> IsDirtyAsync(object old, object current, ISessionImplementor session, CancellationToken cancellationToken)
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
using System;
22
using System.Runtime.Serialization;
3+
using System.Security;
34

45
namespace NHibernate.Bytecode
56
{
67
[Serializable]
78
public class UnableToLoadProxyFactoryFactoryException : HibernateByteCodeException
89
{
9-
private readonly string typeName;
10+
1011
public UnableToLoadProxyFactoryFactoryException(string typeName, Exception inner)
1112
: base("", inner)
1213
{
13-
this.typeName = typeName;
14+
TypeName = typeName;
15+
}
16+
17+
protected UnableToLoadProxyFactoryFactoryException(SerializationInfo info, StreamingContext context)
18+
: base(info, context)
19+
{
20+
foreach (var entry in info)
21+
{
22+
if (entry.Name == "TypeName")
23+
{
24+
TypeName = entry.Value?.ToString();
25+
}
26+
}
27+
}
28+
29+
[SecurityCritical]
30+
public override void GetObjectData(SerializationInfo info, StreamingContext context)
31+
{
32+
base.GetObjectData(info, context);
33+
info.AddValue("TypeName", TypeName);
1434
}
1535

16-
protected UnableToLoadProxyFactoryFactoryException(SerializationInfo info,
17-
StreamingContext context) : base(info, context) {}
36+
public string TypeName { get; }
1837
public override string Message
1938
{
2039
get
@@ -28,10 +47,10 @@ public override string Message
2847
Confirm that your deployment folder contains one of the following assemblies:
2948
NHibernate.ByteCode.LinFu.dll
3049
NHibernate.ByteCode.Castle.dll";
31-
string msg = "Unable to load type '" + typeName + "' during configuration of proxy factory class." + causes;
50+
string msg = "Unable to load type '" + TypeName + "' during configuration of proxy factory class." + causes;
3251

3352
return msg;
3453
}
3554
}
3655
}
37-
}
56+
}

src/NHibernate/Collection/AbstractPersistentCollection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ namespace NHibernate.Collection
1515
/// <summary>
1616
/// Base class for implementing <see cref="IPersistentCollection"/>.
1717
/// </summary>
18+
// 6.0 TODO: remove ILazyInitializedCollection once IPersistentCollection derives from it
1819
[Serializable]
19-
public abstract partial class AbstractPersistentCollection : IPersistentCollection
20+
public abstract partial class AbstractPersistentCollection : IPersistentCollection, ILazyInitializedCollection
2021
{
2122
protected internal static readonly object Unknown = new object(); //place holder
2223
protected internal static readonly object NotFound = new object(); //place holder

0 commit comments

Comments
 (0)