|
From: <fab...@us...> - 2011-04-18 21:24:31
|
Revision: 5718
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5718&view=rev
Author: fabiomaulo
Date: 2011-04-18 21:24:23 +0000 (Mon, 18 Apr 2011)
Log Message:
-----------
- Sync between proxy-validator and proxy-factory
- removed no more used exception about proxy-factory-factory
Breaking Change:
what was "only" a log-error in PocoEntityTuplizer.LogPropertyAccessorsErrors is now checked by the proxy-validator and an early exception is thrown when the proxy-validator is active.
Modified Paths:
--------------
trunk/nhibernate/releasenotes.txt
trunk/nhibernate/src/NHibernate/Linq/EnumerableHelper.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/DictionaryGenerator.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/QueryableGenerator.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs
trunk/nhibernate/src/NHibernate/Proxy/DynamicProxy/ProxyFactory.cs
trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
trunk/nhibernate/src/NHibernate.Test/Insertordering/Membership.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/OrderLine.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Cat.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Area.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/City.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Country.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Person.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1693/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1868/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1922/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1925/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2245/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2420/MyTable.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectionHelperIsMethodOfTests.cs
trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/ComplexDomain.cs
trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/SimpleVersioned.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Proxy/DefaultDynamicProxyMethodCheckerExtensions.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/ShouldBeProxiableTests.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Bytecode/ProxyFactoryFactoryNotConfiguredException.cs
Modified: trunk/nhibernate/releasenotes.txt
===================================================================
--- trunk/nhibernate/releasenotes.txt 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/releasenotes.txt 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,9 +4,11 @@
##### Possible Breaking Changes #####
* [NH-2550] - Allow public access to FieldInterceptor Session (IFieldInterceptor changed)
- * [NH-2593] - Form Microsoft SQL Server the default batch-size (adonet.batch_size) is set to 20 where not explicit defined in the session-factory configuration
+ * [NH-2593] - For Microsoft SQL Server the default batch-size (adonet.batch_size) is set to 20 where not explicit defined in the session-factory configuration
* - ICollectionPersister added property to fix [NH-2489]
* [NH-2605] Refactorize MultiQuery/MultiCriteria implementation to delegate responsibility to IDrive (IDrive changed).
+ * For users who don't look at Log-ERROR, to prevent wrong behavior when lazy-properties are used the DynamicProxyValidator validates the accessability of properties setters.
+
Build 3.2.0.Aplha2 (rev5715)
=============================
** Bug
Deleted: trunk/nhibernate/src/NHibernate/Bytecode/ProxyFactoryFactoryNotConfiguredException.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Bytecode/ProxyFactoryFactoryNotConfiguredException.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate/Bytecode/ProxyFactoryFactoryNotConfiguredException.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -1,29 +0,0 @@
-using System;
-using System.Runtime.Serialization;
-
-namespace NHibernate.Bytecode
-{
-
- [Serializable]
- public class ProxyFactoryFactoryNotConfiguredException : HibernateByteCodeException
- {
- public ProxyFactoryFactoryNotConfiguredException() {}
-
- protected ProxyFactoryFactoryNotConfiguredException(SerializationInfo info,
- StreamingContext context) : base(info, context) {}
-
- public override string Message
- {
- get
- {
- const string msg = @"The ProxyFactoryFactory was not configured.
-Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.
-Example:
-<property name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
-Example:
-<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>";
- return msg;
- }
- }
- }
-}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/EnumerableHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/EnumerableHelper.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate/Linq/EnumerableHelper.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -55,58 +55,6 @@
}
return ((MemberExpression)property.Body).Member;
}
-
- /// <summary>
- /// Check if a method is declared in a given <see cref="System.Type"/>.
- /// </summary>
- /// <param name="source">The method to check.</param>
- /// <param name="realDeclaringType">The where the method is really declared.</param>
- /// <returns>True if the method is an implementation of the method declared in <paramref name="realDeclaringType"/>; false otherwise. </returns>
- public static bool IsMethodOf(this MethodInfo source, System.Type realDeclaringType)
- {
- if (source == null)
- {
- throw new ArgumentNullException("source");
- }
- if (realDeclaringType == null)
- {
- throw new ArgumentNullException("realDeclaringType");
- }
- var methodDeclaringType = source.DeclaringType;
- if(realDeclaringType.Equals(methodDeclaringType))
- {
- return true;
- }
- if (methodDeclaringType.IsGenericType && !methodDeclaringType.IsGenericTypeDefinition &&
- realDeclaringType.Equals(methodDeclaringType.GetGenericTypeDefinition()))
- {
- return true;
- }
- if (realDeclaringType.IsInterface)
- {
- var declaringTypeInterfaces = methodDeclaringType.GetInterfaces();
- if(declaringTypeInterfaces.Contains(realDeclaringType))
- {
- var methodsMap = methodDeclaringType.GetInterfaceMap(realDeclaringType);
- if(methodsMap.TargetMethods.Contains(source))
- {
- return true;
- }
- }
- if (realDeclaringType.IsGenericTypeDefinition)
- {
- bool implements = declaringTypeInterfaces
- .Where(t => t.IsGenericType && t.GetGenericTypeDefinition().Equals(realDeclaringType))
- .Select(implementedGenericInterface => methodDeclaringType.GetInterfaceMap(implementedGenericInterface))
- .Any(methodsMap => methodsMap.TargetMethods.Contains(source));
- if (implements)
- {
- return true;
- }
- }
- }
- return false;
- }
}
// TODO rename / remove - reflection helper above is better
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/DictionaryGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/DictionaryGenerator.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/DictionaryGenerator.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -6,6 +6,7 @@
using System.Reflection;
using NHibernate.Hql.Ast;
using NHibernate.Linq.Visitors;
+using NHibernate.Util;
namespace NHibernate.Linq.Functions
{
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/QueryableGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/QueryableGenerator.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/QueryableGenerator.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -5,6 +5,7 @@
using System.Reflection;
using NHibernate.Hql.Ast;
using NHibernate.Linq.Visitors;
+using NHibernate.Util;
namespace NHibernate.Linq.Functions
{
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-18 21:24:23 UTC (rev 5718)
@@ -496,6 +496,7 @@
<Compile Include="Properties\PascalCaseMUnderscoreStrategy.cs" />
<Compile Include="Properties\PascalCaseUnderscoreStrategy.cs" />
<Compile Include="Properties\PropertyAccessorFactory.cs" />
+ <Compile Include="Proxy\DefaultDynamicProxyMethodCheckerExtensions.cs" />
<Compile Include="Proxy\DefaultLazyInitializer.cs" />
<Compile Include="Proxy\DefaultProxyFactory.cs" />
<Compile Include="Proxy\DynamicProxy\DefaultArgumentHandler.cs" />
@@ -680,7 +681,6 @@
<Compile Include="Bytecode\HibernateByteCodeException.cs" />
<Compile Include="Bytecode\IInjectableCollectionTypeFactoryClass.cs" />
<Compile Include="Bytecode\IObjectsFactory.cs" />
- <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" />
<Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" />
<Compile Include="Cache\FakeCache.cs" />
<Compile Include="Cfg\BindMappingEventArgs.cs" />
Added: trunk/nhibernate/src/NHibernate/Proxy/DefaultDynamicProxyMethodCheckerExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/DefaultDynamicProxyMethodCheckerExtensions.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Proxy/DefaultDynamicProxyMethodCheckerExtensions.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -0,0 +1,50 @@
+using System;
+using System.Linq;
+using System.Reflection;
+using NHibernate.Util;
+
+namespace NHibernate.Proxy
+{
+ public static class DefaultDynamicProxyMethodCheckerExtensions
+ {
+ public static bool IsProxiable(this MethodInfo method)
+ {
+ return !method.IsFinal
+ && (method.DeclaringType != typeof(MarshalByRefObject))
+ && (method.DeclaringType != typeof(object) || !"finalize".Equals(method.Name.ToLowerInvariant()))
+ &&
+ (
+ ((method.IsPublic || method.IsFamily) && (method.IsVirtual || method.IsAbstract)) // public or protected (virtual)
+ ||
+ (method.IsFamilyOrAssembly && (method.IsVirtual || method.IsAbstract)) // internal protected virtual
+ );
+ }
+
+ public static bool ShouldBeProxiable(this MethodInfo method)
+ {
+ // to use only for real methods (no getter/setter)
+ return (method.DeclaringType != typeof (MarshalByRefObject)) &&
+ (method.DeclaringType != typeof (object) || !"finalize".Equals(method.Name.ToLowerInvariant())) &&
+ (!(method.DeclaringType == typeof (object) && "GetType".Equals(method.Name))) &&
+ !IsDisposeMethod(method) &&
+ (method.IsPublic || method.IsAssembly || method.IsFamilyOrAssembly);
+ }
+
+ public static bool ShouldBeProxiable(this PropertyInfo propertyInfo)
+ {
+ if(propertyInfo != null)
+ {
+ var accessors = propertyInfo.GetAccessors(true);
+ return accessors.Where(x => x.IsPublic || x.IsAssembly || x.IsFamilyOrAssembly).Any();
+ }
+ return true;
+ }
+
+ private static bool IsDisposeMethod(MethodInfo method)
+ {
+ // NH-1464
+ return method.Name.Equals("Dispose") && method.MemberType == MemberTypes.Method && method.GetParameters().Length == 0;
+ // return method.Name.Equals("Dispose") && method.IsMethodOf(typeof(IDisposable));
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate/Proxy/DynProxyTypeValidator.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -52,36 +52,44 @@
if (member is PropertyInfo)
{
var property = (PropertyInfo) member;
- MethodInfo[] accessors = property.GetAccessors(false);
+ if(property.ShouldBeProxiable())
+ {
+ MethodInfo[] accessors = property.GetAccessors(true);
- if (accessors != null)
- {
- foreach (var accessor in accessors)
+ if (accessors != null)
{
- CheckMethodIsVirtual(type, accessor);
+ foreach (var accessor in accessors)
+ {
+ CheckMethodIsVirtual(type, accessor);
+ }
}
}
}
else if (member is MethodInfo)
{
- if (member.DeclaringType == typeof (object) && member.Name == "GetType")
+ var methodInfo = (MethodInfo) member;
+ // avoid the check of properties getter and setter because already checked when the PropertyInfo was found.
+ if (!IsPropertyMethod(methodInfo) && methodInfo.ShouldBeProxiable())
{
- // object.GetType is ignored
- continue;
+ CheckMethodIsVirtual(type, methodInfo);
}
- 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");
+ EnlistError(type, "field " + member.Name + " should not be public nor internal (ecapsulate it in a property).");
}
}
}
}
+ private bool IsPropertyMethod(MethodInfo methodInfo)
+ {
+ return methodInfo.IsSpecialName && (methodInfo.Name.StartsWith("get_") || methodInfo.Name.StartsWith("set_"));
+ }
+
protected virtual void CheckMethodIsVirtual(System.Type type, MethodInfo method)
{
if (!IsProxeable(method))
@@ -92,17 +100,11 @@
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)));
+ // NH: this method is used even when the proxy-validation at start-up is turned off to check each persistent property (only persistent properties).
+ // it must be in sync with what is really proxiable by the proxy-factory.
+ return method.IsProxiable();
}
- 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 =
Modified: trunk/nhibernate/src/NHibernate/Proxy/DynamicProxy/ProxyFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/DynamicProxy/ProxyFactory.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate/Proxy/DynamicProxy/ProxyFactory.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -173,20 +173,10 @@
const BindingFlags candidateMethodsBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
return
type.GetMethods(candidateMethodsBindingFlags)
- .Where(method => IsProxiable(method))
+ .Where(method=> method.IsProxiable())
.Concat(interfaces.SelectMany(interfaceType => interfaceType.GetMethods())).Distinct();
}
- private bool IsProxiable(MethodInfo method)
- {
- return (
- ((method.IsPublic || method.IsFamily || method.IsAssembly || method.IsFamilyOrAssembly) && (method.IsVirtual || method.IsAbstract))
- && !method.IsFinal
- && (method.DeclaringType != typeof (MarshalByRefObject)))
- && (method.DeclaringType != typeof (object) || !"finalize".Equals(method.Name.ToLowerInvariant())
- );
- }
-
private static ConstructorBuilder DefineConstructor(TypeBuilder typeBuilder)
{
const MethodAttributes constructorAttributes = MethodAttributes.Public |
Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -689,5 +689,57 @@
}
return HasProperty(source.BaseType, propertyName) || source.GetInterfaces().Any(@interface => HasProperty(@interface, propertyName));
}
- }
+
+ /// <summary>
+ /// Check if a method is declared in a given <see cref="System.Type"/>.
+ /// </summary>
+ /// <param name="source">The method to check.</param>
+ /// <param name="realDeclaringType">The where the method is really declared.</param>
+ /// <returns>True if the method is an implementation of the method declared in <paramref name="realDeclaringType"/>; false otherwise. </returns>
+ public static bool IsMethodOf(this MethodInfo source, System.Type realDeclaringType)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException("source");
+ }
+ if (realDeclaringType == null)
+ {
+ throw new ArgumentNullException("realDeclaringType");
+ }
+ var methodDeclaringType = source.DeclaringType;
+ if(realDeclaringType.Equals(methodDeclaringType))
+ {
+ return true;
+ }
+ if (methodDeclaringType.IsGenericType && !methodDeclaringType.IsGenericTypeDefinition &&
+ realDeclaringType.Equals(methodDeclaringType.GetGenericTypeDefinition()))
+ {
+ return true;
+ }
+ if (realDeclaringType.IsInterface)
+ {
+ var declaringTypeInterfaces = methodDeclaringType.GetInterfaces();
+ if(declaringTypeInterfaces.Contains(realDeclaringType))
+ {
+ var methodsMap = methodDeclaringType.GetInterfaceMap(realDeclaringType);
+ if(methodsMap.TargetMethods.Contains(source))
+ {
+ return true;
+ }
+ }
+ if (realDeclaringType.IsGenericTypeDefinition)
+ {
+ bool implements = declaringTypeInterfaces
+ .Where(t => t.IsGenericType && t.GetGenericTypeDefinition().Equals(realDeclaringType))
+ .Select(implementedGenericInterface => methodDeclaringType.GetInterfaceMap(implementedGenericInterface))
+ .Any(methodsMap => methodsMap.TargetMethods.Contains(source));
+ if (implements)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
}
Modified: trunk/nhibernate/src/NHibernate.Test/Insertordering/Membership.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Insertordering/Membership.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/Insertordering/Membership.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -16,8 +16,8 @@
}
public virtual int Id { get; protected set; }
- public virtual User User { get; private set; }
- public virtual Group Group { get; private set; }
- public virtual DateTime ActivationDate { get; private set; }
+ public virtual User User { get; protected set; }
+ public virtual Group Group { get; protected set; }
+ public virtual DateTime ActivationDate { get; protected set; }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/OrderLine.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/OrderLine.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/OrderLine.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -10,7 +10,7 @@
Product = product;
}
- public virtual int Id { get; private set; }
+ public virtual int Id { get; protected set; }
public virtual string Description { get; set; }
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Cat.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Cat.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Cat.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -2,7 +2,7 @@
{
public abstract class Cat
{
- public virtual int Id { get; private set; }
+ public virtual int Id { get; protected set; }
public virtual string Name { get; set; }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Area.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Area.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Area.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,10 +4,10 @@
{
public abstract class Area
{
- public virtual string Code { get; private set; }
- public virtual string Name { get; private set; }
- public virtual int Version { get; private set; }
- public virtual IDictionary<int, AreaStatistics> Statistics { get; private set; }
+ public virtual string Code { get; protected set; }
+ public virtual string Name { get; protected set; }
+ public virtual int Version { get; protected set; }
+ public virtual IDictionary<int, AreaStatistics> Statistics { get; protected set; }
protected Area() {}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/City.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/City.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/City.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -2,7 +2,7 @@
{
public class City : Area
{
- public virtual Country Country { get; private set; }
+ public virtual Country Country { get; protected set; }
protected City() {}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Country.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Country.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Country.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,8 +4,8 @@
{
public class Country : Area
{
- public virtual IList<string> Routes { get; private set; }
- public virtual IList<City> Cities { get; private set; }
+ public virtual IList<string> Routes { get; protected set; }
+ public virtual IList<City> Cities { get; protected set; }
protected Country() {}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Person.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Person.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Person.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,9 +4,9 @@
{
public class Person
{
- public virtual Guid PersonId { get; private set; }
- public virtual string Name { get; private set; }
- public virtual int Version { get; private set; }
+ public virtual Guid PersonId { get; protected set; }
+ public virtual string Name { get; protected set; }
+ public virtual int Version { get; protected set; }
protected Person() {}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1693/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1693/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1693/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -2,7 +2,7 @@
{
public class Invoice
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual string Mode { get; set; }
public virtual int Category { get; set; }
public virtual int Num { get; set; }
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,13 +4,13 @@
{
public class Category
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime ValidUntil { get; set; }
}
public class Invoice
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime ValidUntil { get; set; }
public virtual int Foo { get; set; }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1868/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1868/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1868/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,19 +4,19 @@
{
public class Category
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime ValidUntil { get; set; }
}
public class Package
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime ValidUntil { get; set; }
}
public class Invoice
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime ValidUntil { get; set; }
public virtual Category Category { get; set; }
public virtual Package Package { get; set; }
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,7 +4,7 @@
{
public class Invoice
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime Issued { get; set; }
protected virtual DateTime issued { get; set; }
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,14 +4,14 @@
{
public class Category
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual Category ParentCategory { get; set; }
public virtual DateTime ValidUntil { get; set; }
}
public class Invoice
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime Issued { get; set; }
public virtual Category Category { get; set; }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1922/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1922/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1922/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -5,7 +5,7 @@
{
public class Customer
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime ValidUntil { get; set; }
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1925/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1925/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1925/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,14 +4,14 @@
{
public class Customer
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual ISet<Invoice> Invoices { get; set; }
public virtual string Name { get; set; }
}
public class Invoice
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual Customer Customer { get; set; }
public virtual int Number { get; set; }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -5,14 +5,14 @@
{
public class Customer
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual ISet<Invoice> Invoices { get; set; }
public virtual DateTime ValidUntil { get; set; }
}
public class Invoice
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual DateTime ValidUntil { get; set; }
public virtual Customer Customer { get; set; }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -2,7 +2,7 @@
{
public class Customer
{
- public virtual int ID { get; private set; }
+ public virtual int ID { get; protected set; }
public virtual string Name { get; set; }
public virtual int Age { get; set; }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2245/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2245/Model.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2245/Model.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -6,7 +6,7 @@
public class Foo
{
public Foo() {}
- public virtual Guid Id {get; private set;}
+ public virtual Guid Id { get; protected set; }
public virtual string Name {get; set;}
public virtual string Description {get; set;}
public virtual int Version{get; set;}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2420/MyTable.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2420/MyTable.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2420/MyTable.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -4,7 +4,7 @@
{
public class MyTable
{
- public virtual int Id { get; private set; }
+ public virtual int Id { get; protected set; }
public virtual string String { get; set; }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Domain.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Domain.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -8,7 +8,7 @@
public virtual Int64 Id
{
get;
- private set;
+ protected set;
}
public virtual String Name
{
@@ -23,7 +23,7 @@
public virtual IEnumerable<Order> Orders
{
get;
- private set;
+ protected set;
}
}
@@ -32,7 +32,7 @@
public virtual Int32 Id
{
get;
- private set;
+ protected set;
}
public virtual DateTime Date
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/Fixture.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -240,6 +240,21 @@
public void VirtualPublicImplementsInterface()
{
Assert.Throws<InvalidProxyTypeException>(() => Validate(typeof(NonVirtualPublicImplementsInterface)));
- }
+ }
+
+ public class InvalidVirtualPrivateAutoProperty : ValidClass
+ {
+ public virtual int NonVirtualSetterProperty
+ {
+ get;
+ private set;
+ }
+ }
+
+ [Test]
+ public void PrivateSetterOnVirtualPropertyShouldThrows()
+ {
+ Assert.Throws<InvalidProxyTypeException>(() => Validate(typeof(InvalidVirtualPrivateAutoProperty)));
+ }
}
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/ShouldBeProxiableTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/ShouldBeProxiableTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ProxyValidator/ShouldBeProxiableTests.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -0,0 +1,104 @@
+using System;
+using System.Reflection;
+using NHibernate.Proxy;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.NHSpecificTest.ProxyValidator
+{
+ public class ShouldBeProxiableTests
+ {
+ private class MyClass: IDisposable
+ {
+ public void Dispose()
+ {
+
+ }
+ }
+ private class ProtectedNoVirtualProperty
+ {
+ protected int Aprop { get; set; }
+ protected internal int AProtectedInternalProp { get; set; }
+ internal int AInternalProp { get; set; }
+ }
+
+ private class NoVirtualMethods
+ {
+ protected void AProtected() { }
+ private void APrivate() { }
+ public void APublic() { }
+ internal void AInternal() { }
+ protected internal void AProtectedInternal() { }
+ }
+
+ [Test]
+ public void GetTypeNotBeProxiable()
+ {
+ var method = typeof(object).GetMethod("GetType");
+ method.ShouldBeProxiable().Should().Be.False();
+ }
+
+ [Test]
+ public void DisposeNotBeProxiable()
+ {
+ var method = typeof(MyClass).GetMethod("Dispose");
+ method.ShouldBeProxiable().Should().Be.False();
+ }
+
+ [Test]
+ public void WhenProtectedNoVirtualPropertyThenShouldntBeProxiable()
+ {
+ var prop = typeof(ProtectedNoVirtualProperty).GetProperty("Aprop", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ prop.ShouldBeProxiable().Should().Be.False();
+ }
+
+ [Test]
+ public void WhenProtectedInternalNoVirtualPropertyThenShouldBeProxiable()
+ {
+ var prop = typeof(ProtectedNoVirtualProperty).GetProperty("AProtectedInternalProp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ prop.ShouldBeProxiable().Should().Be.True();
+ }
+
+ [Test]
+ public void WhenInternalNoVirtualPropertyThenShouldBeProxiable()
+ {
+ var prop = typeof(ProtectedNoVirtualProperty).GetProperty("AInternalProp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ prop.ShouldBeProxiable().Should().Be.True();
+ }
+
+ [Test]
+ public void WhenProtectedNoVirtualMethodThenShouldntBeProxiable()
+ {
+ var method = typeof(NoVirtualMethods).GetMethod("AProtected", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ method.ShouldBeProxiable().Should().Be.False();
+ }
+
+ [Test]
+ public void WhenProtectedInternalNoVirtualMethodThenShouldBeProxiable()
+ {
+ var method = typeof(NoVirtualMethods).GetMethod("AProtectedInternal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ method.ShouldBeProxiable().Should().Be.True();
+ }
+
+ [Test]
+ public void WhenPrivateMethodThenShouldntBeProxiable()
+ {
+ var method = typeof(NoVirtualMethods).GetMethod("APrivate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ method.ShouldBeProxiable().Should().Be.False();
+ }
+
+ [Test]
+ public void WhenPublicMethodThenShouldBeProxiable()
+ {
+ var method = typeof(NoVirtualMethods).GetMethod("APublic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ method.ShouldBeProxiable().Should().Be.True();
+ }
+
+ [Test]
+ public void WhenInternalMethodThenShouldBeProxiable()
+ {
+ var method = typeof(NoVirtualMethods).GetMethod("AInternal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ method.ShouldBeProxiable().Should().Be.True();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-18 21:24:23 UTC (rev 5718)
@@ -769,6 +769,7 @@
<Compile Include="NHSpecificTest\Properties\CompositePropertyRefTest.cs" />
<Compile Include="NHSpecificTest\Properties\DynamicEntityTest.cs" />
<Compile Include="NHSpecificTest\Properties\Model.cs" />
+ <Compile Include="NHSpecificTest\ProxyValidator\ShouldBeProxiableTests.cs" />
<Compile Include="NHSpecificTest\SqlConverterAndMultiQuery\Fixture.cs" />
<Compile Include="NHSpecificTest\SqlConverterAndMultiQuery\Model.cs" />
<Compile Include="NHSpecificTest\SqlConverterAndMultiQuery\SqlConverter.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectionHelperIsMethodOfTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectionHelperIsMethodOfTests.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectionHelperIsMethodOfTests.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Reflection;
using NHibernate.Linq;
+using NHibernate.Util;
using NUnit.Framework;
using SharpTestsEx;
Modified: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/ComplexDomain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/ComplexDomain.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/ComplexDomain.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -5,7 +5,7 @@
public class Bar
{
public virtual int Id { get; set; }
- public virtual byte[] Timestamp { get; private set; }
+ public virtual byte[] Timestamp { get; protected set; }
public virtual int AField { get; set; }
public virtual Foo Foo { get; set; }
}
@@ -17,7 +17,7 @@
Bars = new HashedSet<Bar>();
}
public virtual int Id { get; set; }
- public virtual byte[] Timestamp { get; private set; }
+ public virtual byte[] Timestamp { get; protected set; }
public virtual int AField { get; set; }
public virtual ISet<Bar> Bars { get; set; }
Modified: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/SimpleVersioned.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/SimpleVersioned.cs 2011-04-18 17:25:00 UTC (rev 5717)
+++ trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/SimpleVersioned.cs 2011-04-18 21:24:23 UTC (rev 5718)
@@ -2,8 +2,8 @@
{
public class SimpleVersioned
{
- public virtual int Id { get; private set; }
- public virtual byte[] LastModified { get; private set; }
+ public virtual int Id { get; protected set; }
+ public virtual byte[] LastModified { get; protected set; }
public virtual string Something { get; set; }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|