diff --git a/CHANGELOG.md b/CHANGELOG.md index a1595c8378..4df1a77782 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Deprecations: - `Castle.Core.Internal.PermissionUtil.IsGranted` (method) - all type members in `Castle.DynamicProxy.ModuleScope` that gave direct access to DynamicProxy's type cache and `ModuleBuilder`s. Only `SaveAssembly`, `LoadAssemblyIntoCache`, and members supporting these two facilities are left public. - almost all types and type members in the `Castle.DynamicProxy.*` sub-namespaces, as most of them are intended for internal use only. + - DynamicProxy's custom exception types have been replaced by standard BCL exceptions (where appropriate), and by a single `DynamicProxyException` type for internal DynamicProxy errors. ## 4.4.1 (2020-05-06) diff --git a/ref/Castle.Core-net45.cs b/ref/Castle.Core-net45.cs index b50aaa29c5..f96b447a02 100644 --- a/ref/Castle.Core-net45.cs +++ b/ref/Castle.Core-net45.cs @@ -2516,6 +2516,8 @@ public class DefaultProxyBuilder : Castle.DynamicProxy.IProxyBuilder public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } } + [System.Serializable] + public sealed class DynamicProxyException : System.Exception { } public interface IChangeProxyTarget { void ChangeInvocationTarget(object target); @@ -2661,7 +2663,6 @@ public class PersistentProxyBuilder : Castle.DynamicProxy.DefaultProxyBuilder public PersistentProxyBuilder() { } public string SaveAssembly() { } } - public class ProxyGenerationException : System.Exception { } [System.Serializable] public class ProxyGenerationOptions : System.Runtime.Serialization.ISerializable { diff --git a/ref/Castle.Core-netstandard2.0.cs b/ref/Castle.Core-netstandard2.0.cs index 62410757be..6a2dc3a043 100644 --- a/ref/Castle.Core-netstandard2.0.cs +++ b/ref/Castle.Core-netstandard2.0.cs @@ -2482,6 +2482,8 @@ public class DefaultProxyBuilder : Castle.DynamicProxy.IProxyBuilder public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } } + [System.Serializable] + public sealed class DynamicProxyException : System.Exception { } public interface IChangeProxyTarget { void ChangeInvocationTarget(object target); @@ -2617,7 +2619,6 @@ public class ModuleScope public string WeakNamedModuleName { get; } public static byte[] GetKeyPair() { } } - public class ProxyGenerationException : System.Exception { } public class ProxyGenerationOptions { public static readonly Castle.DynamicProxy.ProxyGenerationOptions Default; diff --git a/ref/Castle.Core-netstandard2.1.cs b/ref/Castle.Core-netstandard2.1.cs index 3a0b7fac3c..a7e6da4960 100644 --- a/ref/Castle.Core-netstandard2.1.cs +++ b/ref/Castle.Core-netstandard2.1.cs @@ -2482,6 +2482,8 @@ public class DefaultProxyBuilder : Castle.DynamicProxy.IProxyBuilder public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } } + [System.Serializable] + public sealed class DynamicProxyException : System.Exception { } public interface IChangeProxyTarget { void ChangeInvocationTarget(object target); @@ -2617,7 +2619,6 @@ public class ModuleScope public string WeakNamedModuleName { get; } public static byte[] GetKeyPair() { } } - public class ProxyGenerationException : System.Exception { } public class ProxyGenerationOptions { public static readonly Castle.DynamicProxy.ProxyGenerationOptions Default; diff --git a/src/Castle.Core.Tests/DynamicProxy.Tests/ProxyTargetAccessorHandlingTestCase.cs b/src/Castle.Core.Tests/DynamicProxy.Tests/ProxyTargetAccessorHandlingTestCase.cs index 14a088b6af..43f0a78b60 100644 --- a/src/Castle.Core.Tests/DynamicProxy.Tests/ProxyTargetAccessorHandlingTestCase.cs +++ b/src/Castle.Core.Tests/DynamicProxy.Tests/ProxyTargetAccessorHandlingTestCase.cs @@ -34,7 +34,7 @@ private ProxyGenerationOptions MixIn(object mixin) [Test] public void ClassProxy_AdditionalInterfaces() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateClassProxy(typeof(object), new[] { typeof(IProxyTargetAccessor) })); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -50,7 +50,7 @@ public void ClassProxy_base() [Test] public void ClassProxy_Mixin() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateClassProxy(typeof(object), MixIn(new ImplementsProxyTargetAccessor()))); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -60,7 +60,7 @@ public void ClassProxy_Mixin() [Test] public void InterfaceProxyWithoutTarget_AdditionalInterfaces() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithoutTarget(typeof(IOne), new[] { typeof(IProxyTargetAccessor) })); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -68,7 +68,7 @@ public void InterfaceProxyWithoutTarget_AdditionalInterfaces() [Test] public void InterfaceProxyWithoutTarget_Mixin() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithoutTarget(typeof(IOne), new[] { typeof(IProxyTargetAccessor) }, MixIn(new ImplementsProxyTargetAccessor()))); StringAssert.Contains("IProxyTargetAccessor", ex.Message); @@ -77,7 +77,7 @@ public void InterfaceProxyWithoutTarget_Mixin() [Test] public void InterfaceProxyWithoutTarget_TargetInterface() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithoutTarget(typeof(IProxyTargetAccessor))); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -85,7 +85,7 @@ public void InterfaceProxyWithoutTarget_TargetInterface() [Test] public void InterfaceProxyWithoutTarget_TargetInterface_derived() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithoutTarget(typeof(IProxyTargetAccessorDerived))); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -93,7 +93,7 @@ public void InterfaceProxyWithoutTarget_TargetInterface_derived() [Test] public void InterfaceProxyWithTarget_AdditionalInterfaces() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithTarget(typeof(IOne), new[] { typeof(IProxyTargetAccessor) }, new One())); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -101,7 +101,7 @@ public void InterfaceProxyWithTarget_AdditionalInterfaces() [Test] public void InterfaceProxyWithTarget_Mixin() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithTarget(typeof(IOne), new[] { typeof(IProxyTargetAccessor) }, new One(), MixIn(new ImplementsProxyTargetAccessor()))); StringAssert.Contains("IProxyTargetAccessor", ex.Message); @@ -110,7 +110,7 @@ public void InterfaceProxyWithTarget_Mixin() [Test] public void InterfaceProxyWithTarget_Target() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithTarget(typeof(IProxyTargetAccessor), new ImplementsProxyTargetAccessor())); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -118,7 +118,7 @@ public void InterfaceProxyWithTarget_Target() [Test] public void InterfaceProxyWithTarget_Target_derived() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithTarget(typeof(IProxyTargetAccessorDerived), new ImplementsProxyTargetAccessorDerived())); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -128,7 +128,7 @@ public void InterfaceProxyWithTarget_Target_derived() [Test] public void InterfaceProxyWithTargetInterface_AdditionalInterfaces() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithTargetInterface(typeof(IOne), new[] { typeof(IProxyTargetAccessor) }, new One())); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -136,7 +136,7 @@ public void InterfaceProxyWithTargetInterface_AdditionalInterfaces() [Test] public void InterfaceProxyWithTargetInterface_Mixin() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithTargetInterface(typeof(IOne), new[] { typeof(IProxyTargetAccessor) }, new One(), MixIn(new ImplementsProxyTargetAccessor()))); StringAssert.Contains("IProxyTargetAccessor", ex.Message); @@ -145,7 +145,7 @@ public void InterfaceProxyWithTargetInterface_Mixin() [Test] public void InterfaceProxyWithTargetInterface_Target() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithTargetInterface(typeof(IProxyTargetAccessor), new ImplementsProxyTargetAccessor())); StringAssert.Contains("IProxyTargetAccessor", ex.Message); } @@ -153,7 +153,7 @@ public void InterfaceProxyWithTargetInterface_Target() [Test] public void InterfaceProxyWithTargetInterface_Target_derived() { - var ex = Assert.Throws(typeof(ProxyGenerationException), () => + var ex = Assert.Throws(() => generator.CreateInterfaceProxyWithTargetInterface(typeof(IProxyTargetAccessorDerived), new ImplementsProxyTargetAccessorDerived())); StringAssert.Contains("IProxyTargetAccessor", ex.Message); diff --git a/src/Castle.Core/DynamicProxy/DynamicProxyException.cs b/src/Castle.Core/DynamicProxy/DynamicProxyException.cs new file mode 100644 index 0000000000..002b57dde6 --- /dev/null +++ b/src/Castle.Core/DynamicProxy/DynamicProxyException.cs @@ -0,0 +1,39 @@ +// Copyright 2004-2020 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.DynamicProxy +{ + using System; + using System.Runtime.Serialization; + + // NOTE TO MAINTAINERS: + // Prefer throwing Base Class Library exception types wherever appropriate. + // This exception type is to be used mostly when something inside DynamicProxy goes wrong. + // Think of it as a "failed assertion" / "bug" exception. + [Serializable] + public sealed class DynamicProxyException : Exception + { + internal DynamicProxyException(string message) : base(message) + { + } + + internal DynamicProxyException(string message, Exception innerException) : base(message, innerException) + { + } + + internal DynamicProxyException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} diff --git a/src/Castle.Core/DynamicProxy/Generators/BaseProxyGenerator.cs b/src/Castle.Core/DynamicProxy/Generators/BaseProxyGenerator.cs index 826b75605c..8a47217652 100644 --- a/src/Castle.Core/DynamicProxy/Generators/BaseProxyGenerator.cs +++ b/src/Castle.Core/DynamicProxy/Generators/BaseProxyGenerator.cs @@ -313,7 +313,7 @@ protected void GenerateParameterlessConstructor(ClassEmitter emitter, Type baseC constructor.CodeBuilder.AddStatement(new AssignStatement(interceptorField, new NewArrayExpression(1, typeof(IInterceptor)))); constructor.CodeBuilder.AddStatement( - new AssignArrayStatement(interceptorField, 0, new NewInstanceExpression(typeof(StandardInterceptor), new Type[0]))); + new AssignArrayStatement(interceptorField, 0, new NewInstanceExpression(typeof(StandardInterceptor)))); // Invoke base constructor @@ -339,6 +339,7 @@ protected ConstructorEmitter GenerateStaticConstructor(ClassEmitter emitter) string.Format( "Target type for the proxy implements {0} which is a DynamicProxy infrastructure interface and you should never implement it yourself. Are you trying to proxy an existing proxy?", interfaceName); + throw new InvalidOperationException("This is a DynamicProxy2 error: " + message); } else if (ProxyGenerationOptions.MixinData.ContainsMixin(typeof(IProxyTargetAccessor))) { @@ -347,6 +348,7 @@ protected ConstructorEmitter GenerateStaticConstructor(ClassEmitter emitter) string.Format( "Mixin type {0} implements {1} which is a DynamicProxy infrastructure interface and you should never implement it yourself. Are you trying to mix in an existing proxy?", mixinType.Name, interfaceName); + throw new InvalidOperationException("This is a DynamicProxy2 error: " + message); } else if (additionalInterfaces.Contains(typeof(IProxyTargetAccessor))) { @@ -354,14 +356,15 @@ protected ConstructorEmitter GenerateStaticConstructor(ClassEmitter emitter) string.Format( "You passed {0} as one of additional interfaces to proxy which is a DynamicProxy infrastructure interface and is implemented by every proxy anyway. Please remove it from the list of additional interfaces to proxy.", interfaceName); + throw new InvalidOperationException("This is a DynamicProxy2 error: " + message); } else { // this can technically never happen message = string.Format("It looks like we have a bug with regards to how we handle {0}. Please report it.", interfaceName); + throw new DynamicProxyException(message); } - throw new ProxyGenerationException("This is a DynamicProxy2 error: " + message); } protected void InitializeStaticFields(Type builtType) diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/AbstractTypeEmitter.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/AbstractTypeEmitter.cs index abc0e8bc57..58cf26e75b 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/AbstractTypeEmitter.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/AbstractTypeEmitter.cs @@ -115,7 +115,7 @@ public void CopyGenericParametersFromMethod(MethodInfo methodToCopyGenericsFrom) // big sanity check if (genericTypeParams != null) { - throw new ProxyGenerationException("CopyGenericParametersFromMethod: cannot invoke me twice"); + throw new InvalidOperationException("Cannot invoke me twice"); } SetGenericTypeParameters(GenericUtil.CopyGenericArguments(methodToCopyGenericsFrom, typebuilder, name2GenericType)); @@ -316,36 +316,7 @@ public void SetGenericTypeParameters(GenericTypeParameterBuilder[] genericTypePa protected Type CreateType(TypeBuilder type) { - try - { - return type.CreateTypeInfo(); - } - catch (BadImageFormatException ex) - { - if (Debugger.IsAttached == false) - { - throw; - } - - if (ex.Message.Contains(@"HRESULT: 0x8007000B") == false) - { - throw; - } - - if (type.IsGenericTypeDefinition == false) - { - throw; - } - - var message = - "This is a DynamicProxy2 error: It looks like you encountered a bug in Visual Studio debugger, " + - "which causes this exception when proxying types with generic methods having constraints on their generic arguments." + - "This code will work just fine without the debugger attached. " + - "If you wish to use debugger you may have to switch to Visual Studio 2010 where this bug was fixed."; - var exception = new ProxyGenerationException(message); - exception.Data.Add("ProxyType", type.ToString()); - throw exception; - } + return type.CreateTypeInfo(); } protected virtual void EnsureBuildersAreInAValidState() diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ArgumentReference.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ArgumentReference.cs index 1ac800b11e..47ede399d1 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ArgumentReference.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ArgumentReference.cs @@ -44,7 +44,7 @@ public override void LoadReference(ILGenerator gen) { if (Position == -1) { - throw new ProxyGenerationException("ArgumentReference uninitialized"); + throw new InvalidOperationException("ArgumentReference uninitialized"); } switch (Position) { @@ -70,7 +70,7 @@ public override void StoreReference(ILGenerator gen) { if (Position == -1) { - throw new ProxyGenerationException("ArgumentReference uninitialized"); + throw new InvalidOperationException("ArgumentReference uninitialized"); } gen.Emit(OpCodes.Starg, Position); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConstReference.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConstReference.cs index b389233a28..3c0db248a7 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConstReference.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConstReference.cs @@ -27,10 +27,7 @@ internal class ConstReference : TypeReference public ConstReference(object value) : base(value.GetType()) { - if (!value.GetType().IsPrimitive && !(value is String)) - { - throw new ProxyGenerationException("Invalid type to ConstReference"); - } + Debug.Assert(value.GetType().IsPrimitive || value is string, "Invalid type to ConstReference"); this.value = value; } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/DefaultValueExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/DefaultValueExpression.cs index 7ab4e602e2..974d4c930c 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/DefaultValueExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/DefaultValueExpression.cs @@ -48,7 +48,7 @@ public override void Emit(IMemberEmitter member, ILGenerator gen) } else { - throw new ProxyGenerationException("Can't emit default value for type " + type); + throw new NotImplementedException("Can't emit default value for type " + type); } } @@ -66,7 +66,7 @@ private void EmitByRef(ILGenerator gen) } else { - throw new ProxyGenerationException("Can't emit default value for reference of type " + elementType); + throw new NotImplementedException("Can't emit default value for reference of type " + elementType); } } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewInstanceExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewInstanceExpression.cs index c56ae84035..beaa9e8021 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewInstanceExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewInstanceExpression.cs @@ -21,38 +21,28 @@ namespace Castle.DynamicProxy.Generators.Emitters.SimpleAST internal class NewInstanceExpression : Expression { private readonly Expression[] arguments; - private readonly Type[] constructorArgs; - private readonly Type type; private ConstructorInfo constructor; public NewInstanceExpression(ConstructorInfo constructor, params Expression[] args) { - this.constructor = constructor; + this.constructor = constructor ?? throw new ArgumentNullException(nameof(constructor)); arguments = args; } - public NewInstanceExpression(Type target, Type[] constructor_args, params Expression[] args) + public NewInstanceExpression(Type target) { - type = target; - constructorArgs = constructor_args; - arguments = args; + constructor = target.GetConstructor(Type.EmptyTypes) ?? throw new MissingMethodException("Could not find default constructor."); + arguments = null; } public override void Emit(IMemberEmitter member, ILGenerator gen) { - foreach (var exp in arguments) - { - exp.Emit(member, gen); - } - - if (constructor == null) - { - constructor = type.GetConstructor(constructorArgs); - } - - if (constructor == null) + if (arguments != null) { - throw new ProxyGenerationException("Could not find constructor matching specified arguments"); + foreach (var exp in arguments) + { + exp.Emit(member, gen); + } } gen.Emit(OpCodes.Newobj, constructor); diff --git a/src/Castle.Core/DynamicProxy/Generators/TypeElementCollection.cs b/src/Castle.Core/DynamicProxy/Generators/TypeElementCollection.cs index 09eabc3590..5d28622f6d 100644 --- a/src/Castle.Core/DynamicProxy/Generators/TypeElementCollection.cs +++ b/src/Castle.Core/DynamicProxy/Generators/TypeElementCollection.cs @@ -46,7 +46,7 @@ public void Add(TElement item) if (Contains(item)) { // there is something *really* wrong going on here - throw new ProxyGenerationException("Duplicate element: " + item); + throw new DynamicProxyException("Duplicate element: " + item); } } items.Add(item); diff --git a/src/Castle.Core/DynamicProxy/Internal/AttributeUtil.cs b/src/Castle.Core/DynamicProxy/Internal/AttributeUtil.cs index 6e977a1783..f90a6d160c 100644 --- a/src/Castle.Core/DynamicProxy/Internal/AttributeUtil.cs +++ b/src/Castle.Core/DynamicProxy/Internal/AttributeUtil.cs @@ -144,7 +144,7 @@ public static IEnumerable GetNonInheritableAttributes(this member.DeclaringType.FullName, (member is TypeInfo) ? "" : ("." + member.Name), typeof(AttributesToAvoidReplicating).FullName); - throw new ProxyGenerationException(message, e); + throw new NotSupportedException(message, e); } if (info != null) { diff --git a/src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs b/src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs index 9bf7df268d..c1edbbeff5 100644 --- a/src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs +++ b/src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs @@ -178,7 +178,7 @@ internal static void SetStaticField(this Type type, string fieldName, BindingFla FieldInfo field = type.GetField(fieldName, flags); if (field == null) { - throw new ProxyGenerationException(string.Format( + throw new DynamicProxyException(string.Format( "Could not find field named '{0}' on type {1}. This is likely a bug in DynamicProxy. Please report it.", fieldName, type)); } @@ -189,7 +189,7 @@ internal static void SetStaticField(this Type type, string fieldName, BindingFla } catch (MissingFieldException e) { - throw new ProxyGenerationException( + throw new DynamicProxyException( string.Format( "Could not find field named '{0}' on type {1}. This is likely a bug in DynamicProxy. Please report it.", fieldName, @@ -197,7 +197,7 @@ internal static void SetStaticField(this Type type, string fieldName, BindingFla } catch (TargetException e) { - throw new ProxyGenerationException( + throw new DynamicProxyException( string.Format( "There was an error trying to set field named '{0}' on type {1}. This is likely a bug in DynamicProxy. Please report it.", fieldName, @@ -209,7 +209,7 @@ internal static void SetStaticField(this Type type, string fieldName, BindingFla { throw; } - throw new ProxyGenerationException( + throw new DynamicProxyException( string.Format( "There was an error in static constructor on type {0}. This is likely a bug in DynamicProxy. Please report it.", type), e); diff --git a/src/Castle.Core/DynamicProxy/ProxyGenerationException.cs b/src/Castle.Core/DynamicProxy/ProxyGenerationException.cs deleted file mode 100644 index 37b560b4aa..0000000000 --- a/src/Castle.Core/DynamicProxy/ProxyGenerationException.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2004-2011 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace Castle.DynamicProxy -{ - using System; - - public class ProxyGenerationException : Exception - { - internal ProxyGenerationException(string message) : base(message) - { - } - - internal ProxyGenerationException(string message, Exception innerException) : base(message, innerException) - { - } - } -} \ No newline at end of file