diff --git a/build-common/NHibernate.props b/build-common/NHibernate.props
index c2676d0cd85..4fa8208b537 100644
--- a/build-common/NHibernate.props
+++ b/build-common/NHibernate.props
@@ -6,7 +6,7 @@
0
dev
- 12.0
+ 13.0
$(NhVersion).$(VersionPatch)
$(VersionSuffix).$(BuildNumber)
diff --git a/src/NHibernate.Test/NHSpecificTest/NH2030/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2030/Fixture.cs
index dba4873091e..d3f377e9e59 100644
--- a/src/NHibernate.Test/NHSpecificTest/NH2030/Fixture.cs
+++ b/src/NHibernate.Test/NHSpecificTest/NH2030/Fixture.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
diff --git a/src/NHibernate/Cache/SyncCacheLock.cs b/src/NHibernate/Cache/SyncCacheLock.cs
index c9eceacb63c..2cc4656a2fb 100644
--- a/src/NHibernate/Cache/SyncCacheLock.cs
+++ b/src/NHibernate/Cache/SyncCacheLock.cs
@@ -6,32 +6,27 @@ namespace NHibernate.Cache
{
class SyncCacheLock : ICacheLock
{
- private readonly MonitorLock _monitorLock;
+ private readonly InternalLock _internalLock;
- class MonitorLock : IDisposable
+ class InternalLock : IDisposable
{
- private readonly object _lockObj;
-
- public MonitorLock(object lockObj)
- {
- _lockObj = lockObj;
- }
+ private readonly Lock _lockObj = new Lock();
public IDisposable Lock()
{
- Monitor.Enter(_lockObj);
+ _lockObj.Enter();
return this;
}
public void Dispose()
{
- Monitor.Exit(_lockObj);
+ _lockObj.Exit();
}
}
public SyncCacheLock()
{
- _monitorLock = new MonitorLock(this);
+ _internalLock = new();
}
public void Dispose()
@@ -40,12 +35,12 @@ public void Dispose()
public IDisposable ReadLock()
{
- return _monitorLock.Lock();
+ return _internalLock.Lock();
}
public IDisposable WriteLock()
{
- return _monitorLock.Lock();
+ return _internalLock.Lock();
}
public Task ReadLockAsync()
diff --git a/src/NHibernate/Cache/Timestamper.cs b/src/NHibernate/Cache/Timestamper.cs
index c904b9108b4..159ce788593 100644
--- a/src/NHibernate/Cache/Timestamper.cs
+++ b/src/NHibernate/Cache/Timestamper.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading;
namespace NHibernate.Cache
{
@@ -11,7 +12,7 @@ namespace NHibernate.Cache
///
public static class Timestamper
{
- private static object lockObject = new object();
+ private static Lock lockObject = LockFactory.Create();
// hibernate is using System.currentMilliSeconds which is calculated
// from jan 1, 1970
diff --git a/src/NHibernate/Context/MapBasedSessionContext.cs b/src/NHibernate/Context/MapBasedSessionContext.cs
index 60f67ae7697..275d38febe9 100644
--- a/src/NHibernate/Context/MapBasedSessionContext.cs
+++ b/src/NHibernate/Context/MapBasedSessionContext.cs
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Concurrent;
+using System.Threading;
using NHibernate.Engine;
namespace NHibernate.Context
@@ -9,7 +10,7 @@ public abstract class MapBasedSessionContext : CurrentSessionContext
private readonly ISessionFactoryImplementor _factory;
// Must be static, different instances of MapBasedSessionContext may have to yield the same map.
- private static readonly object _locker = new object();
+ private static readonly Lock _locker = LockFactory.Create();
protected MapBasedSessionContext(ISessionFactoryImplementor factory)
{
diff --git a/src/NHibernate/NHibernate.csproj b/src/NHibernate/NHibernate.csproj
index e38db30c036..bcc078ff91f 100644
--- a/src/NHibernate/NHibernate.csproj
+++ b/src/NHibernate/NHibernate.csproj
@@ -73,6 +73,16 @@
+
+
+ all
+ analyzers
+
+
+
+
+
+
./
diff --git a/src/NHibernate/Stat/StatisticsImpl.cs b/src/NHibernate/Stat/StatisticsImpl.cs
index b7d055dc9e0..7641a337d44 100644
--- a/src/NHibernate/Stat/StatisticsImpl.cs
+++ b/src/NHibernate/Stat/StatisticsImpl.cs
@@ -3,12 +3,13 @@
using System.Text;
using NHibernate.Engine;
using System.Linq;
+using System.Threading;
namespace NHibernate.Stat
{
public class StatisticsImpl : IStatistics, IStatisticsImplementor
{
- private readonly object _syncRoot = new object();
+ private readonly Lock _syncRoot = LockFactory.Create();
private static readonly INHibernateLogger log = NHibernateLogger.For(typeof(StatisticsImpl));
private readonly ISessionFactoryImplementor sessionFactory;
diff --git a/src/NHibernate/Util/AsyncReaderWriterLock.cs b/src/NHibernate/Util/AsyncReaderWriterLock.cs
index 203de8812ee..c6b1287a80b 100644
--- a/src/NHibernate/Util/AsyncReaderWriterLock.cs
+++ b/src/NHibernate/Util/AsyncReaderWriterLock.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/NHibernate/Util/SimpleMRUCache.cs b/src/NHibernate/Util/SimpleMRUCache.cs
index b6ad7beb413..d7f8eb07409 100644
--- a/src/NHibernate/Util/SimpleMRUCache.cs
+++ b/src/NHibernate/Util/SimpleMRUCache.cs
@@ -1,5 +1,6 @@
using System;
using System.Runtime.Serialization;
+using System.Threading;
namespace NHibernate.Util
{
@@ -17,7 +18,7 @@ public class SimpleMRUCache : IDeserializationCallback
{
private const int DefaultStrongRefCount = 128;
- private readonly object _syncRoot = new object();
+ private readonly Lock _syncRoot = LockFactory.Create();
private readonly int strongReferenceCount;
diff --git a/src/NHibernate/Util/SoftLimitMRUCache.cs b/src/NHibernate/Util/SoftLimitMRUCache.cs
index e69c3f2916e..3b4e67cf61e 100644
--- a/src/NHibernate/Util/SoftLimitMRUCache.cs
+++ b/src/NHibernate/Util/SoftLimitMRUCache.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Runtime.Serialization;
+using System.Threading;
namespace NHibernate.Util
{
@@ -23,7 +24,7 @@ namespace NHibernate.Util
public class SoftLimitMRUCache : IDeserializationCallback
{
private const int DefaultStrongRefCount = 128;
- private readonly object _syncRoot = new object();
+ private readonly Lock _syncRoot = LockFactory.Create();
private readonly int strongReferenceCount;