Skip to content

Commit

Permalink
Deprecate Lock and all related members
Browse files Browse the repository at this point in the history
  • Loading branch information
stakx committed Jun 22, 2018
1 parent 41c0dd2 commit 8885558
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 1 deletion.
1 change: 1 addition & 0 deletions buildscripts/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<NoWarn>$(NoWarn);CS1591;CS3014;CS3003;CS3001;CS3021</NoWarn>
<NoWarn>$(NoWarn);CS0612;CS0618</NoWarn> <!-- TODO: Remove this line once `[Obsolete]` members have been dealt with. -->
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/castleproject/Core</RepositoryUrl>
<BuildVersion>0.0.0</BuildVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

namespace Castle.Core.Internal.Tests
{
using System;
using System.Threading;

using NUnit.Framework;

[TestFixture]
[Obsolete]
public class SlimReadWriteLockTestCase
{
private SlimReadWriteLock @lock;
Expand Down
3 changes: 3 additions & 0 deletions src/Castle.Core/Core/Internal/ILockHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
public interface ILockHolder:IDisposable
{
bool LockAcquired { get; }
Expand Down
5 changes: 5 additions & 0 deletions src/Castle.Core/Core/Internal/IUpgradeableLockHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
public interface IUpgradeableLockHolder : ILockHolder
{
ILockHolder Upgrade();
Expand Down
4 changes: 4 additions & 0 deletions src/Castle.Core/Core/Internal/Lock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;
using System.Threading;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class Lock
{
public abstract IUpgradeableLockHolder ForReadingUpgradeable();
Expand Down
5 changes: 5 additions & 0 deletions src/Castle.Core/Core/Internal/NoOpLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
internal class NoOpLock : ILockHolder
{
public static readonly ILockHolder Lock = new NoOpLock();
Expand Down
5 changes: 5 additions & 0 deletions src/Castle.Core/Core/Internal/NoOpUpgradeableLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
internal class NoOpUpgradeableLock : IUpgradeableLockHolder
{
public static readonly IUpgradeableLockHolder Lock = new NoOpUpgradeableLock();
Expand Down
4 changes: 4 additions & 0 deletions src/Castle.Core/Core/Internal/SlimReadLockHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;
using System.Threading;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
internal class SlimReadLockHolder : ILockHolder
{
private readonly ReaderWriterLockSlim locker;
Expand Down
4 changes: 4 additions & 0 deletions src/Castle.Core/Core/Internal/SlimReadWriteLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;
using System.Threading;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
internal class SlimReadWriteLock : Lock
{
private readonly ReaderWriterLockSlim locker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;
using System.Threading;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
internal class SlimUpgradeableReadLockHolder : IUpgradeableLockHolder
{
private readonly ReaderWriterLockSlim locker;
Expand Down
4 changes: 4 additions & 0 deletions src/Castle.Core/Core/Internal/SlimWriteLockHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

namespace Castle.Core.Internal
{
using System;
using System.ComponentModel;
using System.Threading;

[Obsolete("Consider using `System.Threading.ReaderWriterLockSlim` instead of `Lock` and related types.")] // TODO: Remove this type.
[EditorBrowsable(EditorBrowsableState.Never)]
internal class SlimWriteLockHolder : ILockHolder
{
private readonly ReaderWriterLockSlim locker;
Expand Down
7 changes: 7 additions & 0 deletions src/Castle.Core/DynamicProxy/Generators/BaseProxyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Castle.DynamicProxy.Generators
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -111,6 +112,8 @@ protected void AddMappingNoCheck(Type @interface, ITypeContributor implementer,
mapping.Add(@interface, implementer);
}

[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Remove this method.
[EditorBrowsable(EditorBrowsableState.Never)]
protected void AddToCache(CacheKey key, Type type)
{
scope.RegisterInCache(key, type);
Expand Down Expand Up @@ -335,6 +338,8 @@ protected ConstructorEmitter GenerateStaticConstructor(ClassEmitter emitter)
return emitter.CreateTypeConstructor();
}

[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Remove this method.
[EditorBrowsable(EditorBrowsableState.Never)]
protected Type GetFromCache(CacheKey key)
{
return scope.GetFromCache(key);
Expand Down Expand Up @@ -382,6 +387,8 @@ protected void InitializeStaticFields(Type builtType)
builtType.SetStaticField("proxyGenerationOptions", BindingFlags.NonPublic, ProxyGenerationOptions);
}

[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Redeclare this method as `private protected`.
[EditorBrowsable(EditorBrowsableState.Never)]
protected Type ObtainProxyType(CacheKey cacheKey, Func<string, INamingScope, Type> factory)
{
bool notFoundInTypeCache = false;
Expand Down
3 changes: 3 additions & 0 deletions src/Castle.Core/DynamicProxy/Generators/CacheKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
namespace Castle.DynamicProxy.Generators
{
using System;
using System.ComponentModel;
using System.Reflection;

[Obsolete("Intended for internal use only.")] // TODO: Redeclare this type as `internal`.
[EditorBrowsable(EditorBrowsableState.Never)]
#if FEATURE_SERIALIZATION
[Serializable]
#endif
Expand Down
11 changes: 10 additions & 1 deletion src/Castle.Core/DynamicProxy/ModuleScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Castle.DynamicProxy
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
Expand Down Expand Up @@ -57,7 +58,9 @@ public class ModuleScope
private readonly Dictionary<CacheKey, Type> typeCache = new Dictionary<CacheKey, Type>();

// Users of ModuleScope should use this lock when accessing the cache
[Obsolete] // TODO: Remove this field together with the `Lock` property.
private readonly Lock cacheLock;

private readonly ReaderWriterLockSlim typeCacheLock;

// Used to lock the module builder creation
Expand Down Expand Up @@ -158,6 +161,8 @@ public INamingScope NamingScope
/// <summary>
/// Users of this <see cref = "ModuleScope" /> should use this lock when accessing the cache.
/// </summary>
[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Remove this property.
[EditorBrowsable(EditorBrowsableState.Never)]
public Lock Lock
{
get { return cacheLock; }
Expand All @@ -168,6 +173,8 @@ public Lock Lock
/// </summary>
/// <param name = "key">The key to be looked up in the cache.</param>
/// <returns>The type from this scope's type cache matching the key, or null if the key cannot be found</returns>
[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Remove this method.
[EditorBrowsable(EditorBrowsableState.Never)]
public Type GetFromCache(CacheKey key)
{
Type type;
Expand All @@ -180,6 +187,8 @@ public Type GetFromCache(CacheKey key)
/// </summary>
/// <param name = "key">The key to be associated with the type.</param>
/// <param name = "type">The type to be stored in the cache.</param>
[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Remove this method.
[EditorBrowsable(EditorBrowsableState.Never)]
public void RegisterInCache(CacheKey key, Type type)
{
typeCache[key] = type;
Expand Down Expand Up @@ -648,7 +657,7 @@ public void LoadAssemblyIntoCache(Assembly assembly)

if (loadedType != null)
{
RegisterInCache(mapping.Key, loadedType);
typeCache[mapping.Key] = loadedType;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Castle.DynamicProxy.Serialization
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
Expand Down Expand Up @@ -47,6 +48,8 @@ public byte[] SerializedCacheMappings
get { return serializedCacheMappings; }
}

[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Redeclare this method as `internal`.
[EditorBrowsable(EditorBrowsableState.Never)]
public Dictionary<CacheKey, string> GetDeserializedMappings()
{
using (var stream = new MemoryStream(SerializedCacheMappings))
Expand All @@ -56,6 +59,8 @@ public Dictionary<CacheKey, string> GetDeserializedMappings()
}
}

[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Redeclare this method as `internal`.
[EditorBrowsable(EditorBrowsableState.Never)]
public static void ApplyTo(AssemblyBuilder assemblyBuilder, Dictionary<CacheKey, string> mappings)
{
using (var stream = new MemoryStream())
Expand Down

0 comments on commit 8885558

Please sign in to comment.