diff --git a/Directory.Packages.props b/Directory.Packages.props
index d08fe2c0546..7ec27f7abe5 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -17,6 +17,7 @@
+
diff --git a/framework/Directory.Build.props b/framework/Directory.Build.props
new file mode 100644
index 00000000000..dc793d94be9
--- /dev/null
+++ b/framework/Directory.Build.props
@@ -0,0 +1,18 @@
+
+
+
+
+ latest
+
+
+
+
+ all
+ analyzers
+
+
+
+
+
+
+
diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs
index d13fd5a7514..f03b0389d17 100644
--- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs
@@ -6,7 +6,7 @@ namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling;
public class AbpExceptionHandlingLoggerProvider : ILoggerProvider
{
private AbpExceptionHandlingLogger? _logger;
- private static readonly object SyncObj = new object();
+ private static readonly Lock SyncObj = new();
private readonly IServiceCollection _serviceCollection;
public AbpExceptionHandlingLoggerProvider(IServiceCollection serviceCollection)
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs
index 36e981e698c..dd02b380005 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling.Abstractions/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs
@@ -10,6 +10,7 @@ public class BundleConfigurationCollection
private readonly ConcurrentDictionary _bundles;
private readonly ConcurrentDictionary>> _lazyBundleConfigurationActions;
private readonly List> _lazyAllBundleConfigurationActions;
+ private readonly Lock _syncLock = new();
public BundleConfigurationCollection()
{
@@ -92,7 +93,7 @@ private BundleConfiguration CreateBundle(string bundleName, Action c.Invoke(bundle));
}
@@ -146,7 +147,7 @@ public BundleConfigurationCollection ConfigureAll([NotNull] Action WatchDisposeHandles { get; }
+ public Lock SyncLock { get; } = new();
+
public BundleCacheItem(List files)
{
Files = files;
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs
index 20c33e86e58..c28d7a3e25a 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs
@@ -138,13 +138,13 @@ private BundleCacheItem AddToBundleCache(string bundleName, IBundler bundler, Li
private void WatchChanges(BundleCacheItem cacheValue, List files, string bundleRelativePath)
{
- lock (cacheValue.WatchDisposeHandles)
+ lock (cacheValue.SyncLock)
{
foreach (var file in files)
{
var watchDisposeHandle = HostingEnvironment.WebRootFileProvider.Watch(file).RegisterChangeCallback(_ =>
{
- lock (cacheValue.WatchDisposeHandles)
+ lock (cacheValue.SyncLock)
{
cacheValue.WatchDisposeHandles.ForEach(h => h.Dispose());
cacheValue.WatchDisposeHandles.Clear();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs
index 10900f6ee47..4f411632bde 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs
@@ -13,7 +13,7 @@ public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoServic
{
protected IExtensionPropertyAttributeDtoFactory ExtensionPropertyAttributeDtoFactory { get; }
protected volatile ObjectExtensionsDto? CachedValue;
- protected readonly object SyncLock = new object();
+ protected readonly Lock SyncLock = new();
public CachedObjectExtensionsDtoService(IExtensionPropertyAttributeDtoFactory extensionPropertyAttributeDtoFactory)
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/DynamicProxyIgnoreTypes.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/DynamicProxyIgnoreTypes.cs
index d14f64a55bb..ecff01b3c6f 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/DynamicProxyIgnoreTypes.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/DynamicProxyIgnoreTypes.cs
@@ -15,6 +15,7 @@ namespace Volo.Abp.DynamicProxy;
public static class DynamicProxyIgnoreTypes
{
private static HashSet IgnoredTypes { get; } = new HashSet();
+ private static readonly Lock _syncLock = LockFactory.Create();
public static void Add()
{
@@ -23,7 +24,7 @@ public static void Add()
public static void Add(Type type)
{
- lock (IgnoredTypes)
+ lock (_syncLock)
{
IgnoredTypes.AddIfNotContains(type);
}
@@ -31,7 +32,7 @@ public static void Add(Type type)
public static void Add(params Type[] types)
{
- lock (IgnoredTypes)
+ lock (_syncLock)
{
IgnoredTypes.AddIfNotContains(types);
}
@@ -39,7 +40,7 @@ public static void Add(params Type[] types)
public static bool Contains(Type type, bool includeDerivedTypes = true)
{
- lock (IgnoredTypes)
+ lock (_syncLock)
{
return includeDerivedTypes
? IgnoredTypes.Any(t => t.IsAssignableFrom(type))
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs
index 0a5b3ffd05b..e9a2803aaf1 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs
@@ -12,6 +12,7 @@ namespace Volo.Abp;
public static class RandomHelper
{
private static readonly Random Rnd = new Random();
+ private static readonly Lock _syncLock = LockFactory.Create();
///
/// Returns a random number within a specified range.
@@ -25,7 +26,7 @@ public static class RandomHelper
///
public static int GetRandom(int minValue, int maxValue)
{
- lock (Rnd)
+ lock (_syncLock)
{
return Rnd.Next(minValue, maxValue);
}
@@ -42,7 +43,7 @@ public static int GetRandom(int minValue, int maxValue)
///
public static int GetRandom(int maxValue)
{
- lock (Rnd)
+ lock (_syncLock)
{
return Rnd.Next(maxValue);
}
@@ -54,7 +55,7 @@ public static int GetRandom(int maxValue)
/// A 32-bit signed integer greater than or equal to zero and less than .
public static int GetRandom()
{
- lock (Rnd)
+ lock (_syncLock)
{
return Rnd.Next();
}
diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/VirtualFileLocalizationResourceContributorBase.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/VirtualFileLocalizationResourceContributorBase.cs
index b25bd9ec6e6..3191516c592 100644
--- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/VirtualFileLocalizationResourceContributorBase.cs
+++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/VirtualFileLocalizationResourceContributorBase.cs
@@ -18,7 +18,7 @@ public abstract class VirtualFileLocalizationResourceContributorBase : ILocaliza
private IVirtualFileProvider _virtualFileProvider = default!;
private Dictionary? _dictionaries;
private bool _subscribedForChanges;
- private readonly object _syncObj = new object();
+ private readonly Lock _syncObj = LockFactory.Create();
private LocalizationResourceBase _resource = default!;
protected VirtualFileLocalizationResourceContributorBase(string virtualPath)
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoModelBuilder.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoModelBuilder.cs
index d7ad79f7d0b..5782bb88c01 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoModelBuilder.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoModelBuilder.cs
@@ -17,7 +17,7 @@ public class MongoModelBuilder : IMongoModelBuilder
{
private readonly Dictionary _entityModelBuilders;
- private static readonly object SyncObj = new object();
+ private static readonly Lock SyncObj = LockFactory.Create();
public MongoModelBuilder()
{
diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo.Abp.ObjectExtending.csproj b/framework/src/Volo.Abp.ObjectExtending/Volo.Abp.ObjectExtending.csproj
index 2c930c7dd21..c5bf37e570a 100644
--- a/framework/src/Volo.Abp.ObjectExtending/Volo.Abp.ObjectExtending.csproj
+++ b/framework/src/Volo.Abp.ObjectExtending/Volo.Abp.ObjectExtending.csproj
@@ -1,4 +1,4 @@
-
+
diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs
index 9a13b170287..66d81cecf31 100644
--- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs
+++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs
@@ -6,7 +6,7 @@ namespace Volo.Abp.ObjectExtending.Modularity;
public static class ModuleExtensionConfigurationHelper
{
- private static object SyncLock = new object();
+ private static Lock SyncLock = LockFactory.Create();
public static void ApplyEntityConfigurationToEntity(
string moduleName,
diff --git a/framework/src/Volo.Abp.TestBase/Volo/Abp/Testing/Utils/TestCounter.cs b/framework/src/Volo.Abp.TestBase/Volo/Abp/Testing/Utils/TestCounter.cs
index 1a364abf814..7c4f7bb9202 100644
--- a/framework/src/Volo.Abp.TestBase/Volo/Abp/Testing/Utils/TestCounter.cs
+++ b/framework/src/Volo.Abp.TestBase/Volo/Abp/Testing/Utils/TestCounter.cs
@@ -6,6 +6,7 @@ namespace Volo.Abp.Testing.Utils;
public class TestCounter : ITestCounter, ISingletonDependency
{
private readonly Dictionary _values;
+ private readonly Lock _syncLock = LockFactory.Create();
public TestCounter()
{
@@ -24,7 +25,7 @@ public int Decrement(string name)
public int Add(string name, int count)
{
- lock (_values)
+ lock (_syncLock)
{
var newValue = _values.GetOrDefault(name) + count;
_values[name] = newValue;
@@ -34,7 +35,7 @@ public int Add(string name, int count)
public int GetValue(string name)
{
- lock (_values)
+ lock (_syncLock)
{
return _values.GetOrDefault(name);
}
@@ -42,7 +43,7 @@ public int GetValue(string name)
public void ResetCount(string name)
{
- lock (_values)
+ lock (_syncLock)
{
_values[name] = 0;
}