Skip to content

Commit 87d5f71

Browse files
Merge branch 'master' into feature/no-reflection-serialization
2 parents 1d3dfb0 + 03d5aee commit 87d5f71

27 files changed

+229
-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
}

src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public async Task CanRetrieveReservedWordsAsync()
3939
var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection);
4040
var reserved = metaData.GetReservedWords();
4141
Assert.That(reserved, Is.Not.Empty);
42-
Assert.That(reserved, Has.Member("SELECT").IgnoreCase);
43-
Assert.That(reserved, Has.Member("FROM").IgnoreCase);
42+
Assert.That(reserved, Has.Some.EqualTo("SELECT").IgnoreCase);
43+
Assert.That(reserved, Has.Some.EqualTo("FROM").IgnoreCase);
4444
}
4545
finally
4646
{

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+
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
4242
<PackageReference Include="MySql.Data" Version="6.9.10" />
4343
<PackageReference Include="Npgsql" Version="3.2.4.1" />
44-
<PackageReference Include="nunit" Version="3.7.1" />
4544
<PackageReference Include="Oracle.ManagedDataAccess" Version="12.1.2400" />
4645
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.105.2" />
4746
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.7.6" />
48-
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
49-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
47+
<PackageReference Include="NUnit" Version="3.9.0" />
48+
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
49+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
5050
</ItemGroup>
5151
<ItemGroup Condition=" '$(NuGetPackageRoot)' != '' ">
5252
<NativeBinaries Include="$(NuGetPackageRoot)microsoft.sqlserver.compact\4.0.8876.1\NativeBinaries\**\*.*" />

src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public void CanRetrieveReservedWords()
2727
var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection);
2828
var reserved = metaData.GetReservedWords();
2929
Assert.That(reserved, Is.Not.Empty);
30-
Assert.That(reserved, Has.Member("SELECT").IgnoreCase);
31-
Assert.That(reserved, Has.Member("FROM").IgnoreCase);
30+
Assert.That(reserved, Has.Some.EqualTo("SELECT").IgnoreCase);
31+
Assert.That(reserved, Has.Some.EqualTo("FROM").IgnoreCase);
3232
}
3333
finally
3434
{

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/Loader/Loader.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,6 @@ protected async Task<DbDataReader> GetResultSetAsync(DbCommand st, bool autoDisc
843843
DbDataReader rs = null;
844844
try
845845
{
846-
Log.Info(st.CommandText);
847846
// TODO NH: Callable
848847
rs = await (session.Batcher.ExecuteReaderAsync(st, cancellationToken)).ConfigureAwait(false);
849848

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+
}
Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
11
using System;
22
using System.Runtime.Serialization;
3+
using System.Security;
34

45
namespace NHibernate
56
{
67
[Serializable]
78
public class DuplicateMappingException : MappingException
89
{
9-
private readonly string type;
10-
private readonly string name;
11-
12-
/// <summary>
13-
/// The type of the duplicated object
14-
/// </summary>
15-
public string Type
16-
{
17-
get { return type; }
18-
}
19-
20-
/// <summary>
21-
/// The name of the duplicated object
22-
/// </summary>
23-
public string Name
24-
{
25-
get { return name; }
26-
}
2710

2811
/// <summary>
2912
/// Initializes a new instance of the <see cref="MappingException"/> class.
@@ -34,8 +17,8 @@ public string Name
3417
public DuplicateMappingException(string customMessage, string type, string name)
3518
: base(customMessage)
3619
{
37-
this.type = type;
38-
this.name = name;
20+
Type = type;
21+
Name = name;
3922
}
4023

4124
/// <summary>
@@ -44,7 +27,7 @@ public DuplicateMappingException(string customMessage, string type, string name)
4427
/// <param name="name">The name of the duplicate object</param>
4528
/// <param name="type">The type of the duplicate object</param>
4629
public DuplicateMappingException(string type, string name)
47-
: this(string.Format("Duplicate {0} mapping {1}", type, name), type, name)
30+
: this($"Duplicate {type} mapping {name}", type, name)
4831
{
4932
}
5033

@@ -62,6 +45,35 @@ public DuplicateMappingException(string type, string name)
6245
public DuplicateMappingException(SerializationInfo info, StreamingContext context)
6346
: base(info, context)
6447
{
48+
foreach (var entry in info)
49+
{
50+
if (entry.Name == "Type")
51+
{
52+
Type = entry.Value?.ToString();
53+
}
54+
else if (entry.Name == "Name")
55+
{
56+
Name = entry.Value?.ToString();
57+
}
58+
}
6559
}
60+
61+
[SecurityCritical]
62+
public override void GetObjectData(SerializationInfo info, StreamingContext context)
63+
{
64+
base.GetObjectData(info, context);
65+
info.AddValue("Type", Type);
66+
info.AddValue("Name", Name);
67+
}
68+
69+
/// <summary>
70+
/// The type of the duplicated object
71+
/// </summary>
72+
public string Type { get; }
73+
74+
/// <summary>
75+
/// The name of the duplicated object
76+
/// </summary>
77+
public string Name { get; }
6678
}
67-
}
79+
}

0 commit comments

Comments
 (0)