Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public ExtractionContext(Catalog catalog, Dictionary<string, string> replacement
private const int DefaultDayPrecision = 2;
private const int DefaultFSecondsPrecision = 6;

private readonly object accessGuard = new object();
private readonly Lock accessGuard = new();

private string nonSystemSchemasFilter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal static class ProviderInitializer
private const string FrameworkName = "Net40";

private static volatile bool IsInitialized;
private static readonly object SyncRoot = new object();
private static readonly Lock SyncRoot = new();

public static void Run(string nativeLibraryCacheFolder)
{
Expand Down
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm.Tests.Core/DotNetFramework/ThreadingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private class Target
public int PassCount;
public bool Stop;
public Thread LastAccessor;
public object ObjectLock = new object();
public Lock ObjectLock = new();
public ReaderWriterLockSlim SlimLock = new ReaderWriterLockSlim();

public void ExecuteLock(object argument)
Expand Down Expand Up @@ -280,4 +280,4 @@ private static void ThreadedTest(Target target, int passCount, ParameterizedThre
TestHelper.CollectGarbage();
}
}
}
}
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm.Tests.Framework/StorageProviderInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Xtensive.Orm.Tests
{
public sealed class StorageProviderInfo
{
private static readonly object InstanceLock = new object();
private static readonly Lock InstanceLock = new();
private static StorageProviderInfo InstanceValue;

public static StorageProviderInfo Instance
Expand Down Expand Up @@ -113,4 +113,4 @@ private static IStorageTimeZoneProvider GetTimeZoneProvider(StorageProvider prov
}
}
}
}
}
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm.Tests.Framework/TestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class TestConfiguration

private const string DefaultStorage = "default";

private static readonly object InstanceLock = new object();
private static readonly Lock InstanceLock = new();
private static TestConfiguration InstanceValue;

private readonly Dictionary<string, string> configuration;
Expand Down Expand Up @@ -103,4 +103,4 @@ private TestConfiguration()
Storage = GetEnvironmentVariable(StorageKey) ?? GetStorageFromFile() ?? DefaultStorage;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private sealed class KeyExtension
#region "Null entity" pattern implementation

public const string NullName = "<None>";
private static object @lock = new object();
private static Lock @lock = new();

public static Person Null {
get {
Expand Down Expand Up @@ -190,4 +190,4 @@ public void HasNullEntityTest()
}
}
}
}
}
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm.Tests/Issues/Issue0839_MultithreadingBug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Issue0839_MultithreadingBug : AutoBuildTest
private const int entityCount = 20;
private const int readCount = 20;

private static object exceptionLock = new object();
private static Lock exceptionLock = new();
private static int exceptionCount;
private static Key[] keys = new Key[entityCount];

Expand Down Expand Up @@ -136,4 +136,4 @@ currentError is UniqueConstraintViolationException ||
}
}
}
}
}
19 changes: 10 additions & 9 deletions Orm/Xtensive.Orm.Tests/Storage/ActivatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
// Created: 2008.06.11

using System;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using Xtensive.Orm.Configuration;
using Xtensive.Orm.Tests.Issues.CustomerBug1Model;
using Xtensive.Orm.Tests.Storage.ActivatorModel;
using System.Linq;

namespace Xtensive.Orm.Tests.Storage.ActivatorModel
{
Expand All @@ -32,19 +33,19 @@ public class Descendant : Ancestor
[HierarchyRoot]
public class InitializebleClass : Entity
{
public object syncRoot = new object();
public Lock syncRoot = new();

protected override void OnInitialize()
{
base.OnInitialize();
syncRoot = new object();
syncRoot = new();
}

public InitializebleClass()
{
syncRoot = new object();
// ������, ������� ����� syncRoot.
Assert.IsNotNull(syncRoot);
syncRoot = new();
// Логика, которая юзает syncRoot.
Assert.That(syncRoot != null, Is.True);
}

[Field, Key]
Expand Down Expand Up @@ -75,7 +76,7 @@ public void TestFieldInitializer()
using (var t = session.OpenTransaction())
{
var obj1 = new InitializebleClass();
Assert.IsNotNull(obj1.syncRoot);
Assert.That(obj1.syncRoot != null, Is.True);
t.Complete();
}
}
Expand All @@ -85,7 +86,7 @@ public void TestFieldInitializer()
{
var obj1 = session.Query.All<InitializebleClass>().First();
Assert.IsNotNull(obj1);
Assert.IsNotNull(obj1.syncRoot);
Assert.That(obj1.syncRoot != null, Is.True);
t.Complete();
}
}
Expand Down Expand Up @@ -113,4 +114,4 @@ public void Test()
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016 Xtensive LLC.
// Copyright (C) 2016 Xtensive LLC.
// All rights reserved.
// For conditions of distribution and use, see license.
// Created by: Alexey Kulakov
Expand All @@ -20,7 +20,7 @@ namespace Xtensive.Orm.Tests.Upgrade.UpgradeAndNamingRulesAdvanced
[TestFixture]
public abstract class TestBase
{
public readonly object guard = new object();
public readonly Lock guard = new();
private NamingConvention namingConvention;

[Test]
Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Core/AssociateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class AssociateProvider :
private string[] typeSuffixes;

[NonSerialized]
private object highPriorityLocationsLock = new object();
private Lock highPriorityLocationsLock = new();

private List<(Assembly, string)> highPriorityLocations = new();

Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Core/Scope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Xtensive.Core
public class Scope<TContext> : IDisposable
where TContext: class
{
internal static readonly object @lock = new object();
internal static readonly Lock @lock = new();
internal static volatile Type allowedType = null;

private static readonly AsyncLocal<Scope<TContext>> currentScopeAsync = new AsyncLocal<Scope<TContext>>();
Expand Down
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm/Core/SimpleScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Xtensive.Core
/// <typeparam name="TVariator">The type of the variator. Must be an internal type.</typeparam>
public class SimpleScope<TVariator> : IDisposable
{
private readonly static object @lock = new object();
private readonly static Lock @lock = new();
private volatile static Type allowedType = null;

private static readonly AsyncLocal<SimpleScope<TVariator>> currentAsync = new AsyncLocal<SimpleScope<TVariator>>();
Expand Down Expand Up @@ -117,4 +117,4 @@ public void Dispose()
throw error;
}
}
}
}
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm/Orm/Domain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace Xtensive.Orm
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
public sealed class Domain : IDisposable, IAsyncDisposable, IHasExtensions, ISessionSource
{
private readonly object disposeGuard = new object();
private readonly object singleConnectionGuard = new object();
private readonly Lock disposeGuard = new();
private readonly Lock singleConnectionGuard = new();

private bool isDisposed;
private Session singleConnectionOwner;
Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Orm/Logging/Internals/FileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Xtensive.Orm.Logging
internal sealed class FileWriter : LogWriter
{
private readonly string fileName;
private readonly object syncRoot = new object();
private readonly Lock syncRoot = new();

/// <inheritdoc/>
public override void Write(in LogEventInfo logEvent)
Expand Down
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm/Orm/Logging/Internals/SystemClock.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2013 Xtensive LLC.
// Copyright (C) 2013 Xtensive LLC.
// All rights reserved.
// For conditions of distribution and use, see license.
// Created by: Alexey Kulakov
Expand All @@ -10,7 +10,7 @@ namespace Xtensive.Orm.Logging
{
internal static class SystemClock
{
private static readonly object syncRoot = new object();
private static readonly Lock syncRoot = new();
private static int lastTick = -1;
private static DateTime lastDateTime = DateTime.MinValue;

Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Orm/Logging/LogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed class LogManager
{
private static readonly LogManager defaultInstance = new LogManager();

private readonly object syncObj = new object();
private readonly Lock syncObj = new();
private LogProvider provider;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2012 Xtensive LLC.
// Copyright (C) 2012 Xtensive LLC.
// All rights reserved.
// For conditions of distribution and use, see license.
// Created by: Denis Krjuchkov
Expand All @@ -17,7 +17,7 @@ namespace Xtensive.Orm.Upgrade
{
internal sealed class UpgradeServiceAccessor : LockableBase, IDisposable
{
private readonly object resourcesSyncRoot = new object();
private readonly Lock resourcesSyncRoot = new();
private readonly DisposableSet resources = new DisposableSet();
private readonly DisposableSet temporaryResources = new DisposableSet();

Expand Down Expand Up @@ -177,4 +177,4 @@ public void Dispose()
}
}
}
}
}
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Reflection/TypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public int GetHashCode((Type, Type[]) obj)

private const string InvokeMethodName = "Invoke";

private static readonly object EmitLock = new object();
private static readonly Lock EmitLock = new();
private static readonly int NullableTypeMetadataToken = WellKnownTypes.NullableOfT.MetadataToken;
private static readonly int ValueTuple1MetadataToken = typeof(ValueTuple<>).MetadataToken;
private static readonly int ValueTuple8MetadataToken = typeof(ValueTuple<,,,,,,,>).MetadataToken;
Expand Down