From: <fab...@us...> - 2008-10-11 17:17:19
|
Revision: 3844 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3844&view=rev Author: fabiomaulo Date: 2008-10-11 17:17:10 +0000 (Sat, 11 Oct 2008) Log Message: ----------- - proxy validation responsibility moved to IProxyFactoryFactory trough IProxyValidator - Rename DefaultProxyFactoryFactory to Castle.ProxyFactoryFactory - some Minor changes - Actualized BREAKING CHANGES in releasenotes.txt Modified Paths: -------------- trunk/nhibernate/releasenotes.txt trunk/nhibernate/src/NHibernate/Bytecode/IProxyFactoryFactory.cs trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs trunk/nhibernate/src/NHibernate/Cfg/Environment.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1515/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs trunk/nhibernate/src/NHibernate.Test/ProxyInterface/CustomProxyFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Bytecode/Castle/ProxyFactoryFactory.cs trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs trunk/nhibernate/src/NHibernate/Proxy/IProxyValidator.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Bytecode/Castle/DefaultProxyFactoryFactory.cs trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs Modified: trunk/nhibernate/releasenotes.txt =================================================================== --- trunk/nhibernate/releasenotes.txt 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/releasenotes.txt 2008-10-11 17:17:10 UTC (rev 3844) @@ -3,10 +3,11 @@ ** BREAKING CHANGES from NH2.0.xGA to NH2.1.0 ##### Possible Breaking Changes for external frameworks ##### * ISession interface have additional methods - * DefaultProxyFactoryFactory moved to NHibernate.Bytecode.Castle + * DefaultProxyFactoryFactory moved to NHibernate.Bytecode.Castle.ProxyFactoryFactory + * IProxyFactoryFactory now provide the IProxyValidator implementation ##### Initialization time ##### - * The ProxyTypeValidator check for "internal virtual" (to be proxied need "protected internal virtual") + * The ProxyValidator check for "internal virtual" (to be intercepted by proxy need "protected internal virtual") Build 2.0.1.GA Deleted: trunk/nhibernate/src/NHibernate/Bytecode/Castle/DefaultProxyFactoryFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/Castle/DefaultProxyFactoryFactory.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate/Bytecode/Castle/DefaultProxyFactoryFactory.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -1,17 +0,0 @@ -using NHibernate.Proxy; -using NHibernate.Proxy.Poco.Castle; - -namespace NHibernate.Bytecode.Castle -{ - public class DefaultProxyFactoryFactory : IProxyFactoryFactory - { - #region IProxyFactoryFactory Members - - public IProxyFactory BuildProxyFactory() - { - return new CastleProxyFactory(); - } - - #endregion - } -} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate/Bytecode/Castle/ProxyFactoryFactory.cs (from rev 3841, trunk/nhibernate/src/NHibernate/Bytecode/Castle/DefaultProxyFactoryFactory.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/Castle/ProxyFactoryFactory.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Bytecode/Castle/ProxyFactoryFactory.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -0,0 +1,22 @@ +using NHibernate.Proxy; +using NHibernate.Proxy.Poco.Castle; + +namespace NHibernate.Bytecode.Castle +{ + public class ProxyFactoryFactory : IProxyFactoryFactory + { + #region IProxyFactoryFactory Members + + public IProxyFactory BuildProxyFactory() + { + return new CastleProxyFactory(); + } + + public IProxyValidator ProxyValidator + { + get { return new DynProxyTypeValidator(); } + } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Bytecode/IProxyFactoryFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/IProxyFactoryFactory.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate/Bytecode/IProxyFactoryFactory.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -6,7 +6,7 @@ /// An interface for factories of <see cref="IProxyFactory">proxy factory</see> instances. /// </summary> /// <remarks> - /// Currently used to abstract from the tupizer even if... + /// Used to abstract from the tupizer. /// </remarks> public interface IProxyFactoryFactory { @@ -16,6 +16,7 @@ /// </summary> /// <returns> The lazy-load proxy factory. </returns> IProxyFactory BuildProxyFactory(); + /* /// <summary> Build a proxy factory for basic proxy concerns. The return /// should be capable of properly handling newInstance() calls. @@ -27,14 +28,13 @@ /// Must pass in either superClass or interfaces (or both). /// /// </summary> - /// <param name="superClass">The abstract super class (or null if none). - /// </param> - /// <param name="interfaces">Interfaces to be proxied (or null if none). - /// </param> - /// <returns> The proxy class - /// </returns> + /// <param name="superClass">The abstract super class (or null if none).</param> + /// <param name="interfaces">Interfaces to be proxied (or null if none).</param> + /// <returns> The proxy class</returns> // TODO: H3.2 - //BasicProxyFactory buildBasicProxyFactory(System.Type superClass, System.Type[] interfaces); - */ + //BasicProxyFactory BuildBasicProxyFactory(System.Type superClass, System.Type[] interfaces); + */ + + IProxyValidator ProxyValidator { get; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -785,13 +785,14 @@ { bool validateProxy = PropertiesHelper.GetBoolean(Environment.UseProxyValidator, properties, true); HashedSet<string> allProxyErrors = null; + IProxyValidator pvalidator = Environment.BytecodeProvider.ProxyFactoryFactory.ProxyValidator; foreach (var clazz in classes.Values) { clazz.Validate(mapping); if (validateProxy) { - ICollection<string> errors = ValidateProxyInterface(clazz); + ICollection<string> errors = ValidateProxyInterface(clazz, pvalidator); if (errors != null) { if (allProxyErrors == null) @@ -817,7 +818,7 @@ } } - private static ICollection<string> ValidateProxyInterface(PersistentClass persistentClass) + private static ICollection<string> ValidateProxyInterface(PersistentClass persistentClass, IProxyValidator validator) { if (!persistentClass.IsLazy) { @@ -831,7 +832,7 @@ return null; } - return ProxyTypeValidator.ValidateType(persistentClass.ProxyInterface); + return validator.ValidateType(persistentClass.ProxyInterface); } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Cfg/Environment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Configuration; using System.Reflection; @@ -194,7 +193,7 @@ private static void SetDefaultProxyFactoryFactory() { // maitaining the optionality of set the proxyfactory.factory_class property - GlobalProperties[ProxyFactoryFactoryClass] = "NHibernate.Bytecode.Castle.DefaultProxyFactoryFactory, NHibernate"; + GlobalProperties[ProxyFactoryFactoryClass] = "NHibernate.Bytecode.Castle.ProxyFactoryFactory, NHibernate"; } private static void LoadGlobalPropertiesFromAppConfig() Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-10-11 17:17:10 UTC (rev 3844) @@ -303,7 +303,7 @@ <Compile Include="Proxy\IProxyFactory.cs" /> <Compile Include="Proxy\AbstractLazyInitializer.cs" /> <Compile Include="Proxy\NHibernateProxyHelper.cs" /> - <Compile Include="Proxy\ProxyTypeValidator.cs" /> + <Compile Include="Proxy\DynProxyTypeValidator.cs" /> <Compile Include="QueryException.cs" /> <Compile Include="ReplicationMode.cs" /> <Compile Include="SqlCommand\Alias.cs" /> @@ -452,7 +452,7 @@ <Compile Include="AdoNet\TooManyRowsAffectedException.cs" /> <Compile Include="Properties\BackFieldStrategy.cs" /> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> - <Compile Include="Bytecode\Castle\DefaultProxyFactoryFactory.cs" /> + <Compile Include="Bytecode\Castle\ProxyFactoryFactory.cs" /> <Compile Include="Bytecode\IAccessOptimizer.cs" /> <Compile Include="Bytecode\IBytecodeProvider.cs" /> <Compile Include="Bytecode\IInjectableProxyFactoryFactory.cs" /> @@ -830,6 +830,7 @@ <Compile Include="Properties\IndexPropertyAccessor.cs" /> <Compile Include="Properties\MapAccessor.cs" /> <Compile Include="Properties\NoopAccessor.cs" /> + <Compile Include="Proxy\IProxyValidator.cs" /> <Compile Include="Proxy\IEntityNotFoundDelegate.cs" /> <Compile Include="Proxy\ILazyInitializer.cs" /> <Compile Include="Proxy\Map\MapLazyInitializer.cs" /> Copied: trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs (from rev 3842, trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -0,0 +1,123 @@ +using System.Collections.Generic; +using System.Reflection; +using NHibernate.Util; + +namespace NHibernate.Proxy +{ + public class DynProxyTypeValidator : IProxyValidator + { + private readonly List<string> errors = new List<string>(); + + /// <summary> + /// Validates whether <paramref name="type"/> can be specified as the base class + /// (or an interface) for a dynamically-generated proxy. + /// </summary> + /// <param name="type">The type to validate.</param> + /// <returns> + /// A collection of errors messages, if any, or <see langword="null" /> if none were found. + /// </returns> + public ICollection<string> ValidateType(System.Type type) + { + errors.Clear(); + if (type.IsInterface) + { + // Any interface is valid as a proxy + return null; + } + CheckHasVisibleDefaultConstructor(type); + CheckAccessibleMembersAreVirtual(type); + CheckNotSealed(type); + return errors.Count > 0 ? errors : null; + } + + protected void EnlistError(System.Type type, string text) + { + errors.Add(string.Format("{0}: {1}", type, text)); + } + + protected virtual void CheckHasVisibleDefaultConstructor(System.Type type) + { + if (!HasVisibleDefaultConstructor(type)) + { + EnlistError(type, "type should have a visible (public or protected) no-argument constructor"); + } + } + + protected virtual void CheckAccessibleMembersAreVirtual(System.Type type) + { + MemberInfo[] members = type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + foreach (var member in members) + { + if (member is PropertyInfo) + { + var property = (PropertyInfo) member; + MethodInfo[] accessors = property.GetAccessors(false); + + if (accessors != null) + { + foreach (var accessor in accessors) + { + CheckMethodIsVirtual(type, accessor); + } + } + } + else if (member is MethodInfo) + { + if (member.DeclaringType == typeof (object) && member.Name == "GetType") + { + // object.GetType is ignored + continue; + } + CheckMethodIsVirtual(type, (MethodInfo) member); + } + else if (member is FieldInfo) + { + var memberField = (FieldInfo) member; + if (memberField.IsPublic || memberField.IsAssembly || memberField.IsFamilyOrAssembly) + { + EnlistError(type, "field " + member.Name + " should not be public nor internal"); + } + } + } + } + + protected virtual void CheckMethodIsVirtual(System.Type type, MethodInfo method) + { + if (!IsProxeable(method)) + { + EnlistError(type, "method " + method.Name + " should be 'public/protected virtual' or 'protected internal virtual'"); + } + } + + public virtual bool IsProxeable(MethodInfo method) + { + // In NET if IsVirtual is false or IsFinal is true, then the method cannot be overridden. + return !(method.DeclaringType != typeof (object) && !IsDisposeMethod(method) + && (method.IsPublic || method.IsAssembly || method.IsFamilyOrAssembly) + && (!method.IsVirtual || method.IsFinal || (method.IsVirtual && method.IsAssembly))); + } + + protected static bool IsDisposeMethod(MethodBase method) + { + return method.Name.Equals("Dispose") && method.MemberType == MemberTypes.Method && method.GetParameters().Length == 0; + } + + protected virtual bool HasVisibleDefaultConstructor(System.Type type) + { + ConstructorInfo constructor = + type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, + System.Type.EmptyTypes, null); + + return constructor != null && !constructor.IsPrivate; + } + + protected void CheckNotSealed(System.Type type) + { + if (ReflectHelper.IsFinalClass(type)) + { + EnlistError(type, "type should not be sealed"); + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Added: trunk/nhibernate/src/NHibernate/Proxy/IProxyValidator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Proxy/IProxyValidator.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Proxy/IProxyValidator.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Reflection; + +namespace NHibernate.Proxy +{ + /// <summary> + /// Proxeability validator. + /// </summary> + public interface IProxyValidator + { + /// <summary> + /// Validates whether <paramref name="type"/> can be specified as the base class + /// (or an interface) for a dynamically-generated proxy. + /// </summary> + /// <param name="type">The type to validate.</param> + /// <returns> + /// A collection of errors messages, if any, or <see langword="null" /> if none were found. + /// </returns> + /// <remarks> + /// When the configuration property "use_proxy_validator" is set to true(default), the result of this method + /// is used to throw a detailed exception about the proxeability of the given <paramref name="type"/>. + /// </remarks> + ICollection<string> ValidateType(System.Type type); + + /// <summary> + /// Validate if a single method can be intercepted by proxy. + /// </summary> + /// <param name="method">The given method to check.</param> + /// <returns><see langword="true"/> if the method can be intercepted by proxy. + /// <see langword="false"/> otherwise. + /// </returns> + /// <remarks> + /// This method can be used internally by the <see cref="ValidateType"/> and is used + /// by <see cref="NHibernate.Tuple.Entity.PocoEntityTuplizer"/> to log errors when + /// a property accessor can't be intercepted by proxy. + /// The validation of property accessors is fairly enough if you ecampsulate each property. + /// </remarks> + bool IsProxeable(MethodInfo method); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -77,7 +77,7 @@ { return Identifier; } - else if (methodName == "Finalize") + else if (methodName == "Dispose") { return null; } Deleted: trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -1,122 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using NHibernate.Util; - -namespace NHibernate.Proxy -{ - public class ProxyTypeValidator - { - private ProxyTypeValidator() {} - - /// <summary> - /// Validates whether <paramref name="type"/> can be specified as the base class - /// (or an interface) for a dynamically-generated proxy. - /// </summary> - /// <returns> - /// A collection of errors, if any, or <see langword="null" /> if none were found. - /// </returns> - /// <param name="type">The type to validate.</param> - public static ICollection<string> ValidateType(System.Type type) - { - var errors = new List<string>(); - - if (type.IsInterface) - { - // Any interface is valid as a proxy - return null; - } - CheckHasVisibleDefaultConstructor(type, errors); - CheckAccessibleMembersAreVirtual(type, errors); - CheckNotSealed(type, errors); - if (errors.Count > 0) - { - return errors; - } - return null; - } - - private static void Error(IList errors, System.Type type, string text) - { - errors.Add(string.Format("{0}: {1}", type, text)); - } - - private static void CheckHasVisibleDefaultConstructor(System.Type type, IList errors) - { - if (!HasVisibleDefaultConstructor(type)) - { - Error(errors, type, "type should have a visible (public or protected) no-argument constructor"); - } - } - - private static void CheckAccessibleMembersAreVirtual(System.Type type, IList errors) - { - MemberInfo[] members = type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - - foreach (MemberInfo member in members) - { - if (member is PropertyInfo) - { - var property = (PropertyInfo) member; - MethodInfo[] accessors = property.GetAccessors(false); - - foreach (MethodInfo accessor in accessors) - { - CheckMethodIsVirtual(type, accessor, errors); - } - } - else if (member is MethodInfo) - { - if (member.DeclaringType == typeof (object) && member.Name == "GetType") - { - // object.GetType is ignored - continue; - } - CheckMethodIsVirtual(type, (MethodInfo) member, errors); - } - else if (member is FieldInfo) - { - var memberField = (FieldInfo) member; - if (memberField.IsPublic || memberField.IsAssembly || memberField.IsFamilyOrAssembly) - { - Error(errors, type, "field " + member.Name + " should not be public nor internal"); - } - } - } - } - - private static void CheckMethodIsVirtual(System.Type type, MethodInfo method, IList errors) - { - if (method.DeclaringType != typeof (object) && !IsDisposeMethod(method) && method.IsPublic || method.IsAssembly - || method.IsFamilyOrAssembly) - { - if (!method.IsVirtual || method.IsFinal || (method.IsVirtual && method.IsAssembly)) - { - Error(errors, type, "method " + method.Name + " should be 'public/protected virtual' or 'protected internal virtual'"); - } - } - } - - private static bool IsDisposeMethod(MethodBase method) - { - return method.Name.Equals("Dispose") && method.MemberType == MemberTypes.Method && method.GetParameters().Length == 0; - } - - private static bool HasVisibleDefaultConstructor(System.Type type) - { - ConstructorInfo constructor = - type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, - System.Type.EmptyTypes, null); - - return constructor != null && !constructor.IsPrivate; - } - - private static void CheckNotSealed(System.Type type, IList errors) - { - if (ReflectHelper.IsFinalClass(type)) - { - Error(errors, type, "type should not be sealed"); - } - } - } -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -23,6 +23,7 @@ private readonly bool isValidatableImplementor; private readonly HashedSet<string> lazyPropertyNames = new HashedSet<string>(); private readonly IReflectionOptimizer optimizer; + private readonly IProxyValidator proxyValidator; public PocoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) : base(entityMetamodel, mappedEntity) @@ -46,6 +47,8 @@ { optimizer = Cfg.Environment.BytecodeProvider.GetReflectionOptimizer(mappedClass, getters, setters); } + + proxyValidator = Cfg.Environment.BytecodeProvider.ProxyFactoryFactory.ProxyValidator; } public override System.Type ConcreteProxyClass @@ -163,21 +166,26 @@ return pf; } - private static void LogPropertyAccessorsErrors(PersistentClass persistentClass) + private void LogPropertyAccessorsErrors(PersistentClass persistentClass) { + if (proxyValidator == null) + { + return; + } + // This method work when Environment.UseProxyValidator is off System.Type clazz = persistentClass.MappedClass; foreach (Mapping.Property property in persistentClass.PropertyIterator) { MethodInfo method = property.GetGetter(clazz).Method; - if (ShouldLogError(method)) + if (!proxyValidator.IsProxeable(method)) { log.Error( string.Format("Getters of lazy classes cannot be final: {0}.{1}", persistentClass.MappedClass.FullName, property.Name)); } method = property.GetSetter(clazz).Method; - if (ShouldLogError(method)) + if (!proxyValidator.IsProxeable(method)) { log.Error( string.Format("Setters of lazy classes cannot be final: {0}.{1}", persistentClass.MappedClass.FullName, @@ -186,12 +194,6 @@ } } - private static bool ShouldLogError(MethodBase method) - { - // In NET if IsVirtual is false or IsFinal is true, then the method cannot be overridden. - return method != null && (!method.IsVirtual || method.IsFinal || (method.IsVirtual && method.IsAssembly)); - } - protected virtual IProxyFactory BuildProxyFactoryInternal(PersistentClass @class, IGetter getter, ISetter setter) { return Cfg.Environment.BytecodeProvider.ProxyFactoryFactory.BuildProxyFactory(); Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -9,6 +9,8 @@ [TestFixture] public class Fixture { + private readonly IProxyValidator pv = new DynProxyTypeValidator(); + public class CPPMimicBase { public virtual void Dispose() @@ -61,11 +63,11 @@ [Test] public void NoExceptionForDispose() { - ICollection<string> errs = ProxyTypeValidator.ValidateType(typeof (CPPMimic)); + ICollection<string> errs = pv.ValidateType(typeof (CPPMimic)); Assert.That(errs, Is.Null); - errs = ProxyTypeValidator.ValidateType(typeof(Another)); + errs = pv.ValidateType(typeof(Another)); Assert.That(errs, Is.Null); - errs = ProxyTypeValidator.ValidateType(typeof(OneMore)); + errs = pv.ValidateType(typeof(OneMore)); Assert.That(errs.Count, Is.EqualTo(1)); } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1515/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1515/Fixture.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1515/Fixture.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -8,6 +8,8 @@ [TestFixture] public class Fixture { + private readonly IProxyValidator pv = new DynProxyTypeValidator(); + public class ClassWithInternal { internal virtual void DoSomething() {} @@ -21,7 +23,7 @@ [Test] public void NoExceptionForMethod() { - ICollection<string> errs = ProxyTypeValidator.ValidateType(typeof(ClassWithInternal)); + ICollection<string> errs = pv.ValidateType(typeof(ClassWithInternal)); Assert.That(errs, Is.Not.Null); Assert.That(errs.Count, Is.EqualTo(1)); } @@ -29,7 +31,7 @@ [Test] public void NoExceptionForProperty() { - ICollection<string> errs = ProxyTypeValidator.ValidateType(typeof(ClassWithInternalProperty)); + ICollection<string> errs = pv.ValidateType(typeof(ClassWithInternalProperty)); Assert.That(errs, Is.Not.Null); Assert.That(errs.Count, Is.EqualTo(2)); } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -1,5 +1,4 @@ using System; -using System.Collections; using NHibernate.Proxy; using NUnit.Framework; using System.Collections.Generic; @@ -9,9 +8,11 @@ [TestFixture] public class Fixture { + private readonly IProxyValidator pv = new DynProxyTypeValidator(); + private void Validate(System.Type type) { - ICollection<string> errors = ProxyTypeValidator.ValidateType(type); + ICollection<string> errors = pv.ValidateType(type); if (errors != null) { throw new InvalidProxyTypeException(errors); Modified: trunk/nhibernate/src/NHibernate.Test/ProxyInterface/CustomProxyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProxyInterface/CustomProxyFixture.cs 2008-10-11 13:09:53 UTC (rev 3843) +++ trunk/nhibernate/src/NHibernate.Test/ProxyInterface/CustomProxyFixture.cs 2008-10-11 17:17:10 UTC (rev 3844) @@ -72,6 +72,11 @@ return new DataBindingProxyFactory(); } + public IProxyValidator ProxyValidator + { + get { return new DynProxyTypeValidator(); } + } + #endregion } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |