You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2008-10-19 21:16:51
|
Revision: 3867 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3867&view=rev Author: fabiomaulo Date: 2008-10-19 21:16:44 +0000 (Sun, 19 Oct 2008) Log Message: ----------- Improv session Load to use entity-name Possible breaking change for related FWs: see ISession Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ISession.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs Modified: trunk/nhibernate/src/NHibernate/ISession.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ISession.cs 2008-10-19 20:25:16 UTC (rev 3866) +++ trunk/nhibernate/src/NHibernate/ISession.cs 2008-10-19 21:16:44 UTC (rev 3867) @@ -214,6 +214,16 @@ /// <returns>the persistent instance</returns> object Load(System.Type theType, object id, LockMode lockMode); + /// <summary> + /// Return the persistent instance of the given entity class with the given identifier, + /// obtaining the specified lock mode, assuming the instance exists. + /// </summary> + /// <param name="entityName">The entity-name of a persistent class</param> + /// <param name="id">a valid identifier of an existing persistent instance of the class </param> + /// <param name="lockMode">the lock level </param> + /// <returns> the persistent instance or proxy </returns> + object Load(string entityName, object id, LockMode lockMode); + /// <summary> /// Return the persistent instance of the given entity class with the given identifier, /// assuming that the instance exists. @@ -252,6 +262,20 @@ /// <returns>The persistent instance or proxy</returns> T Load<T>(object id); + /// <summary> + /// Return the persistent instance of the given <paramref name="entityName"/> with the given identifier, + /// assuming that the instance exists. + /// </summary> + /// <param name="entityName">The entity-name of a persistent class</param> + /// <param name="id">a valid identifier of an existing persistent instance of the class </param> + /// <returns> The persistent instance or proxy </returns> + /// <remarks> + /// You should not use this method to determine if an instance exists (use <see cref="Get(string,object)"/> + /// instead). Use this only to retrieve an instance that you assume exists, where non-existence + /// would be an actual error. + /// </remarks> + object Load(string entityName, object id); + /// <summary> /// Read the persistent state associated with the given identifier into the given transient /// instance. Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2008-10-19 20:25:16 UTC (rev 3866) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2008-10-19 21:16:44 UTC (rev 3867) @@ -47,7 +47,7 @@ private readonly IInterceptor interceptor; - [NonSerialized] private readonly EntityMode entityMode = NHibernate.EntityMode.Poco; + [NonSerialized] private readonly EntityMode entityMode = EntityMode.Poco; [NonSerialized] private readonly EventListeners listeners; @@ -58,7 +58,7 @@ private readonly ConnectionManager connectionManager; [NonSerialized] - private int dontFlushFromFind = 0; + private int dontFlushFromFind; [NonSerialized] private readonly IDictionary<string, IFilter> enabledFilters = new Dictionary<string, IFilter>(); @@ -541,7 +541,7 @@ public IEnumerable Enumerable(string query, object value, IType type) { - return Enumerable(query, new object[] { value }, new IType[] { type }); + return Enumerable(query, new[] { value }, new[] { type }); } public IEnumerable Enumerable(string query, object[] values, IType[] types) @@ -594,7 +594,7 @@ public int Delete(string query, object value, IType type) { - return Delete(query, new object[] { value }, new IType[] { type }); + return Delete(query, new[] { value }, new[] { type }); } public int Delete(string query, object[] values, IType[] types) @@ -937,28 +937,61 @@ return autoFlushEvent.FlushRequired; } + #region load()/get() operations + public void Load(object obj, object id) { LoadEvent loadEvent = new LoadEvent(id, obj, this); FireLoad(loadEvent, LoadEventListener.Reload); } - public object Load(System.Type clazz, object id) + public T Load<T>(object id) { + return (T)Load(typeof(T), id); + } + + public T Load<T>(object id, LockMode lockMode) + { + return (T)Load(typeof(T), id, lockMode); + } + + /// <summary> + /// Load the data for the object with the specified id into a newly created object + /// using "for update", if supported. A new key will be assigned to the object. + /// This should return an existing proxy where appropriate. + /// + /// If the object does not exist in the database, an exception is thrown. + /// </summary> + /// <param name="entityClass"></param> + /// <param name="id"></param> + /// <param name="lockMode"></param> + /// <returns></returns> + /// <exception cref="ObjectNotFoundException"> + /// Thrown when the object with the specified id does not exist in the database. + /// </exception> + public object Load(System.Type entityClass, object id, LockMode lockMode) + { + return Load(entityClass.FullName, id, lockMode); + } + + public object Load(string entityName, object id) + { if (id == null) { throw new ArgumentNullException("id", "null is not a valid identifier"); } - LoadEvent loadEvent = new LoadEvent(id, clazz.FullName, false, this); + + var @event = new LoadEvent(id, entityName, false, this); bool success = false; try { - FireLoad(loadEvent, LoadEventListener.Load); - if (loadEvent.Result == null) - Factory.EntityNotFoundDelegate.HandleEntityNotFound(clazz.FullName, id); - + FireLoad(@event, LoadEventListener.Load); + if (@event.Result == null) + { + Factory.EntityNotFoundDelegate.HandleEntityNotFound(entityName, id); + } success = true; - return loadEvent.Result; + return @event.Result; } finally { @@ -966,14 +999,16 @@ } } - public T Load<T>(object id) + public object Load(string entityName, object id, LockMode lockMode) { - return (T)Load(typeof(T), id); + var @event = new LoadEvent(id, entityName, lockMode, this); + FireLoad(@event, LoadEventListener.Load); + return @event.Result; } - public T Load<T>(object id, LockMode lockMode) + public object Load(System.Type entityClass, object id) { - return (T)Load(typeof(T), id, lockMode); + return Load(entityClass.FullName, id); } public T Get<T>(object id) @@ -986,6 +1021,29 @@ return (T)Get(typeof(T), id, lockMode); } + public object Get(System.Type entityClass, object id) + { + return Get(entityClass.FullName, id); + } + + /// <summary> + /// Load the data for the object with the specified id into a newly created object + /// using "for update", if supported. A new key will be assigned to the object. + /// This should return an existing proxy where appropriate. + /// + /// If the object does not exist in the database, null is returned. + /// </summary> + /// <param name="clazz"></param> + /// <param name="id"></param> + /// <param name="lockMode"></param> + /// <returns></returns> + public object Get(System.Type clazz, object id, LockMode lockMode) + { + LoadEvent loadEvent = new LoadEvent(id, clazz.FullName, lockMode, this); + FireLoad(loadEvent, LoadEventListener.Get); + return loadEvent.Result; + } + public string GetEntityName(object obj) { CheckAndUpdateSessionStatus(); @@ -1011,11 +1069,6 @@ return entry.Persister.EntityName; } - public object Get(System.Type entityClass, object id) - { - return Get(entityClass.FullName, id); - } - public object Get(string entityName, object id) { LoadEvent loadEvent = new LoadEvent(id, entityName, false, this); @@ -1068,45 +1121,8 @@ return loadEvent.Result; } - /// <summary> - /// Load the data for the object with the specified id into a newly created object - /// using "for update", if supported. A new key will be assigned to the object. - /// This should return an existing proxy where appropriate. - /// - /// If the object does not exist in the database, an exception is thrown. - /// </summary> - /// <param name="clazz"></param> - /// <param name="id"></param> - /// <param name="lockMode"></param> - /// <returns></returns> - /// <exception cref="ObjectNotFoundException"> - /// Thrown when the object with the specified id does not exist in the database. - /// </exception> - public object Load(System.Type clazz, object id, LockMode lockMode) - { - LoadEvent loadEvent = new LoadEvent(id, clazz.FullName, lockMode, this); - FireLoad(loadEvent, LoadEventListener.Load); - return loadEvent.Result; - } + #endregion - /// <summary> - /// Load the data for the object with the specified id into a newly created object - /// using "for update", if supported. A new key will be assigned to the object. - /// This should return an existing proxy where appropriate. - /// - /// If the object does not exist in the database, null is returned. - /// </summary> - /// <param name="clazz"></param> - /// <param name="id"></param> - /// <param name="lockMode"></param> - /// <returns></returns> - public object Get(System.Type clazz, object id, LockMode lockMode) - { - LoadEvent loadEvent = new LoadEvent(id, clazz.FullName, lockMode, this); - FireLoad(loadEvent, LoadEventListener.Get); - return loadEvent.Result; - } - public void Refresh(object obj) { FireRefresh(new RefreshEvent(obj, this)); @@ -1616,7 +1632,7 @@ public IQuery CreateSQLQuery(string sql, string returnAlias, System.Type returnClass) { CheckAndUpdateSessionStatus(); - return new SqlQueryImpl(sql, new string[] { returnAlias }, new System.Type[] { returnClass }, this, Factory.QueryPlanCache.GetSQLParameterMetadata(sql)); + return new SqlQueryImpl(sql, new[] { returnAlias }, new[] { returnClass }, this, Factory.QueryPlanCache.GetSQLParameterMetadata(sql)); } public IQuery CreateSQLQuery(string sql, string[] returnAliases, System.Type[] returnClasses) @@ -1798,7 +1814,7 @@ } string filterName = filterParameterName.Substring(0, dot); string parameterName = filterParameterName.Substring(dot + 1); - return new string[] { filterName, parameterName }; + return new[] { filterName, parameterName }; } public override ConnectionManager ConnectionManager This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-19 20:25:26
|
Revision: 3866 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3866&view=rev Author: fabiomaulo Date: 2008-10-19 20:25:16 +0000 (Sun, 19 Oct 2008) Log Message: ----------- Test for NH-662 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Domain.cs 2008-10-19 20:25:16 UTC (rev 3866) @@ -0,0 +1,20 @@ +namespace NHibernate.Test.NHSpecificTest.NH662 +{ + public class Base + { + public virtual int Id { get; set; } + public virtual string Description { get; set; } + protected virtual void Foo() + { + // Some logic. + } + } + + public class Derived : Base + { + protected override void Foo() + { + // Some other logic + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Domain.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Fixture.cs 2008-10-19 20:25:16 UTC (rev 3866) @@ -0,0 +1,38 @@ +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; + +namespace NHibernate.Test.NHSpecificTest.NH662 +{ + [TestFixture, Ignore("Not supported.")] + public class Fixture: BugTestCase + { + [Test] + public void UseDerivedClass() + { + object savedId; + var d = new Derived {Description = "something"}; + + using (ISession s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + savedId = s.Save(d); + tx.Commit(); + } + + using (ISession s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + d = s.Load<Derived>(savedId); + Assert.That(d.Description, Is.EqualTo("something")); + tx.Commit(); + } + + using (ISession s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.Delete(d); + tx.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH662/Mappings.hbm.xml 2008-10-19 20:25:16 UTC (rev 3866) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH662"> + + <class name="Base"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Description"/> + </class> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-18 22:18:15 UTC (rev 3865) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-19 20:25:16 UTC (rev 3866) @@ -523,6 +523,8 @@ <Compile Include="NHSpecificTest\NH1080\Domain.cs" /> <Compile Include="NHSpecificTest\NH1080\Fixture.cs" /> <Compile Include="NHSpecificTest\NH364\Invoice.cs" /> + <Compile Include="NHSpecificTest\NH662\Domain.cs" /> + <Compile Include="NHSpecificTest\NH662\Fixture.cs" /> <Compile Include="NHSpecificTest\NH693\Fixture.cs" /> <Compile Include="NHSpecificTest\NH693\Something.cs" /> <Compile Include="NHSpecificTest\NH883\Cat.cs" /> @@ -1505,6 +1507,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH662\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1495\Mappings.hbm.xml" /> <EmbeddedResource Include="ProjectionFixtures\Mapping.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1033\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-18 22:18:25
|
Revision: 3865 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3865&view=rev Author: fabiomaulo Date: 2008-10-18 22:18:15 +0000 (Sat, 18 Oct 2008) Log Message: ----------- - Fix NH-1495 and NH-1083 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Person.cs Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs 2008-10-18 04:06:39 UTC (rev 3864) +++ trunk/nhibernate/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs 2008-10-18 22:18:15 UTC (rev 3865) @@ -71,20 +71,7 @@ if (entityMetamodel.IsLazy) { - /* NH Different implementation - * When we are using an interface we need to use the interface itself to have - * the getter and setter of the identifier to prevent proxy initialization. - * The BasicLazyInitializer use method.Equals to recognize the the identifier setter. - */ - IGetter pidGetter = idGetter; - ISetter pidSetter = idSetter; - if (mappingInfo.HasIdentifierProperty && mappingInfo.ProxyInterface != null) - { - pidGetter = mappingInfo.IdentifierProperty.GetGetter(mappingInfo.ProxyInterface); - pidSetter = mappingInfo.IdentifierProperty.GetSetter(mappingInfo.ProxyInterface); - } - proxyFactory = BuildProxyFactory(mappingInfo, pidGetter, pidSetter); - /*******************************************************************************/ + proxyFactory = BuildProxyFactory(mappingInfo, idGetter, idSetter); if (proxyFactory == null) { entityMetamodel.IsLazy = false; Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2008-10-18 04:06:39 UTC (rev 3864) +++ trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2008-10-18 22:18:15 UTC (rev 3865) @@ -10,6 +10,7 @@ using NHibernate.Properties; using NHibernate.Proxy; using NHibernate.Type; +using NHibernate.Util; namespace NHibernate.Tuple.Entity { @@ -144,13 +145,11 @@ MethodInfo idGetterMethod = idGetter == null ? null : idGetter.Method; MethodInfo idSetterMethod = idSetter == null ? null : idSetter.Method; - MethodInfo proxyGetIdentifierMethod = idGetterMethod == null || _proxyInterface == null ? null : - idGetterMethod; - // TODO H3.2 different behaviour ReflectHelper.GetMethod(_proxyInterface, idGetterMethod); + MethodInfo proxyGetIdentifierMethod = idGetterMethod == null || _proxyInterface == null ? null : + ReflectHelper.TryGetMethod(_proxyInterface, idGetterMethod); - MethodInfo proxySetIdentifierMethod = idSetterMethod == null || _proxyInterface == null ? null : - idSetterMethod; - // TODO H3.2 different behaviour ReflectHelper.GetMethod(_proxyInterface, idSetterMethod); + MethodInfo proxySetIdentifierMethod = idSetterMethod == null || _proxyInterface == null ? null : + ReflectHelper.TryGetMethod(_proxyInterface, idSetterMethod); IProxyFactory pf = BuildProxyFactoryInternal(persistentClass, idGetter, idSetter); try Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2008-10-18 04:06:39 UTC (rev 3864) +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2008-10-18 22:18:15 UTC (rev 3865) @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Reflection; using System.Text; using log4net; @@ -12,6 +13,9 @@ /// </summary> public sealed class ReflectHelper { + private const BindingFlags defaultBindingFlags = + BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; + private static readonly ILog log = LogManager.GetLogger(typeof(ReflectHelper)); public static BindingFlags AnyVisibilityInstance = BindingFlags.Instance | BindingFlags.Public | @@ -445,5 +449,89 @@ Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] {}); return ex.InnerException; } + + /// <summary> + /// Try to find a method in a given type. + /// </summary> + /// <param name="type">The given type.</param> + /// <param name="method">The method info.</param> + /// <returns>The found method or null.</returns> + /// <remarks> + /// The <paramref name="method"/>, in general, become from another <see cref="Type"/>. + /// </remarks> + public static MethodInfo TryGetMethod(System.Type type, MethodInfo method) + { + if (type == null) + { + throw new ArgumentNullException("type"); + } + + if (method == null) + { + return null; + } + + System.Type[] tps = GetMethodSignature(method); + try + { + return type.GetMethod(method.Name, defaultBindingFlags, null, tps, null); + } + catch (Exception) + { + return null; + } + } + + /// <summary> + /// Try to find a method in a serie of given types. + /// </summary> + /// <param name="types">The serie of types where find.</param> + /// <param name="method">The method info.</param> + /// <returns>The found method or null.</returns> + /// <remarks> + /// The <paramref name="method"/>, in general, become from another <see cref="Type"/>. + /// </remarks> + public static MethodInfo TryGetMethod(IEnumerable<System.Type> types, MethodInfo method) + { + // This method will be used when we support multiple proxy interfaces. + if (types == null) + { + throw new ArgumentNullException("types"); + } + if (method == null) + { + return null; + } + + System.Type[] tps = GetMethodSignature(method); + MethodInfo result = null; + foreach (var type in types) + { + try + { + result = type.GetMethod(method.Name, defaultBindingFlags, null, tps, null); + if (result != null) + { + return result; + } + } + catch (Exception) + { + return null; + } + } + return result; + } + + private static System.Type[] GetMethodSignature(MethodInfo method) + { + var pi = method.GetParameters(); + var tps = new System.Type[pi.Length]; + for (int i = 0; i < pi.Length; i++) + { + tps[i] = pi[i].ParameterType; + } + return tps; + } } } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Fixture.cs 2008-10-18 22:18:15 UTC (rev 3865) @@ -0,0 +1,42 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1495 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void CreateTest() + { + object id; + + using (ISession session = OpenSession()) + { + var person = new Person {Name = "Nelo"}; + + using (ITransaction trans = session.BeginTransaction()) + { + session.Save(person); + trans.Commit(); + } + + id = person.Id; + } + + using (ISession session = OpenSession()) + { + var person = (IPerson)session.Load(typeof(Person), id); //to work with the proxy + + Assert.IsNotNull(person); + Assert.AreEqual("Nelo", person.Name); + + using (ITransaction trans = session.BeginTransaction()) + { + session.Delete(person); + trans.Commit(); + } + } + } + + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Mappings.hbm.xml 2008-10-18 22:18:15 UTC (rev 3865) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1495"> + + <class name="Person" proxy="IPerson"> + <id name="Id" type="Int64" access="backfield"> + <generator class="hilo" /> + </id> + <property name="Name" /> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1495/Person.cs 2008-10-18 22:18:15 UTC (rev 3865) @@ -0,0 +1,15 @@ +namespace NHibernate.Test.NHSpecificTest.NH1495 +{ + public interface IPerson + { + object Id { get;} + string Name { get; set; } + } + + public class Person : IPerson + { + public object Id { get; private set; } + + public string Name { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-18 04:06:39 UTC (rev 3864) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-18 22:18:15 UTC (rev 3865) @@ -502,6 +502,8 @@ <Compile Include="NHSpecificTest\NH1492\ChildEntity.cs" /> <Compile Include="NHSpecificTest\NH1492\Entity.cs" /> <Compile Include="NHSpecificTest\NH1492\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1495\Person.cs" /> + <Compile Include="NHSpecificTest\NH1495\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1499\Document.cs" /> <Compile Include="NHSpecificTest\NH1499\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1499\Person.cs" /> @@ -1503,6 +1505,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1495\Mappings.hbm.xml" /> <EmbeddedResource Include="ProjectionFixtures\Mapping.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1033\Mappings.hbm.xml" /> <EmbeddedResource Include="EntityModeTest\Multi\Stock.hbm.xml" /> Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2008-10-18 04:06:39 UTC (rev 3864) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2008-10-18 22:18:15 UTC (rev 3865) @@ -1,7 +1,9 @@ using System; +using System.Reflection; using NHibernate.DomainModel; using NHibernate.Util; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; namespace NHibernate.Test.UtilityTest { @@ -50,6 +52,33 @@ System.Type int32 = ReflectHelper.ClassForName("System.Int32"); Assert.AreEqual(typeof(Int32), int32); } + + [Test] + public void TryGetMethod() + { + const BindingFlags bf = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; + MethodInfo mig = typeof (MyBaseImplementation).GetMethod("get_Id", bf); + MethodInfo mis = typeof(MyBaseImplementation).GetMethod("set_Id", bf); + MethodInfo mng = typeof(MyBaseImplementation).GetMethod("get_Name", bf); + MethodInfo mns = typeof(MyBaseImplementation).GetMethod("set_Name", bf); + Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mig), Is.Not.Null); + Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mis), Is.Null); + Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mng), Is.Not.Null); + Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mns), Is.Not.Null); + + mig = typeof(MyImplementation).GetMethod("get_Id", bf); + mis = typeof(MyImplementation).GetMethod("set_Id", bf); + mng = typeof(MyImplementation).GetMethod("get_Name", bf); + mns = typeof(MyImplementation).GetMethod("set_Name", bf); + MethodInfo mdg = typeof(MyImplementation).GetMethod("get_Description", bf); + MethodInfo mds = typeof(MyImplementation).GetMethod("set_Description", bf); + Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mig), Is.Not.Null); + Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mis), Is.Null); + Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mng), Is.Not.Null); + Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mns), Is.Not.Null); + Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mdg), Is.Not.Null); + Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mds), Is.Null); + } } public class ARhf @@ -68,4 +97,29 @@ public class BRhf : ARhf { } + + public interface IMyBaseInterface + { + int Id { get; } + string Name { get; set; } + } + + public interface IMyInterface: IMyBaseInterface + { + string Description { get; } + } + + public class MyBaseImplementation : IMyBaseInterface + { + public int Id { get; set; } + public string Name { get; set; } + } + + public class MyImplementation: IMyInterface + { + public int Id{ get; set; } + public string Name { get; set; } + public string Description { 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. |
From: <fab...@us...> - 2008-10-18 04:06:42
|
Revision: 3864 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3864&view=rev Author: fabiomaulo Date: 2008-10-18 04:06:39 +0000 (Sat, 18 Oct 2008) Log Message: ----------- Fix NH-1532 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs Modified: trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs 2008-10-17 18:05:25 UTC (rev 3863) +++ trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs 2008-10-18 04:06:39 UTC (rev 3864) @@ -177,7 +177,7 @@ private bool IsSystemType(string tyname) { - return tyname.StartsWith("System"); // ugly + return tyname.StartsWith("System."); // ugly } public static AssemblyQualifiedTypeName Parse(string text) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-17 18:05:28
|
Revision: 3863 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3863&view=rev Author: fabiomaulo Date: 2008-10-17 18:05:25 +0000 (Fri, 17 Oct 2008) Log Message: ----------- Minor Modified Paths: -------------- trunk/nhibernate/src/NHibernate/EmptyInterceptor.cs Modified: trunk/nhibernate/src/NHibernate/EmptyInterceptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/EmptyInterceptor.cs 2008-10-16 03:32:17 UTC (rev 3862) +++ trunk/nhibernate/src/NHibernate/EmptyInterceptor.cs 2008-10-17 18:05:25 UTC (rev 3863) @@ -12,15 +12,15 @@ { } - public void OnCollectionRecreate(object collection, object key) + public virtual void OnCollectionRecreate(object collection, object key) { } - public void OnCollectionRemove(object collection, object key) + public virtual void OnCollectionRemove(object collection, object key) { } - public void OnCollectionUpdate(object collection, object key) + public virtual void OnCollectionUpdate(object collection, object key) { } @@ -63,7 +63,7 @@ return null; } - public object GetEntity(string entityName, object id) + public virtual object GetEntity(string entityName, object id) { return null; } @@ -90,7 +90,7 @@ { } - public SqlString OnPrepareStatement(SqlString sql) + public virtual SqlString OnPrepareStatement(SqlString sql) { return sql; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-16 03:32:27
|
Revision: 3862 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3862&view=rev Author: fabiomaulo Date: 2008-10-16 03:32:17 +0000 (Thu, 16 Oct 2008) Log Message: ----------- - Generic entities support trough entity-name - Improve of TypeNameParser Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Util/SessionFactoryHelper.cs trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/A.cs trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/Fixture.cs trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Util/SessionFactoryHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Util/SessionFactoryHelper.cs 2008-10-15 21:43:03 UTC (rev 3861) +++ trunk/nhibernate/src/NHibernate/Hql/Util/SessionFactoryHelper.cs 2008-10-16 03:32:17 UTC (rev 3862) @@ -11,6 +11,14 @@ { public static IQueryable FindQueryableUsingImports(ISessionFactoryImplementor sfi, string className) { + // NH : this method prevent unrecognized class when entityName != class.FullName + // this is a patch for the TODO below + var possibleResult = sfi.TryGetEntityPersister(GetEntityName(className)) as IQueryable; + if(possibleResult != null) + { + return possibleResult; + } + string importedClassName = sfi.GetImportedClassName(className); if (importedClassName == null) Modified: trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs 2008-10-15 21:43:03 UTC (rev 3861) +++ trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs 2008-10-16 03:32:17 UTC (rev 3862) @@ -7,10 +7,7 @@ { public class ParserException : ApplicationException { - public ParserException(string message) - : base(message) - { - } + public ParserException(string message) : base(message) {} } public class TypeNameParser @@ -27,7 +24,7 @@ private char[] Characters(int count) { - char[] chars = new char[count]; + var chars = new char[count]; if (input.ReadBlock(chars, 0, count) < count) { throw new ParserException(count + " characters expected"); @@ -50,13 +47,13 @@ private string AssemblyName() { - StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); SkipSpaces(); int code; while ((code = input.Peek()) != -1) { - char ch = (char) code; + var ch = (char) code; if (ch == ']') { @@ -69,27 +66,47 @@ return result.ToString(); } - private string BracketedPart() + private string BracketedPart(string defaultNamespace, string defaultAssembly) { Debug.Assert(input.Peek() == '['); - StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); + var genericTypeName = new StringBuilder(200); int depth = 0; do { - if (input.Peek() == '[') + int c = input.Peek(); + if (c == '[') { depth++; + result.Append(PossiblyEscapedCharacter()); } - else if (input.Peek() == ']') + else if (c == ']') { depth--; + if (genericTypeName.Length > 0) + { + var r = Parse(genericTypeName.ToString(), defaultNamespace, defaultAssembly); + result.Append(r.ToString()); + genericTypeName.Remove(0, genericTypeName.Length); + } + result.Append(PossiblyEscapedCharacter()); } + else if (c == ',' || c == ' ') + { + if (genericTypeName.Length > 0) + genericTypeName.Append(PossiblyEscapedCharacter()); + else + result.Append(PossiblyEscapedCharacter()); + } + else + { + genericTypeName.Append(PossiblyEscapedCharacter()); + } + } + while (depth > 0 && input.Peek() != -1); - result.Append(PossiblyEscapedCharacter()); - } while (depth > 0 && input.Peek() != -1); - if (depth > 0 && input.Peek() == -1) { throw new ParserException("Unmatched left bracket ('[')"); @@ -101,51 +118,54 @@ public AssemblyQualifiedTypeName ParseTypeName(string text, string defaultNamespace, string defaultAssembly) { text = text.Trim(); - - StringBuilder type = new StringBuilder(text.Length); + if (IsSystemType(text)) + { + defaultNamespace = null; + defaultAssembly = null; + } + var type = new StringBuilder(text.Length); string assembly = StringHelper.IsEmpty(defaultAssembly) ? null : defaultAssembly; try { bool seenNamespace = false; - input = new StringReader(text); - - int code; - while ((code = input.Peek()) != -1) + using (input = new StringReader(text)) { - char ch = (char) code; - - if (ch == '.') + int code; + while ((code = input.Peek()) != -1) { - seenNamespace = true; - } + var ch = (char) code; - if (ch == ',') - { - input.Read(); - assembly = AssemblyName(); - if (input.Peek() != -1) + if (ch == '.') { - throw new ParserException("Extra characters found at the end of the type name"); + seenNamespace = true; } + + if (ch == ',') + { + input.Read(); + assembly = AssemblyName(); + if (input.Peek() != -1) + { + throw new ParserException("Extra characters found at the end of the type name"); + } + } + else if (ch == '[') + { + type.Append(BracketedPart(defaultNamespace, defaultAssembly)); + } + else + { + type.Append(PossiblyEscapedCharacter()); + } } - else if (ch == '[') - { - type.Append(BracketedPart()); - } - else - { - type.Append(PossiblyEscapedCharacter()); - } + + input.Close(); } - - input.Close(); - if (!seenNamespace && StringHelper.IsNotEmpty(defaultNamespace)) { - type.Insert(0, '.') - .Insert(0, defaultNamespace); + type.Insert(0, '.').Insert(0, defaultNamespace); } return new AssemblyQualifiedTypeName(type.ToString(), assembly); } @@ -155,6 +175,11 @@ } } + private bool IsSystemType(string tyname) + { + return tyname.StartsWith("System"); // ugly + } + public static AssemblyQualifiedTypeName Parse(string text) { return Parse(text, null, null); Modified: trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/A.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/A.cs 2008-10-15 21:43:03 UTC (rev 3861) +++ trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/A.cs 2008-10-16 03:32:17 UTC (rev 3862) @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace NHibernate.Test.GenericTest.Overall @@ -9,26 +8,10 @@ /// </summary> public class A<T> { - private int? id; - private IList<T> collection; - private T property; + public virtual int? Id { get; set; } - public virtual int? Id - { - get { return id; } - set { id = value; } - } + public virtual T Property { get; set; } - public virtual T Property - { - get { return property; } - set { property = value; } - } - - public virtual IList<T> Collection - { - get { return collection; } - set { collection = value; } - } + public virtual IList<T> Collection { get; set; } } } Modified: trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/Fixture.cs 2008-10-15 21:43:03 UTC (rev 3861) +++ trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/Fixture.cs 2008-10-16 03:32:17 UTC (rev 3862) @@ -1,4 +1,3 @@ -using System; using System.Collections; using System.Collections.Generic; @@ -7,12 +6,11 @@ namespace NHibernate.Test.GenericTest.Overall { [TestFixture] - [Ignore( "Generic entities not supported" )] public class Fixture : TestCase { protected override IList Mappings { - get { return new string[] { "GenericTest.Overall.Mappings.hbm.xml" }; } + get { return new[] { "GenericTest.Overall.Mappings.hbm.xml" }; } } protected override string MappingsAssembly @@ -23,22 +21,19 @@ [Test] public void CRUD() { - A<int> entity = new A<int>(); - entity.Property = 10; - entity.Collection = new List<int>(); - entity.Collection.Add( 20 ); + var entity = new A<int> {Property = 10, Collection = new List<int> {20}}; using( ISession session = OpenSession() ) using( ITransaction transaction = session.BeginTransaction() ) { - session.Save( entity ); + session.Save("AInt", entity); transaction.Commit(); } using( ISession session = OpenSession() ) using( ITransaction transaction = session.BeginTransaction() ) { - session.Delete( entity ); + session.Delete("AInt", entity); transaction.Commit(); } } Modified: trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/Mappings.hbm.xml 2008-10-15 21:43:03 UTC (rev 3861) +++ trunk/nhibernate/src/NHibernate.Test/GenericTest/Overall/Mappings.hbm.xml 2008-10-16 03:32:17 UTC (rev 3862) @@ -4,7 +4,7 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.GenericTest.Overall"> - <class name="A`1[System.Int32]" table="A"> + <class name="A`1[System.Int32]" table="AInt" entity-name="AInt"> <id name="Id"> <generator class="native" /> Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs 2008-10-15 21:43:03 UTC (rev 3861) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs 2008-10-16 03:32:17 UTC (rev 3862) @@ -127,5 +127,74 @@ { TypeNameParser.Parse("\\"); } + + [Test] + public void ParseGenericTypeNameWithDefaults() + { + string fullSpec = "TName`1[PartialName]"; + string defaultassembly = "SomeAssembly"; + string defaultNamespace = "SomeAssembly.MyNS"; + string expectedType = "SomeAssembly.MyNS.TName`1[SomeAssembly.MyNS.PartialName, SomeAssembly]"; + string expectedAssembly = "SomeAssembly"; + + AssemblyQualifiedTypeName tn = TypeNameParser.Parse(fullSpec, defaultNamespace, defaultassembly); + Assert.AreEqual(expectedType, tn.Type, "Type name should match"); + Assert.AreEqual(expectedAssembly, tn.Assembly, "Assembly name should match"); + + fullSpec = "TName`1[[PartialName]]"; + defaultassembly = "SomeAssembly"; + defaultNamespace = "SomeAssembly.MyNS"; + expectedType = "SomeAssembly.MyNS.TName`1[[SomeAssembly.MyNS.PartialName, SomeAssembly]]"; + expectedAssembly = "SomeAssembly"; + + tn = TypeNameParser.Parse(fullSpec, defaultNamespace, defaultassembly); + Assert.AreEqual(expectedType, tn.Type, "Type name should match"); + Assert.AreEqual(expectedAssembly, tn.Assembly, "Assembly name should match"); + + fullSpec = "TName`2[[PartialName],[OtherPartialName]]"; + defaultassembly = "SomeAssembly"; + defaultNamespace = "SomeAssembly.MyNS"; + expectedType = "SomeAssembly.MyNS.TName`2[[SomeAssembly.MyNS.PartialName, SomeAssembly],[SomeAssembly.MyNS.OtherPartialName, SomeAssembly]]"; + expectedAssembly = "SomeAssembly"; + tn = TypeNameParser.Parse(fullSpec, defaultNamespace, defaultassembly); + Assert.AreEqual(expectedType, tn.Type, "Type name should match"); + Assert.AreEqual(expectedAssembly, tn.Assembly, "Assembly name should match"); + } + + [Test] + public void ParseGenericTypeNameWithDefaultNamespaceUnused() + { + string fullSpec = "TName`1[SomeAssembly.MyOtherNS.PartialName]"; + string defaultassembly = "SomeAssembly"; + string defaultNamespace = "SomeAssembly.MyNS"; + string expectedType = "SomeAssembly.MyNS.TName`1[SomeAssembly.MyOtherNS.PartialName, SomeAssembly]"; + string expectedAssembly = "SomeAssembly"; + + AssemblyQualifiedTypeName tn = TypeNameParser.Parse(fullSpec, defaultNamespace, defaultassembly); + Assert.AreEqual(expectedType, tn.Type, "Type name should match"); + Assert.AreEqual(expectedAssembly, tn.Assembly, "Assembly name should match"); + + fullSpec = "SomeType`1[System.Int32]"; + defaultassembly = "SomeAssembly"; + defaultNamespace = null; + expectedType = "SomeType`1[System.Int32]"; + expectedAssembly = "SomeAssembly"; + + tn = TypeNameParser.Parse(fullSpec, defaultNamespace, defaultassembly); + Assert.AreEqual(expectedType, tn.Type, "Type name should match"); + Assert.AreEqual(expectedAssembly, tn.Assembly, "Assembly name should match"); + + fullSpec = typeof(MyGClass<int>).AssemblyQualifiedName; + defaultassembly = "SomeAssembly"; + defaultNamespace = "SomeAssembly.MyNS"; + expectedType = typeof(MyGClass<int>).AssemblyQualifiedName; + tn = TypeNameParser.Parse(fullSpec, defaultNamespace, defaultassembly); + Assert.AreEqual(expectedType, tn.Type + ", " + tn.Assembly, "Type name should match"); + } + + public class MyGClass<T> + { + + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: T. T. <te...@gm...> - 2008-10-15 22:24:51
|
I think this commit will resolve several other issues related to paging such as http://jira.nhibernate.org/browse/NH-1424 i need some free time to check those, maybe on friday. On Wed, Oct 15, 2008 at 9:32 PM, <aye...@us...> wrote: > Revision: 3860 > > http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3860&view=rev > Author: ayenderahien > Date: 2008-10-15 18:32:16 +0000 (Wed, 15 Oct 2008) > > Log Message: > ----------- > NH-1528 - fixing problem with limit clauses with order by clauses that has > parameters on sql 2005. > > Modified Paths: > -------------- > trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs > trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs > trunk/nhibernate/src/NHibernate/Loader/Loader.cs > trunk/nhibernate/src/NHibernate/SqlCommand/ISqlStringVisitor.cs > trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs > trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs > trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs > trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs > trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml > trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs > > Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2008-10-15 > 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2008-10-15 > 18:32:16 UTC (rev 3860) > @@ -44,6 +44,20 @@ > /// </remarks> > public override SqlString GetLimitString(SqlString > querySqlString, int offset, int last) > { > + // we have to do this in order to support parameters in order > clause, the foramt > + // that sql 2005 uses for paging means that we move the > parameters around, which means, > + // that positions are lost, so we record them before making > any changes. > + // NH-1528 > + int parameterPositon = 0; > + foreach (var part in querySqlString.Parts) > + { > + Parameter param = part as Parameter; > + if (param == null) > + continue; > + param.OriginalPositionInQuery = parameterPositon; > + parameterPositon += 1; > + } > + > int fromIndex = GetFromIndex(querySqlString); > SqlString select = querySqlString.Substring(0, > fromIndex); > List<SqlString> columnsOrAliases; > > Modified: trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs > 2008-10-15 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs > 2008-10-15 18:32:16 UTC (rev 3860) > @@ -35,9 +35,10 @@ > result.Append(sqlString.ToString()); > } > > - void ISqlStringVisitor.Parameter() > + void ISqlStringVisitor.Parameter(Parameter parameter) > { > - string name = > formatter.GetParameterName(parameterIndex); > + string name = formatter.GetParameterName( > + parameter.OriginalPositionInQuery ?? parameterIndex); > parameterIndex++; > result.Append(name); > } > > Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-15 16:59:19 > UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-15 18:32:16 > UTC (rev 3860) > @@ -445,6 +445,11 @@ > log.Debug(string.Format("done > processing result set ({0} rows)", count)); > } > } > + catch(Exception e) > + { > + e.Data["actual-sql-query"] = st.CommandText; > + throw; > + } > finally > { > session.Batcher.CloseCommand(st, rs); > > Modified: trunk/nhibernate/src/NHibernate/SqlCommand/ISqlStringVisitor.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/SqlCommand/ISqlStringVisitor.cs > 2008-10-15 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate/SqlCommand/ISqlStringVisitor.cs > 2008-10-15 18:32:16 UTC (rev 3860) > @@ -6,6 +6,6 @@ > { > void String(string text); > void String(SqlString sqlString); > - void Parameter(); > + void Parameter(Parameter parameter); > } > } > > Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs 2008-10-15 > 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs 2008-10-15 > 18:32:16 UTC (rev 3860) > @@ -10,11 +10,25 @@ > [Serializable] > public class Parameter > { > - /// <summary> > - /// Used as a placeholder when parsing HQL or SQL queries. > - /// </summary> > - public static readonly Parameter Placeholder = new > Parameter(); > + /// <summary> > + /// We need to know what the position of the parameter was in a > query > + /// before we rearranged the query. > + /// This is used only by dialects that rearrange the query, > unforantely, > + /// the MS SQL 2005 dialect have to re shuffle the query (and ruin > positional parameter > + /// support) because the SQL 2005 and 2008 SQL dialects have a > completely broken > + /// support for paging, which is just a tad less important than > SELECT. > + /// See NH-1528 > + /// </summary> > + public int? OriginalPositionInQuery; > > + /// <summary> > + /// Used as a placeholder when parsing HQL or SQL queries. > + /// </summary> > + public static Parameter Placeholder > + { > + get { return new Parameter(); } > + } > + > private Parameter() > { > } > @@ -44,8 +58,9 @@ > /// </returns> > public override bool Equals(object obj) > { > - // All parameters are equal > - return obj == this || obj is Parameter; > + // All parameters are equal, this check that > + // the other one is not null and a parameter > + return obj is Parameter; > } > > /// <summary> > @@ -64,5 +79,35 @@ > { > return StringHelper.SqlParameter; > } > + > + public static bool operator ==(Parameter a, Parameter b) > + { > + return Equals(a, b); > + } > + > + public static bool operator ==(object a, Parameter b) > + { > + return Equals(a, b); > + } > + > + public static bool operator ==(Parameter a, object b) > + { > + return Equals(a, b); > + } > + > + public static bool operator !=(Parameter a, object b) > + { > + return !(a == b); > + } > + > + public static bool operator !=(object a, Parameter b) > + { > + return !(a == b); > + } > + > + public static bool operator !=(Parameter a, Parameter b) > + { > + return !(a == b); > + } > } > } > > Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs 2008-10-15 > 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs 2008-10-15 > 18:32:16 UTC (rev 3860) > @@ -664,7 +664,7 @@ > } > else > { > - visitor.Parameter(); > + visitor.Parameter((Parameter)part); > } > } > } > > Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs > 2008-10-15 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs > 2008-10-15 18:32:16 UTC (rev 3860) > @@ -338,9 +338,9 @@ > parent.Add(sqlString); > } > > - public void Parameter() > + public void Parameter(Parameter parameter) > { > - parent.AddParameter(); > + parent.Add(parameter); > } > } > > > Modified: > trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs > 2008-10-15 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs > 2008-10-15 18:32:16 UTC (rev 3860) > @@ -140,5 +140,25 @@ > criteria.List(); > } > } > + > + [Test] > + public void QueryingWithParemetersAndParaemtersInOrderBy() > + { > + using (var s = OpenSession()) > + { > + ICriteria criteria = s.CreateCriteria(typeof(TreeNode), > "parent") > + .Add(Restrictions.Like("Name","ayende")) > + .Add(Restrictions.Gt("Key.Id", 0)); > + > + var currentAssessment = > DetachedCriteria.For<TreeNode>("child") > + .Add(Restrictions.Eq("Type", NodeType.Smart)) > + .SetProjection(Projections.Property("Type")); > + > + > criteria.AddOrder(Order.Asc(Projections.SubQuery(currentAssessment))) > + .SetMaxResults(1000); > + > + criteria.List(); > + } > + } > } > } > \ No newline at end of file > > Modified: > trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml > 2008-10-15 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml > 2008-10-15 18:32:16 UTC (rev 3860) > @@ -20,6 +20,7 @@ > <one-to-many class="TreeNode"/> > </set> > <property name="Type"/> > + <property name="Name"/> > </class> > > </hibernate-mapping> > \ No newline at end of file > > Modified: > trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs > 2008-10-15 16:59:19 UTC (rev 3859) > +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs > 2008-10-15 18:32:16 UTC (rev 3860) > @@ -5,6 +5,7 @@ > { > public class TreeNode > { > + public virtual string Name { get; set; } > public virtual Key Key { get; set; } > public virtual TreeNode Parent { get; set; } > public virtual NodeType Type { get; set; } > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > -- Tuna Toksöz Typos included to enhance the readers attention! |
From: <aye...@us...> - 2008-10-15 21:43:09
|
Revision: 3861 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3861&view=rev Author: ayenderahien Date: 2008-10-15 21:43:03 +0000 (Wed, 15 Oct 2008) Log Message: ----------- fixing spelling mistake in a comment Modified Paths: -------------- trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs 2008-10-15 18:32:16 UTC (rev 3860) +++ trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs 2008-10-15 21:43:03 UTC (rev 3861) @@ -13,7 +13,7 @@ /// <summary> /// We need to know what the position of the parameter was in a query /// before we rearranged the query. - /// This is used only by dialects that rearrange the query, unforantely, + /// This is used only by dialects that rearrange the query, unfortunately, /// the MS SQL 2005 dialect have to re shuffle the query (and ruin positional parameter /// support) because the SQL 2005 and 2008 SQL dialects have a completely broken /// support for paging, which is just a tad less important than SELECT. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2008-10-15 18:32:24
|
Revision: 3860 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3860&view=rev Author: ayenderahien Date: 2008-10-15 18:32:16 +0000 (Wed, 15 Oct 2008) Log Message: ----------- NH-1528 - fixing problem with limit clauses with order by clauses that has parameters on sql 2005. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/SqlCommand/ISqlStringVisitor.cs trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -44,6 +44,20 @@ /// </remarks> public override SqlString GetLimitString(SqlString querySqlString, int offset, int last) { + // we have to do this in order to support parameters in order clause, the foramt + // that sql 2005 uses for paging means that we move the parameters around, which means, + // that positions are lost, so we record them before making any changes. + // NH-1528 + int parameterPositon = 0; + foreach (var part in querySqlString.Parts) + { + Parameter param = part as Parameter; + if (param == null) + continue; + param.OriginalPositionInQuery = parameterPositon; + parameterPositon += 1; + } + int fromIndex = GetFromIndex(querySqlString); SqlString select = querySqlString.Substring(0, fromIndex); List<SqlString> columnsOrAliases; Modified: trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -35,9 +35,10 @@ result.Append(sqlString.ToString()); } - void ISqlStringVisitor.Parameter() + void ISqlStringVisitor.Parameter(Parameter parameter) { - string name = formatter.GetParameterName(parameterIndex); + string name = formatter.GetParameterName( + parameter.OriginalPositionInQuery ?? parameterIndex); parameterIndex++; result.Append(name); } Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -445,6 +445,11 @@ log.Debug(string.Format("done processing result set ({0} rows)", count)); } } + catch(Exception e) + { + e.Data["actual-sql-query"] = st.CommandText; + throw; + } finally { session.Batcher.CloseCommand(st, rs); Modified: trunk/nhibernate/src/NHibernate/SqlCommand/ISqlStringVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/ISqlStringVisitor.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate/SqlCommand/ISqlStringVisitor.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -6,6 +6,6 @@ { void String(string text); void String(SqlString sqlString); - void Parameter(); + void Parameter(Parameter parameter); } } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -10,11 +10,25 @@ [Serializable] public class Parameter { - /// <summary> - /// Used as a placeholder when parsing HQL or SQL queries. - /// </summary> - public static readonly Parameter Placeholder = new Parameter(); + /// <summary> + /// We need to know what the position of the parameter was in a query + /// before we rearranged the query. + /// This is used only by dialects that rearrange the query, unforantely, + /// the MS SQL 2005 dialect have to re shuffle the query (and ruin positional parameter + /// support) because the SQL 2005 and 2008 SQL dialects have a completely broken + /// support for paging, which is just a tad less important than SELECT. + /// See NH-1528 + /// </summary> + public int? OriginalPositionInQuery; + /// <summary> + /// Used as a placeholder when parsing HQL or SQL queries. + /// </summary> + public static Parameter Placeholder + { + get { return new Parameter(); } + } + private Parameter() { } @@ -44,8 +58,9 @@ /// </returns> public override bool Equals(object obj) { - // All parameters are equal - return obj == this || obj is Parameter; + // All parameters are equal, this check that + // the other one is not null and a parameter + return obj is Parameter; } /// <summary> @@ -64,5 +79,35 @@ { return StringHelper.SqlParameter; } + + public static bool operator ==(Parameter a, Parameter b) + { + return Equals(a, b); + } + + public static bool operator ==(object a, Parameter b) + { + return Equals(a, b); + } + + public static bool operator ==(Parameter a, object b) + { + return Equals(a, b); + } + + public static bool operator !=(Parameter a, object b) + { + return !(a == b); + } + + public static bool operator !=(object a, Parameter b) + { + return !(a == b); + } + + public static bool operator !=(Parameter a, Parameter b) + { + return !(a == b); + } } } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -664,7 +664,7 @@ } else { - visitor.Parameter(); + visitor.Parameter((Parameter)part); } } } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -338,9 +338,9 @@ parent.Add(sqlString); } - public void Parameter() + public void Parameter(Parameter parameter) { - parent.AddParameter(); + parent.Add(parameter); } } Modified: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -140,5 +140,25 @@ criteria.List(); } } + + [Test] + public void QueryingWithParemetersAndParaemtersInOrderBy() + { + using (var s = OpenSession()) + { + ICriteria criteria = s.CreateCriteria(typeof(TreeNode), "parent") + .Add(Restrictions.Like("Name","ayende")) + .Add(Restrictions.Gt("Key.Id", 0)); + + var currentAssessment = DetachedCriteria.For<TreeNode>("child") + .Add(Restrictions.Eq("Type", NodeType.Smart)) + .SetProjection(Projections.Property("Type")); + + criteria.AddOrder(Order.Asc(Projections.SubQuery(currentAssessment))) + .SetMaxResults(1000); + + criteria.List(); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml 2008-10-15 18:32:16 UTC (rev 3860) @@ -20,6 +20,7 @@ <one-to-many class="TreeNode"/> </set> <property name="Type"/> + <property name="Name"/> </class> </hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs 2008-10-15 16:59:19 UTC (rev 3859) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs 2008-10-15 18:32:16 UTC (rev 3860) @@ -5,6 +5,7 @@ { public class TreeNode { + public virtual string Name { get; set; } public virtual Key Key { get; set; } public virtual TreeNode Parent { get; set; } public virtual NodeType Type { get; set; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2008-10-15 17:01:59
|
Revision: 3859 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3859&view=rev Author: ayenderahien Date: 2008-10-15 16:59:19 +0000 (Wed, 15 Oct 2008) Log Message: ----------- Fixed NH-1527 - order by with parameters in conjunction with SetMaxResults on sql 2005. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2008-10-15 13:58:32 UTC (rev 3858) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2008-10-15 16:59:19 UTC (rev 3859) @@ -46,24 +46,24 @@ { int fromIndex = GetFromIndex(querySqlString); SqlString select = querySqlString.Substring(0, fromIndex); - List<string> columnsOrAliases; - Dictionary<string, string> aliasToColumn; + List<SqlString> columnsOrAliases; + Dictionary<SqlString, SqlString> aliasToColumn; ExtractColumnOrAliasNames(select, out columnsOrAliases, out aliasToColumn); int orderIndex = querySqlString.LastIndexOfCaseInsensitive(" order by "); SqlString from; - string[] sortExpressions; + SqlString[] sortExpressions; if (orderIndex > 0) { from = querySqlString.Substring(fromIndex, orderIndex - fromIndex).Trim(); - string orderBy = querySqlString.Substring(orderIndex).ToString().Trim(); - sortExpressions = orderBy.Substring(9).Split(','); + SqlString orderBy = querySqlString.Substring(orderIndex).Trim(); + sortExpressions = orderBy.Substring(9).Split(","); } else { from = querySqlString.Substring(fromIndex).Trim(); // Use dummy sort to avoid errors - sortExpressions = new string[] { "CURRENT_TIMESTAMP" }; + sortExpressions = new SqlString[] { new SqlString("CURRENT_TIMESTAMP"), }; } SqlStringBuilder result = @@ -85,7 +85,7 @@ } for (int i = 0; i < sortExpressions.Length; i++) { - string sortExpression = RemoveSortOrderDirection(sortExpressions[i]); + SqlString sortExpression = RemoveSortOrderDirection(sortExpressions[i]); if (!columnsOrAliases.Contains(sortExpression)) { result.Add(", query.__hibernate_sort_expr_").Add(i.ToString()).Add("__"); @@ -96,7 +96,7 @@ for (int i = 0; i < sortExpressions.Length; i++) { - string sortExpression = RemoveSortOrderDirection(sortExpressions[i]); + SqlString sortExpression = RemoveSortOrderDirection(sortExpressions[i]); if (columnsOrAliases.Contains(sortExpression)) { @@ -118,13 +118,16 @@ return result.ToSqlString(); } - private static string RemoveSortOrderDirection(string sortExpression) + private static SqlString RemoveSortOrderDirection(SqlString sortExpression) { - // Drop the ASC/DESC at the end of the sort expression which might look like "count(distinct frog.Id)desc" or "frog.Name asc". - return Regex.Replace(sortExpression.Trim(), @"(\)|\s)(?i:asc|desc)$", "$1").Trim(); + if (sortExpression.EndsWithCaseInsensitive("asc")) + return sortExpression.Substring(0, sortExpression.Length - 3).Trim(); + if (sortExpression.EndsWithCaseInsensitive("desc")) + return sortExpression.Substring(0, sortExpression.Length - 4).Trim(); + return sortExpression.Trim(); } - private static void AppendSortExpressions(ICollection<string> columnsOrAliases, string[] sortExpressions, + private static void AppendSortExpressions(ICollection<SqlString> columnsOrAliases, SqlString[] sortExpressions, SqlStringBuilder result) { for (int i = 0; i < sortExpressions.Length; i++) @@ -134,7 +137,7 @@ result.Add(", "); } - string sortExpression = RemoveSortOrderDirection(sortExpressions[i]); + SqlString sortExpression = RemoveSortOrderDirection(sortExpressions[i]); if (columnsOrAliases.Contains(sortExpression)) { result.Add(sortExpression); @@ -143,7 +146,7 @@ { result.Add("__hibernate_sort_expr_").Add(i.ToString()).Add("__"); } - if (sortExpressions[i].Trim().ToLower().EndsWith("desc")) + if (sortExpressions[i].Trim().EndsWithCaseInsensitive("desc")) { result.Add(" DESC"); } @@ -161,11 +164,11 @@ return fromIndex; } - private static void ExtractColumnOrAliasNames(SqlString select, out List<string> columnsOrAliases, - out Dictionary<string, string> aliasToColumn) + private static void ExtractColumnOrAliasNames(SqlString select, out List<SqlString> columnsOrAliases, + out Dictionary<SqlString, SqlString> aliasToColumn) { - columnsOrAliases = new List<string>(); - aliasToColumn = new Dictionary<string, string>(); + columnsOrAliases = new List<SqlString>(); + aliasToColumn = new Dictionary<SqlString, SqlString>(); IList<string> tokens = new QuotedAndParenthesisStringTokenizer(select.ToString()).GetTokens(); int index = 0; @@ -222,8 +225,8 @@ index += 2; //skip the "as" and the alias \ } - columnsOrAliases.Add(alias); - aliasToColumn[alias] = token; + columnsOrAliases.Add(new SqlString(alias)); + aliasToColumn[new SqlString(alias)] = new SqlString(token); } } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs 2008-10-15 13:58:32 UTC (rev 3858) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs 2008-10-15 16:59:19 UTC (rev 3859) @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Diagnostics; using System.Text; using NHibernate.Util; @@ -734,5 +735,40 @@ { return new SubselectClauseExtractor(Compact().sqlParts).GetSqlString(); } + + public bool EndsWithCaseInsensitive(string value) + { + SqlString tempSql = Compact(); + if (tempSql.Count == 0) + { + return false; + } + + string lastPart = tempSql.sqlParts[tempSql.Count - 1] as string; + + return lastPart != null && lastPart.EndsWith(value,StringComparison.InvariantCultureIgnoreCase); + + } + + public SqlString[] Split(string splitter) + { + int iterations = 0; + SqlString temp = Compact(); + List<SqlString> results = new List<SqlString>(); + int index; + do + { + index = temp.IndexOfCaseInsensitive(splitter); + int locationOfComma = index == -1 ? + temp.Length : + index; + if (iterations++ > 100) + Debugger.Break(); + + results.Add(temp.Substring(0, locationOfComma)); + temp = temp.Substring(locationOfComma+1); + } while (index != -1); + return results.ToArray(); + } } } Modified: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2008-10-15 13:58:32 UTC (rev 3858) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2008-10-15 16:59:19 UTC (rev 3859) @@ -119,5 +119,26 @@ tx.Commit(); } } + + [Test] + public void LimitingResultSetOnQueryThatIsOrderedByProjection() + { + using(var s = OpenSession()) + { + ICriteria criteria = s.CreateCriteria(typeof(TreeNode), "parent") + .Add(Restrictions.Gt("Key.Id", 0)); + + var currentAssessment = DetachedCriteria.For<TreeNode>("child") + .Add(Restrictions.EqProperty("Key.Id", "parent.Key.Id")) + .Add(Restrictions.EqProperty("Key.Area", "parent.Key.Area")) + .Add(Restrictions.Eq("Type", NodeType.Smart)) + .SetProjection(Projections.Property("Type")); + + criteria.AddOrder(Order.Asc(Projections.SubQuery(currentAssessment))) + .SetMaxResults(1000); + + criteria.List(); + } + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2008-10-15 13:59:33
|
Revision: 3858 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3858&view=rev Author: ayenderahien Date: 2008-10-15 13:58:32 +0000 (Wed, 15 Oct 2008) Log Message: ----------- Fixing NH-1526 - Cannot use projection for Count in OrderBy Fixing NH-1029 - Misleading SQL Query on exception Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs trunk/nhibernate/src/NHibernate/Criterion/CountProjection.cs trunk/nhibernate/src/NHibernate/Exceptions/ADOExceptionHelper.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Key.cs trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/NodeType.cs trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2008-10-15 12:03:06 UTC (rev 3857) +++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2008-10-15 13:58:32 UTC (rev 3858) @@ -193,7 +193,15 @@ { CheckReaders(); Prepare(cmd); - return cmd.ExecuteNonQuery(); + try + { + return cmd.ExecuteNonQuery(); + } + catch (Exception e) + { + e.Data["actual-sql-query"] = cmd.CommandText; + throw; + } } public IDataReader ExecuteReader(IDbCommand cmd) @@ -201,9 +209,18 @@ CheckReaders(); Prepare(cmd); - IDataReader reader = cmd.ExecuteReader(); + IDataReader reader; + try + { + reader = cmd.ExecuteReader(); + } + catch (Exception e) + { + e.Data["actual-sql-query"] = cmd.CommandText; + throw; + } - if (!factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders) + if (!factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders) { reader = new NHybridDataReader(reader); } Modified: trunk/nhibernate/src/NHibernate/Criterion/CountProjection.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/CountProjection.cs 2008-10-15 12:03:06 UTC (rev 3857) +++ trunk/nhibernate/src/NHibernate/Criterion/CountProjection.cs 2008-10-15 13:58:32 UTC (rev 3858) @@ -2,6 +2,7 @@ using System.Collections.Generic; using NHibernate.SqlCommand; using NHibernate.Type; +using NHibernate.Util; namespace NHibernate.Criterion { @@ -34,7 +35,19 @@ { buf.Add("distinct "); } - buf.Add(criteriaQuery.GetColumn(criteria, propertyName)).Add(") as y").Add(position.ToString()).Add("_"); + string column; + if(projection!=null) + { + column = + StringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, position, criteriaQuery, + enabledFilters)).ToString(); + } + else + { + column = criteriaQuery.GetColumn(criteria, propertyName); + } + + buf.Add(column).Add(") as y").Add(position.ToString()).Add("_"); return buf.ToSqlString(); } Modified: trunk/nhibernate/src/NHibernate/Exceptions/ADOExceptionHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Exceptions/ADOExceptionHelper.cs 2008-10-15 12:03:06 UTC (rev 3857) +++ trunk/nhibernate/src/NHibernate/Exceptions/ADOExceptionHelper.cs 2008-10-15 13:58:32 UTC (rev 3858) @@ -8,15 +8,11 @@ namespace NHibernate.Exceptions { - public sealed class ADOExceptionHelper + public static class ADOExceptionHelper { public const string SQLNotAvailable = "SQL not available"; - private ADOExceptionHelper() - { - } - - /// <summary> + /// <summary> /// Converts the given SQLException into NHibernate's ADOException hierarchy, as well as performing /// appropriate logging. /// </summary> @@ -27,6 +23,7 @@ /// <returns> The converted <see cref="ADOException"/>.</returns> public static ADOException Convert(ISQLExceptionConverter converter, Exception sqlException, string message, SqlString sql) { + sql = TryGetActualSqlQuery(sqlException, sql); ADOExceptionReporter.LogExceptions(sqlException, ExtendMessage(message, sql, null, null)); return converter.Convert(sqlException, message, sql); } @@ -41,13 +38,16 @@ /// <returns> The converted <see cref="ADOException"/>.</returns> public static ADOException Convert(ISQLExceptionConverter converter, Exception sqlException, string message) { - return Convert(converter, sqlException, message, new SqlString(SQLNotAvailable)); + SqlString sql = new SqlString(SQLNotAvailable); + sql = TryGetActualSqlQuery(sqlException, sql); + return Convert(converter, sqlException, message, sql); } public static ADOException Convert(ISQLExceptionConverter converter, Exception sqle, string message, SqlString sql, object[] parameterValues, IDictionary<string, TypedValue> namedParameters) { - string extendMessage = ExtendMessage(message, sql, parameterValues, namedParameters); + sql = TryGetActualSqlQuery(sqle, sql); + string extendMessage = ExtendMessage(message, sql, parameterValues, namedParameters); ADOExceptionReporter.LogExceptions(sqle, extendMessage); return new ADOException(extendMessage, sqle, sql); } @@ -100,5 +100,13 @@ sb.Append(Environment.NewLine); return sb.ToString(); } + + public static SqlString TryGetActualSqlQuery(Exception sqle, SqlString sql) + { + string query = (string)sqle.Data["actual-sql-query"]; + if(query!=null) + sql = new SqlString(query); + return sql; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-15 12:03:06 UTC (rev 3857) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-15 13:58:32 UTC (rev 3858) @@ -757,6 +757,10 @@ <Compile Include="Ondelete\ParentChildFixture.cs" /> <Compile Include="Ondelete\Person.cs" /> <Compile Include="Ondelete\Salesperson.cs" /> + <Compile Include="ProjectionFixtures\Key.cs" /> + <Compile Include="ProjectionFixtures\Fixture.cs" /> + <Compile Include="ProjectionFixtures\NodeType.cs" /> + <Compile Include="ProjectionFixtures\TreeNode.cs" /> <Compile Include="PropertyRef\A.cs" /> <Compile Include="PropertyRef\B.cs" /> <Compile Include="PropertyRef\KeyPropertyRefFixture.cs" /> @@ -1499,6 +1503,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="ProjectionFixtures\Mapping.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1033\Mappings.hbm.xml" /> <EmbeddedResource Include="EntityModeTest\Multi\Stock.hbm.xml" /> <EmbeddedResource Include="EntityModeTest\Multi\Valuation.hbm.xml" /> Property changes on: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2008-10-15 13:58:32 UTC (rev 3858) @@ -0,0 +1,123 @@ +using System; +using NHibernate; +using NHibernate.Criterion; +using NHibernate.Test.PropertyRef; +using NUnit.Framework; + +namespace NHibernate.Test.ProjectionFixtures +{ + [TestFixture] + public class Fixture : TestCase + { + protected override System.Collections.IList Mappings + { + get { return new string[] { "ProjectionFixtures.Mapping.hbm.xml" }; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override void OnSetUp() + { + using(var s = sessions.OpenSession()) + using(var tx = s.BeginTransaction()) + { + var root = new TreeNode + { + Key = new Key {Id = 1, Area = 2}, + Type = NodeType.Plain + }; + var child = new TreeNode + { + Key = new Key { Id = 11, Area = 2 }, + Type = NodeType.Blue + }; + var grandchild = new TreeNode + { + Key = new Key {Id = 111, Area = 2}, + Type = NodeType.Smart + }; + root.DirectChildren.Add(child); + child.Parent = root; + grandchild.Parent = child; + child.DirectChildren.Add(grandchild); + + s.Save(root); + s.Save(child); + s.Save(grandchild); + + tx.Commit(); + } + } + + protected override void OnTearDown() + { + using(var s = sessions.OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.Delete("from TreeNode"); + + tx.Commit(); + } + } + + + [Test] + [ExpectedException(typeof(ADOException), ExpectedMessage = @"could not execute query +[ SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = @p0 ] +Positional parameters: #0>2 +[SQL: SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = @p0]")] + public void ErrorFromDBWillGiveTheActualSQLExecuted() + { + DetachedCriteria projection = DetachedCriteria.For<TreeNode>("child") + .Add(Restrictions.Eq("child.Key.Id", 2)) + .SetProjection( + Projections.ProjectionList() + .Add(Projections.Property("child.Key.Id")) + .Add(Projections.Count("child.Key.Area")) + ); + + using (var s = sessions.OpenSession()) + using (var tx = s.BeginTransaction()) + { + var criteria = projection.GetExecutableCriteria(s); + criteria.List(); + + tx.Commit(); + } + } + + [Test] + public void AggregatingHirearchyWithCount() + { + var root = new Key {Id = 1, Area = 2}; + + DetachedCriteria projection = DetachedCriteria.For<TreeNode>("child") + .Add(Restrictions.Eq("Parent.id", root)) + .Add(Restrictions.Gt("Key.Id", 0)) + .Add(Restrictions.Eq("Type", NodeType.Blue)) + .CreateAlias("DirectChildren", "grandchild") + .SetProjection( + Projections.ProjectionList() + .Add(Projections.GroupProperty("child.Key.Id")) + .Add(Projections.GroupProperty("child.Key.Area")) + .Add(Projections.Count(Projections.Property("grandchild.Key.Id"))) + ); + + using(var s = sessions.OpenSession()) + using(var tx = s.BeginTransaction()) + { + var criteria = projection.GetExecutableCriteria(s); + var list = criteria.List(); + Assert.AreEqual(1, list.Count); + var tuple = (object[]) list[0]; + Assert.AreEqual(11, tuple[0]); + Assert.AreEqual(2, tuple[1]); + Assert.AreEqual(1, tuple[2]); + tx.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Key.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Key.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Key.cs 2008-10-15 13:58:32 UTC (rev 3858) @@ -0,0 +1,31 @@ +namespace NHibernate.Test.ProjectionFixtures +{ + public class Key + { + public virtual int Id { get; set; } + public virtual int Area { get; set; } + + public virtual bool Equals(Key obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.Id == Id && obj.Area == Area; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != typeof (Key)) return false; + return Equals((Key) obj); + } + + public override int GetHashCode() + { + unchecked + { + return (Id*397) ^ Area; + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Mapping.hbm.xml 2008-10-15 13:58:32 UTC (rev 3858) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.ProjectionFixtures"> + + <class name="TreeNode"> + <composite-id name="Key"> + <key-property name="Id" /> + <key-property name="Area" /> + </composite-id> + <many-to-one name="Parent"> + <column name="Parent"/> + <column name="ParentArea"/> + </many-to-one> + <set name="DirectChildren"> + <key> + <column name="Parent"/> + <column name="ParentArea"/> + </key> + <one-to-many class="TreeNode"/> + </set> + <property name="Type"/> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/NodeType.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/NodeType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/NodeType.cs 2008-10-15 13:58:32 UTC (rev 3858) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.ProjectionFixtures +{ + public enum NodeType + { + Smart, + Plain, + Blue + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/TreeNode.cs 2008-10-15 13:58:32 UTC (rev 3858) @@ -0,0 +1,18 @@ +using Iesi.Collections.Generic; +using NHibernate.Test.ProjectionFixtures; + +namespace NHibernate.Test.ProjectionFixtures +{ + public class TreeNode + { + public virtual Key Key { get; set; } + public virtual TreeNode Parent { get; set; } + public virtual NodeType Type { get; set; } + public virtual ISet<TreeNode> DirectChildren { get; set; } + + public TreeNode() + { + DirectChildren = new HashedSet<TreeNode>(); + } + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2008-10-15 12:03:20
|
Revision: 3857 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3857&view=rev Author: ayenderahien Date: 2008-10-15 12:03:06 +0000 (Wed, 15 Oct 2008) Log Message: ----------- minor - fixing spelling mistake Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Loader/Loader.cs Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-15 11:55:40 UTC (rev 3856) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-15 12:03:06 UTC (rev 3857) @@ -1688,10 +1688,10 @@ protected IList DoList(ISessionImplementor session, QueryParameters queryParameters) { bool statsEnabled = Factory.Statistics.IsStatisticsEnabled; - var stopWath = new Stopwatch(); + var stopWatch = new Stopwatch(); if (statsEnabled) { - stopWath.Start(); + stopWatch.Start(); } IList result; @@ -1711,8 +1711,8 @@ } if (statsEnabled) { - stopWath.Stop(); - Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, result.Count, stopWath.Elapsed); + stopWatch.Stop(); + Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, result.Count, stopWatch.Elapsed); } return result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2008-10-15 11:55:46
|
Revision: 3856 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3856&view=rev Author: ayenderahien Date: 2008-10-15 11:55:40 +0000 (Wed, 15 Oct 2008) Log Message: ----------- Fixing the nant build, will now properly embed resources. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build Modified: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build 2008-10-13 16:40:25 UTC (rev 3855) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build 2008-10-15 11:55:40 UTC (rev 3856) @@ -32,6 +32,10 @@ <include name="nunit.framework.dll"/> </assemblyfileset> + <resourcefileset id="project.resources" prefix="NHibernate.ProxyGenerators.CastleDynamicProxy.Tests" dynamicprefix="true"> + <include name="**/*.xml" /> + <exclude name="bin/**/*.xml" /> + </resourcefileset> </target> <target name="generate-assemblyinfo" depends="init common.generate-assemblyinfo" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-13 16:40:36
|
Revision: 3855 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3855&view=rev Author: tehlike Date: 2008-10-13 16:40:25 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Minor (fix NH-1522) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Transaction/AdoTransaction.cs Modified: trunk/nhibernate/src/NHibernate/Transaction/AdoTransaction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Transaction/AdoTransaction.cs 2008-10-13 13:38:26 UTC (rev 3854) +++ trunk/nhibernate/src/NHibernate/Transaction/AdoTransaction.cs 2008-10-13 16:40:25 UTC (rev 3855) @@ -206,7 +206,7 @@ } finally { - CloseIfRequerid(); + CloseIfRequired(); } } @@ -249,7 +249,7 @@ finally { AfterTransactionCompletion(false); - CloseIfRequerid(); + CloseIfRequired(); } } } @@ -288,7 +288,7 @@ get { return trans.IsolationLevel; } } - void CloseIfRequerid() + void CloseIfRequired() { //bool close = session.ShouldAutoClose() && !transactionContext.isClosed(); //if (close) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-13 13:38:41
|
Revision: 3854 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3854&view=rev Author: fabiomaulo Date: 2008-10-13 13:38:26 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Fixed tests for new exceptions Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/QueryTest/PositionalParametersFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/QueryTest/PositionalParametersFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/QueryTest/PositionalParametersFixture.cs 2008-10-11 23:38:11 UTC (rev 3853) +++ trunk/nhibernate/src/NHibernate.Test/QueryTest/PositionalParametersFixture.cs 2008-10-13 13:38:26 UTC (rev 3854) @@ -59,7 +59,7 @@ } } - [Test, ExpectedException(typeof(IndexOutOfRangeException))] + [Test, ExpectedException(typeof(ArgumentException))] public void TestPositionOutOfBounds() { ISession s = OpenSession(); @@ -80,7 +80,7 @@ } } - [Test, ExpectedException(typeof(IndexOutOfRangeException))] + [Test, ExpectedException(typeof(ArgumentException))] public void TestNoPositionalParameters() { ISession s = OpenSession(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-11 23:38:21
|
Revision: 3853 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3853&view=rev Author: fabiomaulo Date: 2008-10-11 23:38:11 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Retouch Fix of NH-1047 in order to use generics. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/IQuery.cs trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs Modified: trunk/nhibernate/src/NHibernate/IQuery.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQuery.cs 2008-10-11 23:15:18 UTC (rev 3852) +++ trunk/nhibernate/src/NHibernate/IQuery.cs 2008-10-11 23:38:11 UTC (rev 3853) @@ -189,25 +189,22 @@ /// <param name="type">The NHibernate <see cref="IType"/>.</param> IQuery SetParameter(string name, object val, IType type); - /// <summary> /// Bind a value to an indexed parameter. /// </summary> /// <param name="position">Position of the parameter in the query, numbered from <c>0</c></param> /// <param name="val">The possibly null parameter value</param> - /// <param name="type">The System.Type</param> - IQuery SetParameter(int position, object val, System.Type type); + /// <typeparam name="T">The parameter's <see cref="Type"/> </typeparam> + IQuery SetParameter<T>(int position, T val); /// <summary> /// Bind a value to a named query parameter /// </summary> /// <param name="name">The name of the parameter</param> /// <param name="val">The possibly null parameter value</param> - /// <param name="type">The System.Type.</param> - IQuery SetParameter(string name, object val, System.Type type); + /// <typeparam name="T">The parameter's <see cref="Type"/> </typeparam> + IQuery SetParameter<T>(string name, T val); - - /// <summary> /// Bind a value to an indexed parameter, guessing the Hibernate type from /// the class of the given object. Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2008-10-11 23:15:18 UTC (rev 3852) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2008-10-11 23:38:11 UTC (rev 3853) @@ -322,17 +322,16 @@ } } - public IQuery SetParameter(int position, object val, System.Type type) + public IQuery SetParameter<T>(int position, T val) { - return SetParameter(position, val, GuessType(type)); + return SetParameter(position, val, GuessType(typeof (T))); } - public IQuery SetParameter(string name,object val,System.Type type) + public IQuery SetParameter<T>(string name, T val) { - return SetParameter(name, val, GuessType(type)); + return SetParameter(name, val, GuessType(typeof (T))); } - public IQuery SetParameter(string name, object val) { if (!parameterMetadata.NamedParameterNames.Contains(name)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-11 23:15:25
|
Revision: 3852 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3852&view=rev Author: fabiomaulo Date: 2008-10-11 23:15:18 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Minor (changed ignore list) Property Changed: ---------------- trunk/nhibernate/src/NHibernate/ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ Property changes on: trunk/nhibernate/src/NHibernate ___________________________________________________________________ Modified: svn:ignore - bin obj .#* *.user *.xsx AssemblyInfo.cs Debug Release *.aps *.eto [Bb]in [Dd]ebug [Rr]elease + obj .#* *.user *.xsx AssemblyInfo.cs *.aps *.eto [Bb]in [Dd]ebug [Rr]elease Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy ___________________________________________________________________ Modified: svn:ignore - [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto *resharper* + [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto *resharper* AssemblyInfo.cs Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests ___________________________________________________________________ Modified: svn:ignore - [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto *resharper* hibernate.cfg.xml + [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto *resharper* hibernate.cfg.xml AssemblyInfo.cs This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-11 23:10:46
|
Revision: 3851 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3851&view=rev Author: fabiomaulo Date: 2008-10-11 23:10:39 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Removed generated AssemblyInfo Removed Paths: ------------- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/AssemblyInfo.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/AssemblyInfo.cs Deleted: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/AssemblyInfo.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/AssemblyInfo.cs 2008-10-11 22:25:44 UTC (rev 3850) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/AssemblyInfo.cs 2008-10-11 23:10:39 UTC (rev 3851) @@ -1,27 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; - -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:2.0.50727.3053 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -[assembly: CLSCompliantAttribute(true)] -[assembly: AssemblyTitleAttribute("NHibernate.ProxyGenerators.CastleDynamicProxy")] -[assembly: AssemblyDescriptionAttribute("Castle Dynamic proxy generator adapters for NHibernate.")] -[assembly: AssemblyCompanyAttribute("NHibernate.org")] -[assembly: AssemblyProductAttribute("NHibernate.ProxyGenerators.CastleDynamicProxy")] -[assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] -[assembly: AssemblyVersionAttribute("2.1.0.1001")] -[assembly: AssemblyInformationalVersionAttribute("2.1.0.1001")] -[assembly: AssemblyFileVersionAttribute("2.1.0.1001")] -[assembly: AssemblyDelaySignAttribute(false)] -[assembly: AllowPartiallyTrustedCallersAttribute()] - Deleted: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/AssemblyInfo.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/AssemblyInfo.cs 2008-10-11 22:25:44 UTC (rev 3850) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/AssemblyInfo.cs 2008-10-11 23:10:39 UTC (rev 3851) @@ -1,25 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:2.0.50727.3053 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyTitleAttribute("NHibernate.ProxyGenerators.CastleDynamicProxy.Tests")] -[assembly: AssemblyDescriptionAttribute("The Unit Tests for Castle ProxyGenerators.")] -[assembly: AssemblyCompanyAttribute("NHibernate.org")] -[assembly: AssemblyProductAttribute("NHibernate.ProxyGenerators.CastleDynamicProxy.Tests")] -[assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] -[assembly: AssemblyVersionAttribute("1.0.0.1")] -[assembly: AssemblyInformationalVersionAttribute("1.0")] -[assembly: AssemblyFileVersionAttribute("2.1.0.1001")] -[assembly: AssemblyDelaySignAttribute(false)] - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-11 22:25:52
|
Revision: 3850 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3850&view=rev Author: fabiomaulo Date: 2008-10-11 22:25:44 +0000 (Sat, 11 Oct 2008) Log Message: ----------- - Removed dependency from Castle.DynamicProxy2 in the Core codeBase. - New project NHibernate.ProxyGenerators.CastleDynamicProxy to use as Default in NH Modified Paths: -------------- trunk/nhibernate/default.build trunk/nhibernate/releasenotes.txt trunk/nhibernate/src/NHibernate/Cfg/Environment.cs trunk/nhibernate/src/NHibernate/NHibernate.build trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Proxy/Map/MapProxyFactory.cs trunk/nhibernate/src/NHibernate.Everything.sln trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.sln Added Paths: ----------- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/AssemblyInfo.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/LazyInitializer.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/NHibernate.ProxyGenerators.CastleDynamicProxy.csproj trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/Properties/ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactory.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactoryFactory.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyGenerators.build trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/App.config trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/AssemblyInfo.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/DebugConnectionProvider.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.csproj trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/Properties/ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxy.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyFixture.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.hbm.xml trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/Classes.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CustomProxyFixture.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/TestCase.cs trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/TestConfigurationHelper.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Bytecode/Castle/ trunk/nhibernate/src/NHibernate/Proxy/Poco/Castle/ trunk/nhibernate/src/NHibernate.Test/ProxyInterface/ Modified: trunk/nhibernate/default.build =================================================================== --- trunk/nhibernate/default.build 2008-10-11 21:37:31 UTC (rev 3849) +++ trunk/nhibernate/default.build 2008-10-11 22:25:44 UTC (rev 3850) @@ -23,10 +23,11 @@ <fileset id="buildfiles.all" basedir="src"> <!-- Files have to be in dependency order --> - <!--<include name="HashCodeProvider/HashCodeProvider.build" />--> <include name="Iesi.Collections/Iesi.Collections.build" /> <include name="Iesi.Collections.Test/Iesi.Collections.Test.build" /> <include name="NHibernate/NHibernate.build" /> + <include name="NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyGenerators.build" /> + <include name="NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build" /> <include name="NHibernate.DomainModel/NHibernate.DomainModel.build" /> <include name="NHibernate.Test/NHibernate.Test.build" /> <include name="NHibernate.Test.Performance/NHibernate.Test.Performance.build" /> @@ -36,6 +37,7 @@ <fileset id="buildfiles.tests" basedir="src"> <include name="Iesi.Collections.Test/Iesi.Collections.Test.build" /> + <include name="NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build" /> <include name="NHibernate.Test/NHibernate.Test.build" /> <include name="NHibernate.Test.Performance/NHibernate.Test.Performance.build" if="${run.performance.tests}" /> @@ -84,6 +86,8 @@ --> <exclude name="Iesi.Collections.dll" /> <exclude name="Iesi.Collections.xml" /> + <exclude name="NHibernate.ProxyGenerators.CastleDynamicProxy.dll" /> + <exclude name="NHibernate.ProxyGenerators.CastleDynamicProxy.xml" /> <include name="*.dll" /> <include name="*.xml" /> <include name="*.license.txt" /> @@ -229,6 +233,7 @@ <!-- exclude ReSharper stuff --> <exclude name="**/_ReSharper*/**" /> <exclude name="**/*.resharperoptions" /> + <exclude name="**/*resharper*" /> <!-- exclude VS.NET stuff --> <exclude name="**/*.suo" /> @@ -259,7 +264,7 @@ <target name="copy-xml-schemas" depends="init"> <!-- TODO: Probably need to think of a better place for the XML schemas since - they are used by NHibernate, NHMA, and this build file. + they are used by NHibernate and this build file. --> <copy todir="${build.dir}"> <fileset basedir="src/NHibernate"> Modified: trunk/nhibernate/releasenotes.txt =================================================================== --- trunk/nhibernate/releasenotes.txt 2008-10-11 21:37:31 UTC (rev 3849) +++ trunk/nhibernate/releasenotes.txt 2008-10-11 22:25:44 UTC (rev 3850) @@ -1,6 +1,9 @@ Build 2.1.0.GA ======================== ** BREAKING CHANGES from NH2.0.xGA to NH2.1.0 + ##### Run time ##### + * If you want work using lazy loading with Castle.DynamicProxy2 now you must deploy NHibernate.ProxyGenerators.CastleDynamicProxy.dll + ##### Possible Breaking Changes for external frameworks ##### * ISession interface have additional methods * DefaultProxyFactoryFactory moved to NHibernate.Bytecode.Castle.ProxyFactoryFactory Modified: trunk/nhibernate/src/NHibernate/Cfg/Environment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2008-10-11 21:37:31 UTC (rev 3849) +++ trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -193,7 +193,7 @@ private static void SetDefaultProxyFactoryFactory() { // maitaining the optionality of set the proxyfactory.factory_class property - GlobalProperties[ProxyFactoryFactoryClass] = "NHibernate.Bytecode.Castle.ProxyFactoryFactory, NHibernate"; + GlobalProperties[ProxyFactoryFactoryClass] = "NHibernate.ProxyGenerators.CastleDynamicProxy.ProxyFactoryFactory, NHibernate.ProxyGenerators.CastleDynamicProxy"; } private static void LoadGlobalPropertiesFromAppConfig() Modified: trunk/nhibernate/src/NHibernate/NHibernate.build =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.build 2008-10-11 21:37:31 UTC (rev 3849) +++ trunk/nhibernate/src/NHibernate/NHibernate.build 2008-10-11 22:25:44 UTC (rev 3850) @@ -24,8 +24,6 @@ <include name="System.Web.dll" /> <include name="Iesi.Collections.dll" /> <include name="log4net.dll" /> - <include name="Castle.Core.dll" /> - <include name="Castle.DynamicProxy2.dll" /> </assemblyfileset> <resourcefileset id="project.resources" prefix="NHibernate" dynamicprefix="true"> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-10-11 21:37:31 UTC (rev 3849) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-10-11 22:25:44 UTC (rev 3850) @@ -40,14 +40,6 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Castle.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\lib\net\2.0\Castle.Core.dll</HintPath> - </Reference> - <Reference Include="Castle.DynamicProxy2, Version=2.0.0.1, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\lib\net\2.0\Castle.DynamicProxy2.dll</HintPath> - </Reference> <Reference Include="Iesi.Collections, Version=1.0.0.1, Culture=neutral, PublicKeyToken=154fdcb44c4484fc"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\lib\net\2.0\Iesi.Collections.dll</HintPath> @@ -297,8 +289,6 @@ <Compile Include="Properties\PascalCaseMUnderscoreStrategy.cs" /> <Compile Include="Properties\PascalCaseUnderscoreStrategy.cs" /> <Compile Include="Properties\PropertyAccessorFactory.cs" /> - <Compile Include="Proxy\Poco\Castle\CastleLazyInitializer.cs" /> - <Compile Include="Proxy\Poco\Castle\CastleProxyFactory.cs" /> <Compile Include="Proxy\INHibernateProxy.cs" /> <Compile Include="Proxy\IProxyFactory.cs" /> <Compile Include="Proxy\AbstractLazyInitializer.cs" /> @@ -452,7 +442,6 @@ <Compile Include="AdoNet\TooManyRowsAffectedException.cs" /> <Compile Include="Properties\BackFieldStrategy.cs" /> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> - <Compile Include="Bytecode\Castle\ProxyFactoryFactory.cs" /> <Compile Include="Bytecode\IAccessOptimizer.cs" /> <Compile Include="Bytecode\IBytecodeProvider.cs" /> <Compile Include="Bytecode\IInjectableProxyFactoryFactory.cs" /> Modified: trunk/nhibernate/src/NHibernate/Proxy/Map/MapProxyFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Proxy/Map/MapProxyFactory.cs 2008-10-11 21:37:31 UTC (rev 3849) +++ trunk/nhibernate/src/NHibernate/Proxy/Map/MapProxyFactory.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; using System.Reflection; -using System.Text; using Iesi.Collections.Generic; using NHibernate.Engine; using NHibernate.Type; Modified: trunk/nhibernate/src/NHibernate.Everything.sln =================================================================== --- trunk/nhibernate/src/NHibernate.Everything.sln 2008-10-11 21:37:31 UTC (rev 3849) +++ trunk/nhibernate/src/NHibernate.Everything.sln 2008-10-11 22:25:44 UTC (rev 3850) @@ -99,6 +99,12 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.Tool.HbmXsd", "NHibernate.Tool.HbmXsd\NHibernate.Tool.HbmXsd.csproj", "{446E148D-A9D5-4D7D-A706-BEDD45B2BC7D}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Default proxy generator", "Default proxy generator", "{D2E4E87F-2531-4C7A-BBE9-FE8BFEDECECE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.ProxyGenerators.CastleDynamicProxy", "NHibernate.ProxyGenerators.CastleDynamicProxy\NHibernate.ProxyGenerators.CastleDynamicProxy.csproj", "{31C3F0EA-0FED-4A2F-B68D-96CE29844487}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.ProxyGenerators.CastleDynamicProxy.Tests", "NHibernate.ProxyGenerators.CastleDynamicProxy.Tests\NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.csproj", "{4972EE96-2417-4D47-9FF1-3B1D6B1D3191}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -200,6 +206,26 @@ {446E148D-A9D5-4D7D-A706-BEDD45B2BC7D}.Release|Any CPU.Build.0 = Release|Any CPU {446E148D-A9D5-4D7D-A706-BEDD45B2BC7D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {446E148D-A9D5-4D7D-A706-BEDD45B2BC7D}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Debug|.NET.ActiveCfg = Debug|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Release|.NET.ActiveCfg = Release|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Release|Any CPU.Build.0 = Release|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {31C3F0EA-0FED-4A2F-B68D-96CE29844487}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Debug|.NET.ActiveCfg = Debug|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Release|.NET.ActiveCfg = Release|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Release|Any CPU.Build.0 = Release|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -211,6 +237,7 @@ {094F74CD-2DD7-496F-BC48-A6D357BF33FD} = {28EA2C84-8295-49ED-BC67-803B7778513E} {92509065-DAEA-4457-8300-C7B64CD0E9F4} = {28EA2C84-8295-49ED-BC67-803B7778513E} {C91E7018-3C67-4830-963A-C388C75E1BD5} = {28EA2C84-8295-49ED-BC67-803B7778513E} + {D2E4E87F-2531-4C7A-BBE9-FE8BFEDECECE} = {28EA2C84-8295-49ED-BC67-803B7778513E} {5909BFE7-93CF-4E5F-BE22-6293368AF01D} = {094F74CD-2DD7-496F-BC48-A6D357BF33FD} {5C649B55-1B3F-4C38-9998-1B043E94A244} = {094F74CD-2DD7-496F-BC48-A6D357BF33FD} {7AEE5B37-C552-4E59-9B6F-88755BCB5070} = {094F74CD-2DD7-496F-BC48-A6D357BF33FD} @@ -219,6 +246,8 @@ {446E148D-A9D5-4D7D-A706-BEDD45B2BC7D} = {92509065-DAEA-4457-8300-C7B64CD0E9F4} {4C251E3E-6EA1-4A51-BBCB-F9C42AE55344} = {C91E7018-3C67-4830-963A-C388C75E1BD5} {58CE4584-31B9-4E74-A7FB-5D40BFAD0876} = {C91E7018-3C67-4830-963A-C388C75E1BD5} + {31C3F0EA-0FED-4A2F-B68D-96CE29844487} = {D2E4E87F-2531-4C7A-BBE9-FE8BFEDECECE} + {4972EE96-2417-4D47-9FF1-3B1D6B1D3191} = {D2E4E87F-2531-4C7A-BBE9-FE8BFEDECECE} EndGlobalSection GlobalSection(TextTemplating) = postSolution TextTemplating = 1 Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy ___________________________________________________________________ Added: svn:ignore + [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto *resharper* Added: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/AssemblyInfo.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/AssemblyInfo.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/AssemblyInfo.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,27 @@ +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; + +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.3053 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +[assembly: CLSCompliantAttribute(true)] +[assembly: AssemblyTitleAttribute("NHibernate.ProxyGenerators.CastleDynamicProxy")] +[assembly: AssemblyDescriptionAttribute("Castle Dynamic proxy generator adapters for NHibernate.")] +[assembly: AssemblyCompanyAttribute("NHibernate.org")] +[assembly: AssemblyProductAttribute("NHibernate.ProxyGenerators.CastleDynamicProxy")] +[assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] +[assembly: AssemblyVersionAttribute("2.1.0.1001")] +[assembly: AssemblyInformationalVersionAttribute("2.1.0.1001")] +[assembly: AssemblyFileVersionAttribute("2.1.0.1001")] +[assembly: AssemblyDelaySignAttribute(false)] +[assembly: AllowPartiallyTrustedCallersAttribute()] + Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/LazyInitializer.cs (from rev 3844, trunk/nhibernate/src/NHibernate/Proxy/Poco/Castle/CastleLazyInitializer.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/LazyInitializer.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/LazyInitializer.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,86 @@ +using System; +using System.Reflection; +using Castle.Core.Interceptor; +using NHibernate.Proxy; +using NHibernate.Proxy.Poco; +using NHibernate.Type; +using NHibernate.Engine; + +namespace NHibernate.ProxyGenerators.CastleDynamicProxy +{ + /// <summary> + /// A <see cref="ILazyInitializer"/> for use with the Castle Dynamic Class Generator. + /// </summary> + [Serializable] + [CLSCompliant(false)] + public class LazyInitializer : BasicLazyInitializer, Castle.Core.Interceptor.IInterceptor + { + private static readonly MethodInfo Exception_InternalPreserveStackTrace = + typeof(Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic); + + #region Instance + + public bool _constructed; + + /// <summary> + /// Initializes a new <see cref="LazyInitializer"/> object. + /// </summary> + /// <param name="entityName"></param> + /// <param name="persistentClass">The Class to Proxy.</param> + /// <param name="id">The Id of the Object we are Proxying.</param> + /// <param name="getIdentifierMethod"></param> + /// <param name="setIdentifierMethod"></param> + /// <param name="componentIdType"></param> + /// <param name="session">The ISession this Proxy is in.</param> + public LazyInitializer(string entityName, System.Type persistentClass, object id, + MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, + IAbstractComponentType componentIdType, ISessionImplementor session) + :base(entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session) + { + } + + /// <summary> + /// Invoke the actual Property/Method using the Proxy or instantiate the actual + /// object and use it when the Proxy can't handle the method. + /// </summary> + /// <param name="invocation">The <see cref="IInvocation"/> from the generated Castle.DynamicProxy.</param> + public virtual void Intercept(IInvocation invocation) + { + try + { + if (_constructed) + { + // let the generic LazyInitializer figure out if this can be handled + // with the proxy or if the real class needs to be initialized + invocation.ReturnValue = base.Invoke(invocation.Method, invocation.Arguments, invocation.Proxy); + + // the base LazyInitializer could not handle it so we need to Invoke + // the method/property against the real class + if (invocation.ReturnValue == InvokeImplementation) + { + invocation.ReturnValue = invocation.Method.Invoke(GetImplementation(), invocation.Arguments); + return; + } + else + { + return; + } + } + else + { + // TODO: Find out equivalent to CGLIB's 'method.invokeSuper'. + return; + } + } + catch (TargetInvocationException tie) + { + // Propagate the inner exception so that the proxy throws the same exception as + // the real object would + Exception_InternalPreserveStackTrace.Invoke(tie.InnerException, new Object[] { }); + throw tie.InnerException; + } + } + + #endregion + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/LazyInitializer.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Added: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/NHibernate.ProxyGenerators.CastleDynamicProxy.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/NHibernate.ProxyGenerators.CastleDynamicProxy.csproj (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/NHibernate.ProxyGenerators.CastleDynamicProxy.csproj 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{31C3F0EA-0FED-4A2F-B68D-96CE29844487}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>NHibernate.ProxyGenerators.CastleDynamicProxy</RootNamespace> + <AssemblyName>NHibernate.ProxyGenerators.CastleDynamicProxy</AssemblyName> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\Castle.Core.dll</HintPath> + </Reference> + <Reference Include="Castle.DynamicProxy2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\Castle.DynamicProxy2.dll</HintPath> + </Reference> + <Reference Include="Iesi.Collections, Version=1.0.0.3, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\Iesi.Collections.dll</HintPath> + </Reference> + <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\log4net.dll</HintPath> + </Reference> + <Reference Include="System" /> + </ItemGroup> + <ItemGroup> + <Compile Include="AssemblyInfo.cs" /> + <Compile Include="LazyInitializer.cs" /> + <Compile Include="ProxyFactory.cs" /> + <Compile Include="ProxyFactoryFactory.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\NHibernate\NHibernate.csproj"> + <Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project> + <Name>NHibernate</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <None Include="ProxyGenerators.build" /> + </ItemGroup> + <ItemGroup> + <Folder Include="Properties\" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactory.cs (from rev 3844, trunk/nhibernate/src/NHibernate/Proxy/Poco/Castle/CastleProxyFactory.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactory.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactory.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,105 @@ +using System; +using System.Reflection; +using Castle.DynamicProxy; +using Iesi.Collections.Generic; +using log4net; +using NHibernate.Engine; +using NHibernate.Proxy; +using NHibernate.Type; + +namespace NHibernate.ProxyGenerators.CastleDynamicProxy +{ + public class ProxyFactory : IProxyFactory + { + protected static readonly ILog log = LogManager.GetLogger(typeof (ProxyFactory)); + private static readonly ProxyGenerator _proxyGenerator = new ProxyGenerator(); + + private System.Type _persistentClass; + private System.Type[] _interfaces; + private MethodInfo _getIdentifierMethod; + private MethodInfo _setIdentifierMethod; + private string _entityName; + private IAbstractComponentType _componentIdType; + + public virtual void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces, + MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, + IAbstractComponentType componentIdType) + { + _entityName = entityName; + _persistentClass = persistentClass; + _interfaces = new System.Type[interfaces.Count]; + interfaces.CopyTo(_interfaces, 0); + _getIdentifierMethod = getIdentifierMethod; + _setIdentifierMethod = setIdentifierMethod; + _componentIdType = componentIdType; + } + + protected static ProxyGenerator DefaultProxyGenerator + { + get { return _proxyGenerator; } + } + + protected System.Type PersistentClass + { + get { return _persistentClass; } + } + + protected System.Type[] Interfaces + { + get { return _interfaces; } + } + + protected MethodInfo GetIdentifierMethod + { + get { return _getIdentifierMethod; } + } + + protected MethodInfo SetIdentifierMethod + { + get { return _setIdentifierMethod; } + } + + protected bool IsClassProxy + { + get { return _interfaces.Length == 1; } + } + + public string EntityName + { + get { return _entityName; } + } + + public IAbstractComponentType ComponentIdType + { + get { return _componentIdType; } + } + + /// <summary> + /// Build a proxy using the Castle.DynamicProxy library. + /// </summary> + /// <param name="id">The value for the Id.</param> + /// <param name="session">The Session the proxy is in.</param> + /// <returns>A fully built <c>INHibernateProxy</c>.</returns> + public virtual INHibernateProxy GetProxy(object id, ISessionImplementor session) + { + try + { + var initializer = new LazyInitializer(EntityName, _persistentClass, id, _getIdentifierMethod, + _setIdentifierMethod, ComponentIdType, session); + + object generatedProxy = IsClassProxy + ? _proxyGenerator.CreateClassProxy(_persistentClass, _interfaces, initializer) + : _proxyGenerator.CreateInterfaceProxyWithoutTarget(_interfaces[0], _interfaces, + initializer); + + initializer._constructed = true; + return (INHibernateProxy) generatedProxy; + } + catch (Exception e) + { + log.Error("Creating a proxy instance failed", e); + throw new HibernateException("Creating a proxy instance failed", e); + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactory.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactoryFactory.cs (from rev 3844, trunk/nhibernate/src/NHibernate/Bytecode/Castle/ProxyFactoryFactory.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactoryFactory.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyFactoryFactory.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,22 @@ +using NHibernate.Bytecode; +using NHibernate.Proxy; + +namespace NHibernate.ProxyGenerators.CastleDynamicProxy +{ + public class ProxyFactoryFactory : IProxyFactoryFactory + { + #region IProxyFactoryFactory Members + + public IProxyFactory BuildProxyFactory() + { + return new ProxyFactory(); + } + + public IProxyValidator ProxyValidator + { + get { return new DynProxyTypeValidator(); } + } + + #endregion + } +} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyGenerators.build (from rev 3844, trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.build) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyGenerators.build (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyGenerators.build 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,37 @@ +<?xml version="1.0" ?> + +<project + name="NHibernate.ProxyGenerators.CastleDynamicProxy" + default="build" + xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd" +> + + <property name="root.dir" value="../.." /> + <include buildfile="${root.dir}/build-common/common-project.xml" /> + + <target name="init" depends="common.init"> + + <property name="assembly.is-cls-compliant" value="true" /> + <property name="assembly.description" + value="Castle Dynamic proxy generator adapters for NHibernate." /> + <property name="assembly.copyright" + value="Licensed under LGPL." /> + <property name="assembly.allow-partially-trusted-callers" value="true" /> + + <property name="clover.instrument" value="true" /> + + <assemblyfileset basedir="${bin.dir}" id="project.references"> + <include name="System.dll" /> + <include name="Iesi.Collections.dll" /> + <include name="log4net.dll" /> + <include name="Castle.Core.dll" /> + <include name="Castle.DynamicProxy2.dll" /> + <include name="NHibernate.dll" /> + </assemblyfileset> + + </target> + + <target name="generate-assemblyinfo" depends="init common.generate-assemblyinfo" /> + <target name="build" depends="init generate-assemblyinfo common.compile-dll" description="Build Castle ProxyGenerators" /> + +</project> Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy/ProxyGenerators.build ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests ___________________________________________________________________ Added: svn:ignore + [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto *resharper* hibernate.cfg.xml Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/App.config (from rev 3844, trunk/nhibernate/src/NHibernate.Test/App.config) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/App.config (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/App.config 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <configSections> + <section name="hibernate-configuration" + type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> + <section name="log4net" + type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> + </configSections> + + <!-- + hibernate-configuration section + + You don't need to change this section for your own use. + You can write your own hibernate.cfg.xml to override all session-factory configuration. + Templates are available in NHibernate.Config.Templates folder. + --> + <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> + <bytecode-provider type="lcg"/> + <reflection-optimizer use="true"/> + <session-factory name="NHibernate.Test"> + <property name="connection.provider">NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.DebugConnectionProvider, NHibernate.ProxyGenerators.CastleDynamicProxy.Tests</property> + <property name="cache.provider_class">NHibernate.Cache.HashtableCacheProvider, NHibernate</property> + <property name="cache.use_query_cache">true</property> + <property name="prepare_sql">false</property> + <property name="query.startup_check">false</property> + <property name="connection.isolation">ReadCommitted</property> + <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> + <property name="connection.connection_string"> + Server=(local);initial catalog=nhibernate;Integrated Security=SSPI + </property> + <property name="show_sql">false</property> + <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> + <property name="use_outer_join">true</property> + <property name="command_timeout">10</property> + <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> + <property name="adonet.wrap_result_sets">false</property> + + <!-- This property is the default value in NH Core --> + <property name="proxyfactory.factory_class">NHibernate.ProxyGenerators.CastleDynamicProxy.ProxyFactoryFactory, NHibernate.ProxyGenerators.CastleDynamicProxy</property> + + </session-factory> + </hibernate-configuration> + + <!-- This section contains the log4net configuration settings --> + <log4net debug="false"> + + <!-- Define some output appenders --> + <appender name="trace" + type="log4net.Appender.TraceAppender, log4net"> + <layout type="log4net.Layout.PatternLayout,log4net"> + <param name="ConversionPattern" + value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" /> + </layout> + </appender> + + <appender name="console" + type="log4net.Appender.ConsoleAppender, log4net"> + <layout type="log4net.Layout.PatternLayout,log4net"> + <param name="ConversionPattern" + value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" /> + </layout> + </appender> + + <appender name="rollingFile" + type="log4net.Appender.RollingFileAppender,log4net" > + + <param name="File" + value="log.txt" /> + <param name="AppendToFile" + value="false" /> + <param name="RollingStyle" + value="Date" /> + <param name="DatePattern" + value="yyyy.MM.dd" /> + <param name="StaticLogFileName" + value="true" /> + + <layout type="log4net.Layout.PatternLayout,log4net"> + <param name="ConversionPattern" + value="%d [%t] %-5p %c - %m%n" /> + </layout> + </appender> + + <root> + <priority value="WARN" /> + <appender-ref ref="console" /> + </root> + + <logger name="NHibernate"> + <priority value="ERROR" /> + </logger> + + <logger name="NHibernate.Tool.hbm2ddl.SchemaExport"> + <level value="ERROR" /> + </logger> + </log4net> + + +</configuration> + + + Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/App.config ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Added: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/AssemblyInfo.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/AssemblyInfo.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/AssemblyInfo.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,25 @@ +using System; +using System.Reflection; +using System.Runtime.CompilerServices; + +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.3053 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +[assembly: CLSCompliantAttribute(false)] +[assembly: AssemblyTitleAttribute("NHibernate.ProxyGenerators.CastleDynamicProxy.Tests")] +[assembly: AssemblyDescriptionAttribute("The Unit Tests for Castle ProxyGenerators.")] +[assembly: AssemblyCompanyAttribute("NHibernate.org")] +[assembly: AssemblyProductAttribute("NHibernate.ProxyGenerators.CastleDynamicProxy.Tests")] +[assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] +[assembly: AssemblyVersionAttribute("1.0.0.1")] +[assembly: AssemblyInformationalVersionAttribute("1.0")] +[assembly: AssemblyFileVersionAttribute("2.1.0.1001")] +[assembly: AssemblyDelaySignAttribute(false)] + Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/DebugConnectionProvider.cs (from rev 3844, trunk/nhibernate/src/NHibernate.Test/DebugConnectionProvider.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/DebugConnectionProvider.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/DebugConnectionProvider.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,72 @@ +using System.Collections; +using System.Data; +using Iesi.Collections; +using NHibernate.Connection; + +namespace NHibernate.ProxyGenerators.CastleDynamicProxy.Tests +{ + /// <summary> + /// This connection provider keeps a list of all open connections, + /// it is used when testing to check that tests clean up after themselves. + /// </summary> + public class DebugConnectionProvider : DriverConnectionProvider + { + private readonly ISet connections = new ListSet(); + + public override IDbConnection GetConnection() + { + IDbConnection connection = base.GetConnection(); + connections.Add(connection); + return connection; + } + + public override void CloseConnection(IDbConnection conn) + { + base.CloseConnection(conn); + connections.Remove(conn); + } + + public bool HasOpenConnections + { + get + { + // check to see if all connections that were at one point opened + // have been closed through the CloseConnection + // method + if (connections.IsEmpty) + { + // there are no connections, either none were opened or + // all of the closings went through CloseConnection. + return false; + } + else + { + // Disposing of an ISession does not call CloseConnection (should it???) + // so a Diposed of ISession will leave an IDbConnection in the list but + // the IDbConnection will be closed (atleast with MsSql it works this way). + foreach (IDbConnection conn in connections) + { + if (conn.State != ConnectionState.Closed) + { + return true; + } + } + + // all of the connections have been Disposed and were closed that way + // or they were Closed through the CloseConnection method. + return false; + } + } + } + + public void CloseAllConnections() + { + while (!connections.IsEmpty) + { + IEnumerator en = connections.GetEnumerator(); + en.MoveNext(); + CloseConnection(en.Current as IDbConnection); + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/DebugConnectionProvider.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Added: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.csproj (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.csproj 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{4972EE96-2417-4D47-9FF1-3B1D6B1D3191}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>NHibernate.ProxyGenerators.CastleDynamicProxy.Tests</RootNamespace> + <AssemblyName>NHibernate.ProxyGenerators.CastleDynamicProxy.Tests</AssemblyName> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\Castle.Core.dll</HintPath> + </Reference> + <Reference Include="Castle.DynamicProxy2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\Castle.DynamicProxy2.dll</HintPath> + </Reference> + <Reference Include="Iesi.Collections, Version=1.0.0.3, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\Iesi.Collections.dll</HintPath> + </Reference> + <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\log4net.dll</HintPath> + </Reference> + <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\nunit.framework.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="DebugConnectionProvider.cs" /> + <Compile Include="AssemblyInfo.cs" /> + <Compile Include="ProxyInterface\CastleProxy.cs" /> + <Compile Include="ProxyInterface\CastleProxyFixture.cs" /> + <Compile Include="ProxyInterface\CastleProxyImpl.cs" /> + <Compile Include="ProxyInterface\Classes.cs" /> + <Compile Include="ProxyInterface\CustomProxyFixture.cs" /> + <Compile Include="TestCase.cs" /> + <Compile Include="TestConfigurationHelper.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\NHibernate.ProxyGenerators.CastleDynamicProxy\NHibernate.ProxyGenerators.CastleDynamicProxy.csproj"> + <Project>{31C3F0EA-0FED-4A2F-B68D-96CE29844487}</Project> + <Name>NHibernate.ProxyGenerators.CastleDynamicProxy</Name> + </ProjectReference> + <ProjectReference Include="..\NHibernate\NHibernate.csproj"> + <Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project> + <Name>NHibernate</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="ProxyInterface\CastleProxyImpl.hbm.xml" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="ProxyInterface\Mappings.hbm.xml" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="ProxyGenerators.Test.build" /> + </ItemGroup> + <ItemGroup> + <Folder Include="Properties\" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <PropertyGroup> + <PostBuildEvent>if exist hibernate.cfg.xml (del hibernate.cfg.xml) +if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")</PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build (from rev 3844, trunk/nhibernate/src/Iesi.Collections.Test/Iesi.Collections.Test.build) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,41 @@ +<?xml version="1.0" ?> + +<project + name="NHibernate.ProxyGenerators.CastleDynamicProxy.Tests" + default="build" + xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd" +> + + <property name="root.dir" value="../.." /> + + <include buildfile="${root.dir}/build-common/common-project.xml" /> + + <target name="init" depends="common.init"> + + <property name="assembly.is-cls-compliant" value="false" /> + <property name="assembly.description" value="The Unit Tests for Castle ProxyGenerators." /> + <property name="assembly.version" value="1.0.0.1" /> + <property name="assembly.version.informational" value="1.0" /> + + <property name="clover.instrument" value="false" /> + + <assemblyfileset id="project.references" basedir="${bin.dir}"> + <include name="System.dll" /> + <include name="System.XML.dll" /> + <include name="System.Data.dll" /> + <include name="Iesi.Collections.dll" /> + <include name="log4net.dll" /> + <include name="Castle.Core.dll" /> + <include name="Castle.DynamicProxy2.dll" /> + <include name="NHibernate.dll" /> + <include name="NHibernate.ProxyGenerators.CastleDynamicProxy.dll" /> + <include name="nunit.framework.dll"/> + </assemblyfileset> + + </target> + + <target name="generate-assemblyinfo" depends="init common.generate-assemblyinfo" /> + <target name="build" depends="init generate-assemblyinfo common.compile-tests" /> + <target name="test" depends="init build common.run-tests" /> + +</project> Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyGenerators.Test.build ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxy.cs (from rev 3844, trunk/nhibernate/src/NHibernate.Test/ProxyInterface/CastleProxy.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxy.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxy.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,14 @@ +namespace NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.ProxyInterface +{ + /// <summary> + /// Summary description for CastleProxy. + /// </summary> + public interface CastleProxy + { + int Id { get; set; } + + string Name { get; set; } + + void ThrowDeepException(); + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxy.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyFixture.cs (from rev 3844, trunk/nhibernate/src/NHibernate.Test/ProxyInterface/CastleProxyFixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyFixture.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,144 @@ +using System; +using System.Collections; +using System.IO; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Binary; +using NUnit.Framework; + +namespace NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.ProxyInterface +{ + /// <summary> + /// Summary description for CastleProxyFixture. + /// </summary> + [TestFixture] + public class CastleProxyFixture : TestCase + { + protected override IList Mappings + { + get { return new[] {"ProxyInterface.CastleProxyImpl.hbm.xml"}; } + } + + [Test] + public void Proxy() + { + ISession s = OpenSession(); + CastleProxy ap = new CastleProxyImpl {Id = 1, Name = "first proxy"}; + s.Save(ap); + s.Flush(); + s.Close(); + + s = OpenSession(); + ap = (CastleProxy) s.Load(typeof (CastleProxyImpl), ap.Id); + Assert.IsFalse(NHibernateUtil.IsInitialized(ap)); + int id = ap.Id; + Assert.IsFalse(NHibernateUtil.IsInitialized(ap), "get id should not have initialized it."); + string name = ap.Name; + Assert.IsTrue(NHibernateUtil.IsInitialized(ap), "get name should have initialized it."); + s.Delete(ap); + s.Flush(); + s.Close(); + } + + private void SerializeAndDeserialize(ref ISession s) + { + // Serialize the session + using (Stream stream = new MemoryStream()) + { + IFormatter formatter = new BinaryFormatter(); + formatter.Serialize(stream, s); + + // Close the original session + s.Close(); + + // Deserialize the session + stream.Position = 0; + s = (ISession) formatter.Deserialize(stream); + } + } + + [Test] + public void ProxySerialize() + { + ISession s = OpenSession(); + CastleProxy ap = new CastleProxyImpl(); + ap.Id = 1; + ap.Name = "first proxy"; + s.Save(ap); + s.Flush(); + s.Close(); + + s = OpenSession(); + ap = (CastleProxy) s.Load(typeof (CastleProxyImpl), ap.Id); + Assert.AreEqual(1, ap.Id); + s.Disconnect(); + + SerializeAndDeserialize(ref s); + + s.Reconnect(); + s.Disconnect(); + + // serialize and then deserialize the session again - make sure Castle.DynamicProxy + // has no problem with serializing two times - earlier versions of it did. + SerializeAndDeserialize(ref s); + + s.Close(); + + s = OpenSession(); + s.Delete(ap); + s.Flush(); + s.Close(); + } + + [Test] + public void SerializeNotFoundProxy() + { + ISession s = OpenSession(); + // this does not actually exists in db + var notThere = (CastleProxy) s.Load(typeof (CastleProxyImpl), 5); + Assert.AreEqual(5, notThere.Id); + s.Disconnect(); + + // serialize and then deserialize the session. + SerializeAndDeserialize(ref s); + + Assert.IsNotNull(s.Load(typeof (CastleProxyImpl), 5), "should be proxy - even though it doesn't exists in db"); + s.Close(); + } + + [Test] + public void ExceptionStackTrace() + { + ISession s = OpenSession(); + CastleProxy ap = new CastleProxyImpl(); + ap.Id = 1; + ap.Name = "first proxy"; + s.Save(ap); + s.Flush(); + s.Close(); + + s = OpenSession(); + ap = (CastleProxy) s.Load(typeof (CastleProxyImpl), ap.Id); + Assert.IsFalse(NHibernateUtil.IsInitialized(ap), "check we have a proxy"); + + try + { + ap.ThrowDeepException(); + Assert.Fail("Exception not thrown"); + } + catch (ArgumentException ae) + { + Assert.AreEqual("thrown from Level2", ae.Message); + + string[] stackTraceLines = ae.StackTrace.Split('\n'); + Assert.IsTrue(stackTraceLines[0].Contains("Level2"), "top of exception stack is Level2()"); + Assert.IsTrue(stackTraceLines[1].Contains("Level1"), "next on exception stack is Level1()"); + } + finally + { + s.Delete(ap); + s.Flush(); + s.Close(); + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyFixture.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.cs (from rev 3844, trunk/nhibernate/src/NHibernate.Test/ProxyInterface/CastleProxyImpl.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,35 @@ +using System; +using NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.ProxyInterface; + +namespace NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.ProxyInterface +{ + /// <summary> + /// Summary description for CastleProxyImpl. + /// </summary> + [Serializable] + public class CastleProxyImpl : CastleProxy + { + private static void Level1() + { + Level2(); + } + + private static void Level2() + { + throw new ArgumentException("thrown from Level2"); + } + + #region CastleProxy Members + + public int Id { get; set; } + + public string Name { get; set; } + + public void ThrowDeepException() + { + Level1(); + } + + #endregion + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.cs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.hbm.xml (from rev 3844, trunk/nhibernate/src/NHibernate.Test/ProxyInterface/CastleProxyImpl.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.hbm.xml 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.ProxyGenerators.CastleDynamicProxy.Tests" + namespace="NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.ProxyInterface"> + <class name="CastleProxyImpl" proxy="CastleProxy" table="avalon_p"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + </class> +</hibernate-mapping> Property changes on: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/CastleProxyImpl.hbm.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/Classes.cs (from rev 3844, trunk/nhibernate/src/NHibernate.Test/ExpressionTest/SubQueries/Classes.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/Classes.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.ProxyGenerators.CastleDynamicProxy.Tests/ProxyInterface/Classes.cs 2008-10-11 22:25:44 UTC (rev 3850) @@ -0,0 +1,212 @@ +using System.Collections; +using Iesi.Collections; + +namespace NHibernate.ProxyGenerators.CastleDynamicProxy.Tests.ProxyInterface +{ + public class Blog + { + private ISet _posts; + private ISet _users; + + private int blog_id; + + public virtual int BlogID + { + get { return blog_id; } + set { blog_id = value; } + } + + private string blog_name; + + public virtual string BlogName + { + get { return blog_name; } + set { blog_name = value; } + } + + public virtual ISet Posts + { + get { return _posts; } + set { _posts = value; } + } + + public virtual ISet Users + { + get { return _users; } + set { _users = value; } + } + + public Blog() + { + _posts = new HashedSet(); + _users = new HashedSet(); + } + + public Blog(string name) : this() + { + blog_name = name; + } + } + + public class Comment + { + private Comment() {} + + public Comment(string text) : this() + { + _text = text; + } + + private int _id; + private int _indexInPost; + private string _text; + private Post _post; + private User commenter; + + public User Commenter + { + get { return commenter; } + set { commenter = value; } + } + + public virtual int IndexInPost + { + get { return _indexInPost; } + set { _indexInPost = value; } + } + + public virtual Post Post + { + get { return _post; } + set { _post = value; } + } + + public virtual int CommentId + { + get { return _id; } + set { _id = value; } + } + + public virtual string Text + { + get { return _text; } + set { _text = value; } + } + } + + public class Post + { + private int post_id; + private Blog _blog; + private string post_title; + private IList _comments; + private ISet categories = new HashedSet(); + + public ISet Categories + { + get { return c... [truncated message content] |
From: <fab...@us...> - 2008-10-11 21:37:37
|
Revision: 3849 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3849&view=rev Author: fabiomaulo Date: 2008-10-11 21:37:31 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Fixed file version number (because OrderedSet) and actualized common lib Modified Paths: -------------- trunk/nhibernate/lib/net/2.0/Iesi.Collections.dll trunk/nhibernate/lib/net/2.0/Iesi.Collections.xml trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.build trunk/nhibernate/src/Iesi.Collections.Test/Iesi.Collections.Test.build Modified: trunk/nhibernate/lib/net/2.0/Iesi.Collections.xml =================================================================== --- trunk/nhibernate/lib/net/2.0/Iesi.Collections.xml 2008-10-11 21:22:21 UTC (rev 3848) +++ trunk/nhibernate/lib/net/2.0/Iesi.Collections.xml 2008-10-11 21:37:31 UTC (rev 3849) @@ -152,42 +152,42 @@ </member> <member name="M:Iesi.Collections.Generic.ISet`1.ContainsAll(System.Collections.Generic.ICollection{`0})"> <summary> - Returns <c>true</c> if the set contains all the elements in the specified collection. + Returns <see langword="true" /> if the set contains all the elements in the specified collection. </summary> <param name="c">A collection of objects.</param> - <returns><c>true</c> if the set contains all the elements in the specified collection, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.ISet`1.Add(`0)"> <summary> Adds the specified element to this set if it is not already present. </summary> <param name="o">The object to add to the set.</param> - <returns><c>true</c> is the object was added, <c>false</c> if it was already present.</returns> + <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns> </member> <member name="M:Iesi.Collections.Generic.ISet`1.AddAll(System.Collections.Generic.ICollection{`0})"> <summary> Adds all the elements in the specified collection to the set if they are not already present. </summary> <param name="c">A collection of objects to add to the set.</param> - <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns> + <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns> </member> <member name="M:Iesi.Collections.Generic.ISet`1.RemoveAll(System.Collections.Generic.ICollection{`0})"> <summary> Remove all the specified elements from this set, if they exist in this set. </summary> <param name="c">A collection of elements to remove.</param> - <returns><c>true</c> if the set was modified as a result of this operation.</returns> + <returns><see langword="true" /> if the set was modified as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Generic.ISet`1.RetainAll(System.Collections.Generic.ICollection{`0})"> <summary> Retains only the elements in this set that are contained in the specified collection. </summary> <param name="c">Collection that defines the set of elements to be retained.</param> - <returns><c>true</c> if this set changed as a result of this operation.</returns> + <returns><see langword="true" /> if this set changed as a result of this operation.</returns> </member> <member name="P:Iesi.Collections.Generic.ISet`1.IsEmpty"> <summary> - Returns <c>true</c> if this set contains no elements. + Returns <see langword="true" /> if this set contains no elements. </summary> </member> <member name="T:Iesi.Collections.ISet"> @@ -274,52 +274,52 @@ </member> <member name="M:Iesi.Collections.ISet.Contains(System.Object)"> <summary> - Returns <c>true</c> if this set contains the specified element. + Returns <see langword="true" /> if this set contains the specified element. </summary> <param name="o">The element to look for.</param> - <returns><c>true</c> if this set contains the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.ISet.ContainsAll(System.Collections.ICollection)"> <summary> - Returns <c>true</c> if the set contains all the elements in the specified collection. + Returns <see langword="true" /> if the set contains all the elements in the specified collection. </summary> <param name="c">A collection of objects.</param> - <returns><c>true</c> if the set contains all the elements in the specified collection, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.ISet.Add(System.Object)"> <summary> Adds the specified element to this set if it is not already present. </summary> <param name="o">The object to add to the set.</param> - <returns><c>true</c> is the object was added, <c>false</c> if it was already present.</returns> + <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns> </member> <member name="M:Iesi.Collections.ISet.AddAll(System.Collections.ICollection)"> <summary> Adds all the elements in the specified collection to the set if they are not already present. </summary> <param name="c">A collection of objects to add to the set.</param> - <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns> + <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns> </member> <member name="M:Iesi.Collections.ISet.Remove(System.Object)"> <summary> Removes the specified element from the set. </summary> <param name="o">The element to be removed.</param> - <returns><c>true</c> if the set contained the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.ISet.RemoveAll(System.Collections.ICollection)"> <summary> Remove all the specified elements from this set, if they exist in this set. </summary> <param name="c">A collection of elements to remove.</param> - <returns><c>true</c> if the set was modified as a result of this operation.</returns> + <returns><see langword="true" /> if the set was modified as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.ISet.RetainAll(System.Collections.ICollection)"> <summary> Retains only the elements in this set that are contained in the specified collection. </summary> <param name="c">Collection that defines the set of elements to be retained.</param> - <returns><c>true</c> if this set changed as a result of this operation.</returns> + <returns><see langword="true" /> if this set changed as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.ISet.Clear"> <summary> @@ -328,7 +328,7 @@ </member> <member name="P:Iesi.Collections.ISet.IsEmpty"> <summary> - Returns <c>true</c> if this set contains no elements. + Returns <see langword="true" /> if this set contains no elements. </summary> </member> <member name="M:Iesi.Collections.Generic.Set`1.Union(Iesi.Collections.Generic.ISet{`0})"> @@ -346,23 +346,23 @@ <summary> Performs a "union" of two sets, where all the elements in both are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>. - The return value is a <c>Clone()</c> of one of the sets (<c>a</c> if it is not <c>null</c>) with elements of the other set + The return value is a <c>Clone()</c> of one of the sets (<c>a</c> if it is not <see langword="null" />) with elements of the other set added in. Neither of the input sets is modified by the operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing the union of the input sets. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>A set containing the union of the input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.op_BitwiseOr(Iesi.Collections.Generic.Set{`0},Iesi.Collections.Generic.Set{`0})"> <summary> Performs a "union" of two sets, where all the elements in both are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>. - The return value is a <c>Clone()</c> of one of the sets (<c>a</c> if it is not <c>null</c>) with elements of the other set + The return value is a <c>Clone()</c> of one of the sets (<c>a</c> if it is not <see langword="null" />) with elements of the other set added in. Neither of the input sets is modified by the operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing the union of the input sets. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>A set containing the union of the input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.Intersect(Iesi.Collections.Generic.ISet{`0})"> <summary> @@ -379,24 +379,24 @@ Performs an "intersection" of the two sets, where only the elements that are present in both sets remain. That is, the element is included only if it exists in both <c>a</c> and <c>b</c>. Neither input object is modified by the operation. - The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <c>null</c>) containing the + The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <see langword="null" />) containing the elements from the intersect operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>The intersection of the two input sets. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>The intersection of the two input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.op_BitwiseAnd(Iesi.Collections.Generic.Set{`0},Iesi.Collections.Generic.Set{`0})"> <summary> Performs an "intersection" of the two sets, where only the elements that are present in both sets remain. That is, the element is included only if it exists in both <c>a</c> and <c>b</c>. Neither input object is modified by the operation. - The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <c>null</c>) containing the + The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <see langword="null" />) containing the elements from the intersect operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>The intersection of the two input sets. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>The intersection of the two input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.Minus(Iesi.Collections.Generic.ISet{`0})"> <summary> @@ -417,7 +417,7 @@ </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing <c>A - B</c> elements. <c>null</c> if <c>a</c> is <c>null</c>.</returns> + <returns>A set containing <c>A - B</c> elements. <see langword="null" /> if <c>a</c> is <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.op_Subtraction(Iesi.Collections.Generic.Set{`0},Iesi.Collections.Generic.Set{`0})"> <summary> @@ -428,7 +428,7 @@ </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing <c>A - B</c> elements. <c>null</c> if <c>a</c> is <c>null</c>.</returns> + <returns>A set containing <c>A - B</c> elements. <see langword="null" /> if <c>a</c> is <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.ExclusiveOr(Iesi.Collections.Generic.ISet{`0})"> <summary> @@ -445,38 +445,38 @@ Performs an "exclusive-or" of the two sets, keeping only the elements that are in one of the sets, but not in both. The original sets are not modified during this operation. The result set is a <c>Clone()</c> of one of the sets - (<c>a</c> if it is not <c>null</c>) containing + (<c>a</c> if it is not <see langword="null" />) containing the elements from the exclusive-or operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing the result of <c>a ^ b</c>. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>A set containing the result of <c>a ^ b</c>. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.op_ExclusiveOr(Iesi.Collections.Generic.Set{`0},Iesi.Collections.Generic.Set{`0})"> <summary> Performs an "exclusive-or" of the two sets, keeping only the elements that are in one of the sets, but not in both. The original sets are not modified during this operation. The result set is a <c>Clone()</c> of one of the sets - (<c>a</c> if it is not <c>null</c>) containing + (<c>a</c> if it is not <see langword="null" />) containing the elements from the exclusive-or operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing the result of <c>a ^ b</c>. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>A set containing the result of <c>a ^ b</c>. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.Add(`0)"> <summary> Adds the specified element to this set if it is not already present. </summary> <param name="o">The object to add to the set.</param> - <returns><c>true</c> is the object was added, <c>false</c> if it was already present.</returns> + <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.AddAll(System.Collections.Generic.ICollection{`0})"> <summary> Adds all the elements in the specified collection to the set if they are not already present. </summary> <param name="c">A collection of objects to add to the set.</param> - <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns> + <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.Clear"> <summary> @@ -485,38 +485,38 @@ </member> <member name="M:Iesi.Collections.Generic.Set`1.Contains(`0)"> <summary> - Returns <c>true</c> if this set contains the specified element. + Returns <see langword="true" /> if this set contains the specified element. </summary> <param name="o">The element to look for.</param> - <returns><c>true</c> if this set contains the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.ContainsAll(System.Collections.Generic.ICollection{`0})"> <summary> - Returns <c>true</c> if the set contains all the elements in the specified collection. + Returns <see langword="true" /> if the set contains all the elements in the specified collection. </summary> <param name="c">A collection of objects.</param> - <returns><c>true</c> if the set contains all the elements in the specified collection, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.Remove(`0)"> <summary> Removes the specified element from the set. </summary> <param name="o">The element to be removed.</param> - <returns><c>true</c> if the set contained the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.RemoveAll(System.Collections.Generic.ICollection{`0})"> <summary> Remove all the specified elements from this set, if they exist in this set. </summary> <param name="c">A collection of elements to remove.</param> - <returns><c>true</c> if the set was modified as a result of this operation.</returns> + <returns><see langword="true" /> if the set was modified as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.RetainAll(System.Collections.Generic.ICollection{`0})"> <summary> Retains only the elements in this set that are contained in the specified collection. </summary> <param name="c">Collection that defines the set of elements to be retained.</param> - <returns><c>true</c> if this set changed as a result of this operation.</returns> + <returns><see langword="true" /> if this set changed as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Generic.Set`1.Clone"> <summary> @@ -576,7 +576,7 @@ </member> <member name="P:Iesi.Collections.Generic.Set`1.IsEmpty"> <summary> - Returns <c>true</c> if this set contains no elements. + Returns <see langword="true" /> if this set contains no elements. </summary> </member> <member name="P:Iesi.Collections.Generic.Set`1.Count"> @@ -586,7 +586,7 @@ </member> <member name="P:Iesi.Collections.Generic.Set`1.IsSynchronized"> <summary> - Returns <c>true</c> if the <c>Set</c> is synchronized across threads. Note that + Returns <see langword="true" /> if the <c>Set</c> is synchronized across threads. Note that enumeration is inherently not thread-safe. Use the <c>SyncRoot</c> to lock the object during enumeration. </summary> @@ -603,7 +603,7 @@ Indicates whether the given instance is read-only or not </summary> <value> - <c>true</c> if the ISet is read-only; otherwise, <c>false</c>. + <see langword="true" /> if the ISet is read-only; otherwise, <see langword="false" />. In the default implementation of Set, this property always returns false. </value> </member> @@ -619,14 +619,14 @@ Adds the specified element to this set if it is not already present. </summary> <param name="o">The <typeparamref name="T"/> to add to the set.</param> - <returns><c>true</c> is the object was added, <c>false</c> if it was already present.</returns> + <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns> </member> <member name="M:Iesi.Collections.Generic.DictionarySet`1.AddAll(System.Collections.Generic.ICollection{`0})"> <summary> Adds all the elements in the specified collection to the set if they are not already present. </summary> <param name="c">A collection of objects to add to the set.</param> - <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns> + <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns> </member> <member name="M:Iesi.Collections.Generic.DictionarySet`1.Clear"> <summary> @@ -635,38 +635,38 @@ </member> <member name="M:Iesi.Collections.Generic.DictionarySet`1.Contains(`0)"> <summary> - Returns <c>true</c> if this set contains the specified element. + Returns <see langword="true" /> if this set contains the specified element. </summary> <param name="o">The element to look for.</param> - <returns><c>true</c> if this set contains the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.DictionarySet`1.ContainsAll(System.Collections.Generic.ICollection{`0})"> <summary> - Returns <c>true</c> if the set contains all the elements in the specified collection. + Returns <see langword="true" /> if the set contains all the elements in the specified collection. </summary> <param name="c">A collection of objects.</param> - <returns><c>true</c> if the set contains all the elements in the specified collection, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.DictionarySet`1.Remove(`0)"> <summary> Removes the specified element from the set. </summary> <param name="o">The element to be removed.</param> - <returns><c>true</c> if the set contained the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.DictionarySet`1.RemoveAll(System.Collections.Generic.ICollection{`0})"> <summary> Remove all the specified elements from this set, if they exist in this set. </summary> <param name="c">A collection of elements to remove.</param> - <returns><c>true</c> if the set was modified as a result of this operation.</returns> + <returns><see langword="true" /> if the set was modified as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Generic.DictionarySet`1.RetainAll(System.Collections.Generic.ICollection{`0})"> <summary> Retains only the elements in this set that are contained in the specified collection. </summary> <param name="c">Collection that defines the set of elements to be retained.</param> - <returns><c>true</c> if this set changed as a result of this operation.</returns> + <returns><see langword="true" /> if this set changed as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Generic.DictionarySet`1.CopyTo(`0[],System.Int32)"> <summary> @@ -701,7 +701,7 @@ </member> <member name="P:Iesi.Collections.Generic.DictionarySet`1.IsEmpty"> <summary> - Returns <c>true</c> if this set contains no elements. + Returns <see langword="true" /> if this set contains no elements. </summary> </member> <member name="P:Iesi.Collections.Generic.DictionarySet`1.Count"> @@ -784,17 +784,17 @@ </member> <member name="M:Iesi.Collections.Generic.ImmutableSet`1.Contains(`0)"> <summary> - Returns <c>true</c> if this set contains the specified element. + Returns <see langword="true" /> if this set contains the specified element. </summary> <param name="o">The element to look for.</param> - <returns><c>true</c> if this set contains the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.ImmutableSet`1.ContainsAll(System.Collections.Generic.ICollection{`0})"> <summary> - Returns <c>true</c> if the set contains all the elements in the specified collection. + Returns <see langword="true" /> if the set contains all the elements in the specified collection. </summary> <param name="c">A collection of objects.</param> - <returns><c>true</c> if the set contains all the elements in the specified collection, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.ImmutableSet`1.Remove(`0)"> <summary> @@ -918,7 +918,7 @@ </member> <member name="P:Iesi.Collections.Generic.ImmutableSet`1.IsEmpty"> <summary> - Returns <c>true</c> if this set contains no elements. + Returns <see langword="true" /> if this set contains no elements. </summary> </member> <member name="P:Iesi.Collections.Generic.ImmutableSet`1.Count"> @@ -941,6 +941,22 @@ Indicates that the given instance is read-only </summary> </member> + <member name="T:Iesi.Collections.Generic.OrderedSet`1"> + <summary> + Implements an ordered <c>Set</c> based on a dictionary. + </summary> + </member> + <member name="M:Iesi.Collections.Generic.OrderedSet`1.#ctor"> + <summary> + Initializes a new instance of the <see cref="T:Iesi.Collections.Generic.OrderedSet`1"/> class. + </summary> + </member> + <member name="M:Iesi.Collections.Generic.OrderedSet`1.#ctor(System.Collections.Generic.ICollection{`0})"> + <summary> + Initializes a new instance of the <see cref="T:Iesi.Collections.Generic.OrderedSet`1"/> class. + </summary> + <param name="initialValues">A collection of elements that defines the initial set contents.</param> + </member> <member name="T:Iesi.Collections.Generic.SortedSet`1"> <summary> Implements a <c>Set</c> based on a sorted tree. This gives good performance for operations on very @@ -1001,14 +1017,14 @@ Adds the specified element to this set if it is not already present. </summary> <param name="o">The object to add to the set.</param> - <returns><c>true</c> is the object was added, <c>false</c> if it was already present.</returns> + <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns> </member> <member name="M:Iesi.Collections.Generic.SynchronizedSet`1.AddAll(System.Collections.Generic.ICollection{`0})"> <summary> Adds all the elements in the specified collection to the set if they are not already present. </summary> <param name="c">A collection of objects to add to the set.</param> - <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns> + <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns> </member> <member name="M:Iesi.Collections.Generic.SynchronizedSet`1.Clear"> <summary> @@ -1017,38 +1033,38 @@ </member> <member name="M:Iesi.Collections.Generic.SynchronizedSet`1.Contains(`0)"> <summary> - Returns <c>true</c> if this set contains the specified element. + Returns <see langword="true" /> if this set contains the specified element. </summary> <param name="o">The element to look for.</param> - <returns><c>true</c> if this set contains the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.SynchronizedSet`1.ContainsAll(System.Collections.Generic.ICollection{`0})"> <summary> - Returns <c>true</c> if the set contains all the elements in the specified collection. + Returns <see langword="true" /> if the set contains all the elements in the specified collection. </summary> <param name="c">A collection of objects.</param> - <returns><c>true</c> if the set contains all the elements in the specified collection, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.SynchronizedSet`1.Remove(`0)"> <summary> Removes the specified element from the set. </summary> <param name="o">The element to be removed.</param> - <returns><c>true</c> if the set contained the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Generic.SynchronizedSet`1.RemoveAll(System.Collections.Generic.ICollection{`0})"> <summary> Remove all the specified elements from this set, if they exist in this set. </summary> <param name="c">A collection of elements to remove.</param> - <returns><c>true</c> if the set was modified as a result of this operation.</returns> + <returns><see langword="true" /> if the set was modified as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Generic.SynchronizedSet`1.RetainAll(System.Collections.Generic.ICollection{`0})"> <summary> Retains only the elements in this set that are contained in the specified collection. </summary> <param name="c">Collection that defines the set of elements to be retained.</param> - <returns><c>true</c> if this set changed as a result of this operation.</returns> + <returns><see langword="true" /> if this set changed as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Generic.SynchronizedSet`1.CopyTo(`0[],System.Int32)"> <summary> @@ -1080,7 +1096,7 @@ </member> <member name="P:Iesi.Collections.Generic.SynchronizedSet`1.IsEmpty"> <summary> - Returns <c>true</c> if this set contains no elements. + Returns <see langword="true" /> if this set contains no elements. </summary> </member> <member name="P:Iesi.Collections.Generic.SynchronizedSet`1.Count"> @@ -1090,7 +1106,7 @@ </member> <member name="P:Iesi.Collections.Generic.SynchronizedSet`1.IsSynchronized"> <summary> - Returns <c>true</c>, indicating that this object is thread-safe. The exception to this + Returns <see langword="true" />, indicating that this object is thread-safe. The exception to this is enumeration, which is inherently not thread-safe. Use the <c>SyncRoot</c> object to lock this object for the entire duration of the enumeration. </summary> @@ -1125,15 +1141,22 @@ </summary> </member> <member name="T:Iesi.Collections.Set"> - <summary><p>A collection that contains no duplicate elements. This class models the mathematical - <c>Set</c> abstraction, and is the base class for all other <c>Set</c> implementations. - The order of elements in a set is dependant on (a)the data-structure implementation, and - (b)the implementation of the various <c>Set</c> methods, and thus is not guaranteed.</p> - - <p>None of the <c>Set</c> implementations in this library are guranteed to be thread-safe - in any way unless wrapped in a <c>SynchronizedSet</c>.</p> - - <p>The following table summarizes the binary operators that are supported by the <c>Set</c> class.</p> + <summary>A collection that contains no duplicate elements.</summary> + <remarks> + <para> + This class models the mathematical set abstraction, and is the base class for all + other set implementations. The order of elements in a set is dependant on + (a) the data-structure implementation, and (b) the implementation of the various + methods, and thus is not guaranteed. + </para> + <para> + None of the <see cref="T:Iesi.Collections.ISet"/> implementations in this library are guranteed to be thread-safe + in any way unless wrapped in a <see cref="T:Iesi.Collections.SynchronizedSet"/>. + </para> + <para> + The following table summarizes the binary operators that are supported by the <see cref="T:Iesi.Collections.ISet"/> + type. + </para> <list type="table"> <listheader> <term>Operation</term> @@ -1167,40 +1190,40 @@ <term><c>-</c></term> </item> </list> - </summary> + </remarks> </member> <member name="M:Iesi.Collections.Set.Union(Iesi.Collections.ISet)"> <summary> Performs a "union" of the two sets, where all the elements in both sets are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>. Neither this set nor the input set are modified during the operation. The return value - is a <c>Clone()</c> of this set with the extra elements added in. + is a clone of this set with the extra elements added in. </summary> <param name="a">A collection of elements.</param> - <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection. + <returns>A new <see cref="T:Iesi.Collections.ISet"/> instance containing the union of this instance with the specified collection. Neither of the input objects is modified by the union.</returns> </member> <member name="M:Iesi.Collections.Set.Union(Iesi.Collections.ISet,Iesi.Collections.ISet)"> <summary> Performs a "union" of two sets, where all the elements in both are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>. - The return value is a <c>Clone()</c> of one of the sets (<c>a</c> if it is not <c>null</c>) with elements of the other set + The return value is a clone of one of the sets (<c>a</c> if it is not <see langword="null" />) with elements of the other set added in. Neither of the input sets is modified by the operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing the union of the input sets. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>A set containing the union of the input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Set.op_BitwiseOr(Iesi.Collections.Set,Iesi.Collections.Set)"> <summary> Performs a "union" of two sets, where all the elements in both are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>. - The return value is a <c>Clone()</c> of one of the sets (<c>a</c> if it is not <c>null</c>) with elements of the other set + The return value is a clone of one of the sets (<c>a</c> if it is not <see langword="null" />) with elements of the other set added in. Neither of the input sets is modified by the operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing the union of the input sets. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>A set containing the union of the input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Set.Intersect(Iesi.Collections.ISet)"> <summary> @@ -1217,24 +1240,24 @@ Performs an "intersection" of the two sets, where only the elements that are present in both sets remain. That is, the element is included only if it exists in both <c>a</c> and <c>b</c>. Neither input object is modified by the operation. - The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <c>null</c>) containing the + The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <see langword="null" />) containing the elements from the intersect operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>The intersection of the two input sets. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>The intersection of the two input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Set.op_BitwiseAnd(Iesi.Collections.Set,Iesi.Collections.Set)"> <summary> Performs an "intersection" of the two sets, where only the elements that are present in both sets remain. That is, the element is included only if it exists in both <c>a</c> and <c>b</c>. Neither input object is modified by the operation. - The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <c>null</c>) containing the + The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <see langword="null" />) containing the elements from the intersect operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>The intersection of the two input sets. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>The intersection of the two input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Set.Minus(Iesi.Collections.ISet)"> <summary> @@ -1255,7 +1278,7 @@ </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing <c>A - B</c> elements. <c>null</c> if <c>a</c> is <c>null</c>.</returns> + <returns>A set containing <c>A - B</c> elements. <see langword="null" /> if <c>a</c> is <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Set.op_Subtraction(Iesi.Collections.Set,Iesi.Collections.Set)"> <summary> @@ -1266,13 +1289,13 @@ </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing <c>A - B</c> elements. <c>null</c> if <c>a</c> is <c>null</c>.</returns> + <returns>A set containing <c>A - B</c> elements. <see langword="null" /> if <c>a</c> is <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Set.ExclusiveOr(Iesi.Collections.ISet)"> <summary> Performs an "exclusive-or" of the two sets, keeping only the elements that are in one of the sets, but not in both. The original sets are not modified - during this operation. The result set is a <c>Clone()</c> of this set containing + during this operation. The result set is a clone of this set containing the elements from the exclusive-or operation. </summary> <param name="a">A set of elements.</param> @@ -1282,39 +1305,39 @@ <summary> Performs an "exclusive-or" of the two sets, keeping only the elements that are in one of the sets, but not in both. The original sets are not modified - during this operation. The result set is a <c>Clone()</c> of one of the sets - (<c>a</c> if it is not <c>null</c>) containing + during this operation. The result set is a clone of one of the sets + (<c>a</c> if it is not <see langword="null" />) containing the elements from the exclusive-or operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing the result of <c>a ^ b</c>. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>A set containing the result of <c>a ^ b</c>. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Set.op_ExclusiveOr(Iesi.Collections.Set,Iesi.Collections.Set)"> <summary> Performs an "exclusive-or" of the two sets, keeping only the elements that are in one of the sets, but not in both. The original sets are not modified - during this operation. The result set is a <c>Clone()</c> of one of the sets - (<c>a</c> if it is not <c>null</c>) containing + during this operation. The result set is a clone of one of the sets + (<c>a</c> if it is not <see langword="null" />) containing the elements from the exclusive-or operation. </summary> <param name="a">A set of elements.</param> <param name="b">A set of elements.</param> - <returns>A set containing the result of <c>a ^ b</c>. <c>null</c> if both sets are <c>null</c>.</returns> + <returns>A set containing the result of <c>a ^ b</c>. <see langword="null" /> if both sets are <see langword="null" />.</returns> </member> <member name="M:Iesi.Collections.Set.Add(System.Object)"> <summary> Adds the specified element to this set if it is not already present. </summary> <param name="o">The object to add to the set.</param> - <returns><c>true</c> is the object was added, <c>false</c> if it was already present.</returns> + <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns> </member> <member name="M:Iesi.Collections.Set.AddAll(System.Collections.ICollection)"> <summary> Adds all the elements in the specified collection to the set if they are not already present. </summary> <param name="c">A collection of objects to add to the set.</param> - <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns> + <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns> </member> <member name="M:Iesi.Collections.Set.Clear"> <summary> @@ -1323,63 +1346,65 @@ </member> <member name="M:Iesi.Collections.Set.Contains(System.Object)"> <summary> - Returns <c>true</c> if this set contains the specified element. + Returns <see langword="true" /> if this set contains the specified element. </summary> <param name="o">The element to look for.</param> - <returns><c>true</c> if this set contains the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Set.ContainsAll(System.Collections.ICollection)"> <summary> - Returns <c>true</c> if the set contains all the elements in the specified collection. + Returns <see langword="true" /> if the set contains all the elements in the specified collection. </summary> <param name="c">A collection of objects.</param> - <returns><c>true</c> if the set contains all the elements in the specified collection, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Set.Remove(System.Object)"> <summary> Removes the specified element from the set. </summary> <param name="o">The element to be removed.</param> - <returns><c>true</c> if the set contained the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.Set.RemoveAll(System.Collections.ICollection)"> <summary> Remove all the specified elements from this set, if they exist in this set. </summary> <param name="c">A collection of elements to remove.</param> - <returns><c>true</c> if the set was modified as a result of this operation.</returns> + <returns><see langword="true" /> if the set was modified as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Set.RetainAll(System.Collections.ICollection)"> <summary> Retains only the elements in this set that are contained in the specified collection. </summary> <param name="c">Collection that defines the set of elements to be retained.</param> - <returns><c>true</c> if this set changed as a result of this operation.</returns> + <returns><see langword="true" /> if this set changed as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.Set.Clone"> <summary> - Returns a clone of the <c>Set</c> instance. This will work for derived <c>Set</c> + Returns a clone of the set instance. This will work for derived set classes if the derived class implements a constructor that takes no arguments. </summary> <returns>A clone of this object.</returns> </member> <member name="M:Iesi.Collections.Set.CopyTo(System.Array,System.Int32)"> <summary> - Copies the elements in the <c>Set</c> to an array. The type of array needs - to be compatible with the objects in the <c>Set</c>, obviously. + Copies the elements in the set to an array. The type of array needs + to be compatible with the objects in the set, obviously. </summary> <param name="array">An array that will be the target of the copy operation.</param> <param name="index">The zero-based index where copying will start.</param> </member> <member name="M:Iesi.Collections.Set.GetEnumerator"> <summary> - Gets an enumerator for the elements in the <c>Set</c>. + Returns an enumerator that iterates through the set. </summary> - <returns>An <c>IEnumerator</c> over the elements in the <c>Set</c>.</returns> + <returns> + An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the set. + </returns> </member> <member name="P:Iesi.Collections.Set.IsEmpty"> <summary> - Returns <c>true</c> if this set contains no elements. + Returns <see langword="true" /> if this set contains no elements. </summary> </member> <member name="P:Iesi.Collections.Set.Count"> @@ -1389,16 +1414,17 @@ </member> <member name="P:Iesi.Collections.Set.IsSynchronized"> <summary> - Returns <c>true</c> if the <c>Set</c> is synchronized across threads. Note that - enumeration is inherently not thread-safe. Use the <c>SyncRoot</c> to lock the + Returns <see langword="true"/> if the set is synchronized across threads. Note that + enumeration is inherently not thread-safe. Use the <see cref="P:Iesi.Collections.Set.SyncRoot"/> to lock the object during enumeration. </summary> </member> <member name="P:Iesi.Collections.Set.SyncRoot"> <summary> An object that can be used to synchronize this collection to make it thread-safe. - When implementing this, if your object uses a base object, like an <c>IDictionary</c>, - or anything that has a <c>SyncRoot</c>, return that object instead of "<c>this</c>". + When implementing this, if your object uses a base object, like an <see cref="T:System.Collections.IDictionary"/>, + or anything that has a <see cref="P:Iesi.Collections.Set.SyncRoot"/>, return that object instead + of <see langword="this"/>. </summary> </member> <member name="F:Iesi.Collections.DictionarySet.InternalDictionary"> @@ -1413,14 +1439,14 @@ Adds the specified element to this set if it is not already present. </summary> <param name="o">The object to add to the set.</param> - <returns><c>true</c> is the object was added, <c>false</c> if it was already present.</returns> + <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns> </member> <member name="M:Iesi.Collections.DictionarySet.AddAll(System.Collections.ICollection)"> <summary> Adds all the elements in the specified collection to the set if they are not already present. </summary> <param name="c">A collection of objects to add to the set.</param> - <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns> + <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns> </member> <member name="M:Iesi.Collections.DictionarySet.Clear"> <summary> @@ -1429,38 +1455,38 @@ </member> <member name="M:Iesi.Collections.DictionarySet.Contains(System.Object)"> <summary> - Returns <c>true</c> if this set contains the specified element. + Returns <see langword="true" /> if this set contains the specified element. </summary> <param name="o">The element to look for.</param> - <returns><c>true</c> if this set contains the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.DictionarySet.ContainsAll(System.Collections.ICollection)"> <summary> - Returns <c>true</c> if the set contains all the elements in the specified collection. + Returns <see langword="true" /> if the set contains all the elements in the specified collection. </summary> <param name="c">A collection of objects.</param> - <returns><c>true</c> if the set contains all the elements in the specified collection, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.DictionarySet.Remove(System.Object)"> <summary> Removes the specified element from the set. </summary> <param name="o">The element to be removed.</param> - <returns><c>true</c> if the set contained the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.DictionarySet.RemoveAll(System.Collections.ICollection)"> <summary> Remove all the specified elements from this set, if they exist in this set. </summary> <param name="c">A collection of elements to remove.</param> - <returns><c>true</c> if the set was modified as a result of this operation.</returns> + <returns><see langword="true" /> if the set was modified as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.DictionarySet.RetainAll(System.Collections.ICollection)"> <summary> Retains only the elements in this set that are contained in the specified collection. </summary> <param name="c">Collection that defines the set of elements to be retained.</param> - <returns><c>true</c> if this set changed as a result of this operation.</returns> + <returns><see langword="true" /> if this set changed as a result of this operation.</returns> </member> <member name="M:Iesi.Collections.DictionarySet.CopyTo(System.Array,System.Int32)"> <summary> @@ -1486,7 +1512,7 @@ </member> <member name="P:Iesi.Collections.DictionarySet.IsEmpty"> <summary> - Returns <c>true</c> if this set contains no elements. + Returns <see langword="true" /> if this set contains no elements. </summary> </member> <member name="P:Iesi.Collections.DictionarySet.Count"> @@ -1566,14 +1592,14 @@ Adds the specified element to this set if it is not already present. </summary> <param name="o">The object to add to the set.</param> - <returns><c>true</c> is the object was added, <c>false</c> if it was already present.</returns> + <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns> </member> <member name="M:Iesi.Collections.ImmutableSet.AddAll(System.Collections.ICollection)"> <summary> Adds all the elements in the specified collection to the set if they are not already present. </summary> <param name="c">A collection of objects to add to the set.</param> - <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns> + <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns> </member> <member name="M:Iesi.Collections.ImmutableSet.Clear"> <summary> @@ -1582,38 +1608,38 @@ </member> <member name="M:Iesi.Collections.ImmutableSet.Contains(System.Object)"> <summary> - Returns <c>true</c> if this set contains the specified element. + Returns <see langword="true" /> if this set contains the specified element. </summary> <param name="o">The element to look for.</param> - <returns><c>true</c> if this set contains the specified element, <c>false</c> otherwise.</returns> + <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns> </member> <member name="M:Iesi.Collections.ImmutableSet.ContainsAll(System.Collections.ICollection)"> <summary> ... [truncated message content] |
From: <te...@us...> - 2008-10-11 21:22:31
|
Revision: 3848 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3848&view=rev Author: tehlike Date: 2008-10-11 21:22:21 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Adding overload for SetParameter using System.Type(No Test)(fix 1047) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/IQuery.cs trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs Modified: trunk/nhibernate/src/NHibernate/IQuery.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQuery.cs 2008-10-11 20:25:14 UTC (rev 3847) +++ trunk/nhibernate/src/NHibernate/IQuery.cs 2008-10-11 21:22:21 UTC (rev 3848) @@ -189,7 +189,26 @@ /// <param name="type">The NHibernate <see cref="IType"/>.</param> IQuery SetParameter(string name, object val, IType type); + /// <summary> + /// Bind a value to an indexed parameter. + /// </summary> + /// <param name="position">Position of the parameter in the query, numbered from <c>0</c></param> + /// <param name="val">The possibly null parameter value</param> + /// <param name="type">The System.Type</param> + IQuery SetParameter(int position, object val, System.Type type); + + /// <summary> + /// Bind a value to a named query parameter + /// </summary> + /// <param name="name">The name of the parameter</param> + /// <param name="val">The possibly null parameter value</param> + /// <param name="type">The System.Type.</param> + IQuery SetParameter(string name, object val, System.Type type); + + + + /// <summary> /// Bind a value to an indexed parameter, guessing the Hibernate type from /// the class of the given object. /// </summary> Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2008-10-11 20:25:14 UTC (rev 3847) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2008-10-11 21:22:21 UTC (rev 3848) @@ -322,6 +322,17 @@ } } + public IQuery SetParameter(int position, object val, System.Type type) + { + return SetParameter(position, val, GuessType(type)); + } + + public IQuery SetParameter(string name,object val,System.Type type) + { + return SetParameter(name, val, GuessType(type)); + } + + public IQuery SetParameter(string name, object val) { if (!parameterMetadata.NamedParameterNames.Contains(name)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-10-11 20:25:20
|
Revision: 3847 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3847&view=rev Author: fabiomaulo Date: 2008-10-11 20:25:14 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Fixed version number (because OrderedSet) Modified Paths: -------------- trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.build Modified: trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.build =================================================================== --- trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.build 2008-10-11 20:24:43 UTC (rev 3846) +++ trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.build 2008-10-11 20:25:14 UTC (rev 3847) @@ -16,7 +16,7 @@ value="Enhanced Collections for .NET. Code was published at http://www.codeproject.com/csharp/sets.asp" /> <property name="assembly.copyright" value="Declaration of code in public domain can be found in comment by Jason Smith at http://www.codeproject.com/csharp/sets.asp#xx703510xx. Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith." /> - <property name="assembly.version" value="1.0.0.3" /> + <property name="assembly.version" value="1.0.1.0" /> <property name="assembly.version.informational" value="1.0" /> <property name="assembly.allow-partially-trusted-callers" value="true" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-11 20:24:52
|
Revision: 3846 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3846&view=rev Author: tehlike Date: 2008-10-11 20:24:43 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Adding test to see if Criteria supports Polymorphic queries(see if NH-1033 is an issue) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Animal.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Reptile.cs Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Animal.cs (from rev 3835, trunk/nhibernate/src/NHibernate.Test/Criteria/Animal.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Animal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Animal.cs 2008-10-11 20:24:43 UTC (rev 3846) @@ -0,0 +1,19 @@ +using System; +namespace NHibernate.Test.NHSpecificTest.NH1033 +{ + public class Animal + { + public virtual long Id + { + get; + set; + } + + public virtual string SerialNumber + { + get; + set; + } + + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Animal.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Fixture.cs 2008-10-11 20:24:43 UTC (rev 3846) @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NHibernate.Criterion; +using NUnit.Framework; +using System.Collections; +namespace NHibernate.Test.NHSpecificTest.NH1033 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void OnSetUp() + { + using(var session=OpenSession()) + { + using (var tran = session.BeginTransaction()) + { + + var animal0 = new Animal(); + var animal1 = new Reptile(); + + animal0.SerialNumber = "00001"; + + animal1.SerialNumber = "00002"; + animal1.BodyTemperature = 34; + + session.Save(animal0); + session.Save(animal1); + tran.Commit(); + } + } + } + protected override void OnTearDown() + { + using (var session = OpenSession()) + using (var tran = session.BeginTransaction()) + { + session.Delete("from Animal"); + session.Delete("from Reptile"); + tran.Commit(); + } + } + + [Test] + public void CanUseClassConstraint() + { + using(ISession session=OpenSession()) + { + var crit = session + .CreateCriteria(typeof (Animal), "a") + .Add(Property + .ForName("a.class") + .Eq(typeof(Animal))); + var results = crit.List<Animal>(); + Assert.AreEqual(1,results.Count); + Assert.AreEqual(typeof(Animal), NHibernateUtil.GetClass(results[0])); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Mappings.hbm.xml 2008-10-11 20:24:43 UTC (rev 3846) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1033"> + + <class name="Animal"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="SerialNumber"/> + + <joined-subclass name="Reptile"> + <key column="animal"/> + <property name="BodyTemperature"/> + </joined-subclass> + </class> + +</hibernate-mapping> \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Reptile.cs (from rev 3835, trunk/nhibernate/src/NHibernate.Test/Criteria/Reptile.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Reptile.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Reptile.cs 2008-10-11 20:24:43 UTC (rev 3846) @@ -0,0 +1,14 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1033 +{ + public class Reptile : Animal + { + + public virtual float BodyTemperature + { + get; + set; + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1033/Reptile.cs ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-11 19:17:21 UTC (rev 3845) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-11 20:24:43 UTC (rev 3846) @@ -373,6 +373,9 @@ <Compile Include="NHSpecificTest\CollectionFixture.cs" /> <Compile Include="NHSpecificTest\CriteriaFromHql\Fixture.cs" /> <Compile Include="NHSpecificTest\CriteriaFromHql\Person.cs" /> + <Compile Include="NHSpecificTest\NH1033\Animal.cs" /> + <Compile Include="NHSpecificTest\NH1033\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1033\Reptile.cs" /> <Compile Include="NHSpecificTest\NH1077\A.cs" /> <Compile Include="NHSpecificTest\NH1077\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1098\FilterParameterOrderFixture.cs" /> @@ -1497,6 +1500,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1033\Mappings.hbm.xml" /> <EmbeddedResource Include="EntityModeTest\Multi\Stock.hbm.xml" /> <EmbeddedResource Include="EntityModeTest\Multi\Valuation.hbm.xml" /> <EmbeddedResource Include="EntityModeTest\Xml\Many2One\Car.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-11 19:17:30
|
Revision: 3845 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3845&view=rev Author: tehlike Date: 2008-10-11 19:17:21 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Minor. Removing entityName check to prevent bug mentioned in NH-1322 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Event/DeleteEvent.cs Modified: trunk/nhibernate/src/NHibernate/Event/DeleteEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/DeleteEvent.cs 2008-10-11 17:17:10 UTC (rev 3844) +++ trunk/nhibernate/src/NHibernate/Event/DeleteEvent.cs 2008-10-11 19:17:21 UTC (rev 3845) @@ -26,9 +26,6 @@ public DeleteEvent(string entityName, object entity, IEventSource source) : this(entity, source) { - if (string.IsNullOrEmpty("entityName")) - throw new ArgumentNullException("entityName"); - this.entityName = entityName; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |