|
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] |