Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove serialization support in DynamicProxy #512

Closed
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,10 @@ Deprecations:
- Removed support for the .NET Framework < 4.5 and .NET Standard 1.x. (@stakx, #495, #496)
- Removed support for Code Access Security (CAS). (@stakx, #502)
- Removed support for Remoting. This library no longer defines any types deriving from `MarshalByRefObject`, and `ProxyUtil.IsProxy` (which used to recognize remoting/"transparent" proxies) now tests only for DynamicProxy proxies. (@stakx, #507)
- Removed support for serialization in DynamicProxy. To be more specific, this means that:
- Previously saved dynamic assemblies can no longer be loaded into a `ProxyGenerator`'s type cache (via `ModuleScope.LoadAssemblyIntoCache`).
- Generated proxies and invocations are no longer marked as `[Serializable]` nor do they automatically implement `ISerializable`.
- There is no longer any requirement to make your interceptors, interceptor selectors, proxy generation hooks, or mixins serializable. (@stakx, #512)
- The following public members have been removed:
- `Castle.Core.Internal.Lock` (class) along with all related types and methods
- `Castle.Core.Internal.PermissionUtil.IsGranted` (method)
Expand Down
3 changes: 0 additions & 3 deletions docs/dynamicproxy-serializable-types.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/dynamicproxy.md
Expand Up @@ -15,7 +15,6 @@ If you're new to DynamicProxy you can read a [quick introduction](dynamicproxy-i
* [Leaking this](dynamicproxy-leaking-this.md)
* [Make proxy generation hooks purely functional](dynamicproxy-generation-hook-pure-function.md)
* [Overriding Equals/GetHashCode on proxy generation hook](dynamicproxy-generation-hook-override-equals-gethashcode.md)
* [Make your supporting classes serializable](dynamicproxy-serializable-types.md)
* [Use proxy generation hooks and interceptor selectors for fine grained control](dynamicproxy-fine-grained-control.md)
* [SRP applies to interceptors](dynamicproxy-srp-applies-to-interceptors.md)
* [Behavior of by-reference parameters during interception](dynamicproxy-by-ref-parameters.md)
Expand Down
29 changes: 1 addition & 28 deletions ref/Castle.Core-net45.cs
Expand Up @@ -2639,7 +2639,6 @@ public class ModuleScope
public string StrongNamedModuleName { get; }
public string WeakNamedModuleDirectory { get; }
public string WeakNamedModuleName { get; }
public void LoadAssemblyIntoCache(System.Reflection.Assembly assembly) { }
public string SaveAssembly() { }
public string SaveAssembly(bool strongNamed) { }
public static byte[] GetKeyPair() { }
Expand All @@ -2650,7 +2649,7 @@ public class PersistentProxyBuilder : Castle.DynamicProxy.DefaultProxyBuilder
public string SaveAssembly() { }
}
public class ProxyGenerationException : System.Exception { }
public class ProxyGenerationOptions : System.Runtime.Serialization.ISerializable
public class ProxyGenerationOptions
{
public static readonly Castle.DynamicProxy.ProxyGenerationOptions Default;
public ProxyGenerationOptions() { }
Expand All @@ -2666,7 +2665,6 @@ public class ProxyGenerationOptions : System.Runtime.Serialization.ISerializable
public void AddMixinInstance(object instance) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public void Initialize() { }
public object[] MixinsAsArray() { }
}
Expand Down Expand Up @@ -2794,30 +2792,5 @@ public static class TypeUtil
{
public static System.Type[] GetAllInterfaces(this System.Type type) { }
public static System.Type GetTypeOrNull(object target) { }
public static System.Reflection.MemberInfo[] Sort(System.Reflection.MemberInfo[] members) { }
}
}
namespace Castle.DynamicProxy.Serialization
{
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.All, AllowMultiple=false)]
[System.CLSCompliant(false)]
public class CacheMappingsAttribute : System.Attribute
{
public CacheMappingsAttribute(byte[] serializedCacheMappings) { }
public byte[] SerializedCacheMappings { get; }
}
public class ProxyObjectReference : System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.IObjectReference, System.Runtime.Serialization.ISerializable
{
protected ProxyObjectReference(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public static Castle.DynamicProxy.ModuleScope ModuleScope { get; }
public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public object GetRealObject(System.Runtime.Serialization.StreamingContext context) { }
protected void InvokeCallback(object target) { }
public void OnDeserialization(object sender) { }
public object RecreateClassProxy() { }
public object RecreateInterfaceProxy(string generatorType) { }
protected virtual object RecreateProxy() { }
public static void ResetScope() { }
public static void SetScope(Castle.DynamicProxy.ModuleScope scope) { }
}
}
1 change: 0 additions & 1 deletion ref/Castle.Core-netstandard2.0.cs
Expand Up @@ -2763,6 +2763,5 @@ public static class TypeUtil
{
public static System.Type[] GetAllInterfaces(this System.Type type) { }
public static System.Type GetTypeOrNull(object target) { }
public static System.Reflection.MemberInfo[] Sort(System.Reflection.MemberInfo[] members) { }
}
}
1 change: 0 additions & 1 deletion ref/Castle.Core-netstandard2.1.cs
Expand Up @@ -2763,6 +2763,5 @@ public static class TypeUtil
{
public static System.Type[] GetAllInterfaces(this System.Type type) { }
public static System.Type GetTypeOrNull(object target) { }
public static System.Reflection.MemberInfo[] Sort(System.Reflection.MemberInfo[] members) { }
}
}

This file was deleted.

Expand Up @@ -16,9 +16,6 @@ namespace Castle.DynamicProxy.Tests.Classes
{
using System;

#if FEATURE_SERIALIZATION
[Serializable]
#endif
public class ClassOverridingEqualsAndGetHashCode
{
private Guid _id;
Expand Down

This file was deleted.

Expand Up @@ -16,9 +16,6 @@ namespace Castle.DynamicProxy.Tests.Classes
{
using System;

#if FEATURE_SERIALIZATION
[Serializable]
#endif
public class ClassWithInterface : ISimpleInterface
{
public int Do()
Expand Down
Expand Up @@ -60,9 +60,6 @@ public virtual void Do2()
}
}

#if FEATURE_SERIALIZATION
[Serializable]
#endif
[AttributeUsage(AttributeTargets.All, Inherited = false)]
public class ComplexNonInheritableAttribute : Attribute
{
Expand Down
Expand Up @@ -16,9 +16,6 @@ namespace Castle.DynamicProxy.Tests.Classes
{
using System;

#if FEATURE_SERIALIZATION
[Serializable]
#endif
[AttributeUsage(AttributeTargets.All, Inherited = true)]
public class InheritableAttribute : Attribute
{
Expand Down

This file was deleted.

Expand Up @@ -16,9 +16,6 @@ namespace Castle.DynamicProxy.Tests.Classes
{
using System;

#if FEATURE_SERIALIZATION
[Serializable]
#endif
[AttributeUsage(AttributeTargets.All, Inherited = false)]
public class NonInheritableAttribute : Attribute
{
Expand Down
Expand Up @@ -16,9 +16,6 @@ namespace Castle.DynamicProxy.Tests.Classes
{
using System;

#if FEATURE_SERIALIZATION
[Serializable]
#endif
[AttributeUsage(AttributeTargets.All, Inherited = false)]
public class NonInheritableWithArray2Attribute : Attribute
{
Expand Down
Expand Up @@ -16,9 +16,6 @@ namespace Castle.DynamicProxy.Tests.Classes
{
using System;

#if FEATURE_SERIALIZATION
[Serializable]
#endif
[AttributeUsage(AttributeTargets.All, Inherited = false)]
public class NonInheritableWithArrayAttribute : Attribute
{
Expand Down
Expand Up @@ -14,7 +14,10 @@

namespace Castle.DynamicProxy.Tests.Classes
{
public class SimpleClass
using System;

[Serializable]
public class SerializableClass
{
}
}
}
Expand Up @@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if FEATURE_SERIALIZATION

namespace Castle.DynamicProxy.Tests.Serialization
namespace Castle.DynamicProxy.Tests.Classes
{
using System;
using System.Runtime.Serialization;
Expand All @@ -27,5 +25,3 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex
}
}
}

#endif