From fc3cb1642bbc1ff753561dd96f59c162b62fa178 Mon Sep 17 00:00:00 2001 From: jperrin Date: Thu, 6 Oct 2011 11:14:21 -0500 Subject: [PATCH 01/14] System.Diagnostics.Trace.WriteLine on line 97 of SimpleDelegatingSessionFactory.cs opens a database connection but never closes it. Replaced ((ISessionFactoryImplementor)factory).ConnectionProvider.GetConnection().ConnectionString With local variable: connectionString An example of the unclosed connection can be found at: http://forum.springframework.net/showthread.php?9478-DelegatingLocalSessionFactoryObject-database-connection-leak --- .../SimpleDelegatingSessionFactory.cs | 210 +++++++++--------- 1 file changed, 105 insertions(+), 105 deletions(-) diff --git a/src/Spring/Spring.Data.NHibernate21/Data/NHibernate/SimpleDelegatingSessionFactory.cs b/src/Spring/Spring.Data.NHibernate21/Data/NHibernate/SimpleDelegatingSessionFactory.cs index 658d4fc0..0d62faab 100644 --- a/src/Spring/Spring.Data.NHibernate21/Data/NHibernate/SimpleDelegatingSessionFactory.cs +++ b/src/Spring/Spring.Data.NHibernate21/Data/NHibernate/SimpleDelegatingSessionFactory.cs @@ -1,105 +1,105 @@ -using System.Collections; - -using NHibernate; -using NHibernate.Cfg; -using NhCfg = NHibernate.Cfg; - -using Spring.Collections; -using Spring.Threading; -using Spring.Data.Common; -using Spring.Context.Support; -using NHibernate.Engine; -using System; - -namespace Spring.Data.NHibernate -{ - /// - /// SimpleDelegatingSessionFactory class - /// - public class SimpleDelegatingSessionFactory : DelegatingSessionFactory - { - /// - /// Connection string config element name - /// - public const string CONNECTION_STRING = "SimpleDelegatingSessionFactory.ConnectionString"; - - private Configuration _configuration; - - private string _defaultConnectionString; - - private object _monitor = new object(); - - private IDictionary _targetSessionFactories = new SynchronizedHashtable(); - - /// - /// public Constructor - /// - /// - public SimpleDelegatingSessionFactory(Configuration defaultConfiguration) - { - if (defaultConfiguration == null) - { - throw new ArgumentException("Configuration cannot be null", "defaultConfiguration"); - } - - _configuration = defaultConfiguration; - if (!_configuration.Properties.ContainsKey(NhCfg.Environment.ConnectionString)) - { - throw new ArgumentException("Must specify connection string"); - } - - _defaultConnectionString = _configuration.Properties[NhCfg.Environment.ConnectionString] as string; - if (_defaultConnectionString == null) - { - throw new ArgumentException("Connection string property must be of type string, not " + - _configuration.Properties[NhCfg.Environment.ConnectionString].GetType().FullName); - } - } - - /// - /// TargetSessionFactory - /// - public override ISessionFactory TargetSessionFactory - { - get - { - string connectionString = LogicalThreadContext.GetData(CONNECTION_STRING) as string; - - System.Diagnostics.Trace.WriteLine(String.Format("{0} = {1}", System.Threading.Thread.CurrentThread.GetHashCode(), connectionString)); - - if (connectionString == null) - { - connectionString = _defaultConnectionString; - } - - lock (_monitor) - { - if (!_targetSessionFactories.Contains(connectionString)) - { - System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.GetHashCode().ToString() + " = (created) "); - - _configuration.Properties[NhCfg.Environment.ConnectionString] = connectionString; - ISessionFactory sessionFactory = _configuration.BuildSessionFactory(); - - LocalSessionFactoryObject.DbProviderWrapper dbProviderWrapper = ((ISessionFactoryImplementor)sessionFactory).ConnectionProvider as LocalSessionFactoryObject.DbProviderWrapper; - if (dbProviderWrapper != null) - { - dbProviderWrapper.DbProvider = (IDbProvider)ContextRegistry.GetContext().GetObject("DbProvider"); - } - - _targetSessionFactories[connectionString] = sessionFactory; - } - else - System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.GetHashCode().ToString() + " = (cached) "); - - ISessionFactory factory = _targetSessionFactories[connectionString] as ISessionFactory; - - System.Diagnostics.Trace.WriteLine(String.Format("{0} = {1}", System.Threading.Thread.CurrentThread.GetHashCode(), ((ISessionFactoryImplementor)factory).ConnectionProvider.GetConnection().ConnectionString)); - - return factory; - } - } - } - - } -} +using System.Collections; + +using NHibernate; +using NHibernate.Cfg; +using NhCfg = NHibernate.Cfg; + +using Spring.Collections; +using Spring.Threading; +using Spring.Data.Common; +using Spring.Context.Support; +using NHibernate.Engine; +using System; + +namespace Spring.Data.NHibernate +{ + /// + /// SimpleDelegatingSessionFactory class + /// + public class SimpleDelegatingSessionFactory : DelegatingSessionFactory + { + /// + /// Connection string config element name + /// + public const string CONNECTION_STRING = "SimpleDelegatingSessionFactory.ConnectionString"; + + private Configuration _configuration; + + private string _defaultConnectionString; + + private object _monitor = new object(); + + private IDictionary _targetSessionFactories = new SynchronizedHashtable(); + + /// + /// public Constructor + /// + /// + public SimpleDelegatingSessionFactory(Configuration defaultConfiguration) + { + if (defaultConfiguration == null) + { + throw new ArgumentException("Configuration cannot be null", "defaultConfiguration"); + } + + _configuration = defaultConfiguration; + if (!_configuration.Properties.ContainsKey(NhCfg.Environment.ConnectionString)) + { + throw new ArgumentException("Must specify connection string"); + } + + _defaultConnectionString = _configuration.Properties[NhCfg.Environment.ConnectionString] as string; + if (_defaultConnectionString == null) + { + throw new ArgumentException("Connection string property must be of type string, not " + + _configuration.Properties[NhCfg.Environment.ConnectionString].GetType().FullName); + } + } + + /// + /// TargetSessionFactory + /// + public override ISessionFactory TargetSessionFactory + { + get + { + string connectionString = LogicalThreadContext.GetData(CONNECTION_STRING) as string; + + System.Diagnostics.Trace.WriteLine(String.Format("{0} = {1}", System.Threading.Thread.CurrentThread.GetHashCode(), connectionString)); + + if (connectionString == null) + { + connectionString = _defaultConnectionString; + } + + lock (_monitor) + { + if (!_targetSessionFactories.Contains(connectionString)) + { + System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.GetHashCode().ToString() + " = (created) "); + + _configuration.Properties[NhCfg.Environment.ConnectionString] = connectionString; + ISessionFactory sessionFactory = _configuration.BuildSessionFactory(); + + LocalSessionFactoryObject.DbProviderWrapper dbProviderWrapper = ((ISessionFactoryImplementor)sessionFactory).ConnectionProvider as LocalSessionFactoryObject.DbProviderWrapper; + if (dbProviderWrapper != null) + { + dbProviderWrapper.DbProvider = (IDbProvider)ContextRegistry.GetContext().GetObject("DbProvider"); + } + + _targetSessionFactories[connectionString] = sessionFactory; + } + else + System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.GetHashCode().ToString() + " = (cached) "); + + ISessionFactory factory = _targetSessionFactories[connectionString] as ISessionFactory; + + System.Diagnostics.Trace.WriteLine(String.Format("{0} = {1}", System.Threading.Thread.CurrentThread.GetHashCode(), connectionString)); + + return factory; + } + } + } + + } +} From cdd2564beb7c37fcfe813fdf2b3329236e7e8522 Mon Sep 17 00:00:00 2001 From: Marijn van der Zee Date: Thu, 13 Oct 2011 16:39:10 +0200 Subject: [PATCH 02/14] Remove the errant paragraph and code listing The errant paragraph is removed, as well as the code listing. From the text it appears that an example should have been inserted here; that's commented out and replaced with a TODO note. --- doc/reference/src/ado.xml | 45 +++++++-------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/doc/reference/src/ado.xml b/doc/reference/src/ado.xml index dd1fa659..52753d46 100644 --- a/doc/reference/src/ado.xml +++ b/doc/reference/src/ado.xml @@ -2052,50 +2052,21 @@ public static void ApplyConnectionAndTx(object typedDataSetAdapter, IDbProvider MappingadoQueryWithParameters (See SDK docs for details). - The AdoNonQuery class encapsulates an - IDbCommand 's ExecuteNonQuery method functionality. Like the - AdoQuery object, an AdoNonQuery - object is reusable, and like all AdoOperation - classes, an AdoNonQuery can have parameters and is - defined in SQL. This class provides two execute methods - - - - IDictionary ExecuteNonQuery(params object[] - inParameterValues) - - - - IDictionary ExecuteNonQueryByNamedParam(IDictionary - inParams) - - - - This class is concrete. Although it can be subclassed (for example - to add a custom update method) it can easily be parameterized by setting - SQL and declaring parameters. + + From d4f67530c45ff95d8a7ff755f379714c51c748e2 Mon Sep 17 00:00:00 2001 From: Marijn van der Zee Date: Tue, 18 Oct 2011 17:10:11 +0200 Subject: [PATCH 03/14] Fix typo. --- doc/reference/src/ado.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/reference/src/ado.xml b/doc/reference/src/ado.xml index d08313ba..f9959399 100644 --- a/doc/reference/src/ado.xml +++ b/doc/reference/src/ado.xml @@ -2047,7 +2047,7 @@ public static void ApplyConnectionAndTx(object typedDataSetAdapter, IDbProvider AdoQuery class is rarely used directly since the MappingAdoQuery subclass provides a much more convenient implementation for mapping rows to .NET classes. Another - implementations that extends AdoQuery is + implementation that extends AdoQuery is MappingadoQueryWithParameters (See SDK docs for details). From c4b0bf255f8bc3da199fb1e0eb761d2ebf9f5f34 Mon Sep 17 00:00:00 2001 From: Bruno Baia Date: Thu, 20 Oct 2011 18:20:48 +0200 Subject: [PATCH 04/14] Fixed WCF Quickstart [Related to SPRNET-1475] --- .../Spring.WcfQuickStart.2008.sln | 4 +- ... Spring.WcfQuickStart.Aspects.2008.csproj} | 9 ++-- .../Spring.WcfQuickStart.Aspects.2010.csproj | 28 +++-------- .../Spring.WcfQuickStart.ClientApp/App.config | 12 ++++- ...Spring.WcfQuickStart.ClientApp.2008.csproj | 36 ++++--------- ...Spring.WcfQuickStart.ClientApp.2010.csproj | 50 ++++--------------- ...pring.WcfQuickStart.Contracts.2008.csproj} | 5 +- ...Spring.WcfQuickStart.Contracts.2010.csproj | 20 +------- ...Spring.WcfQuickStart.ServerApp.2008.csproj | 34 ++++--------- ...Spring.WcfQuickStart.ServerApp.2010.csproj | 48 ++++-------------- ...Spring.WcfQuickStart.ServerWeb.2008.csproj | 29 ++++++++--- ...Spring.WcfQuickStart.ServerWeb.2010.csproj | 25 ++++++---- 12 files changed, 110 insertions(+), 190 deletions(-) rename examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/{Spring.WcfQuickStart.Aspects.csproj => Spring.WcfQuickStart.Aspects.2008.csproj} (87%) rename examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/{Spring.WcfQuickStart.Contracts.csproj => Spring.WcfQuickStart.Contracts.2008.csproj} (90%) diff --git a/examples/Spring/Spring.WcfQuickStart/Spring.WcfQuickStart.2008.sln b/examples/Spring/Spring.WcfQuickStart/Spring.WcfQuickStart.2008.sln index 69acd826..a7962996 100644 --- a/examples/Spring/Spring.WcfQuickStart/Spring.WcfQuickStart.2008.sln +++ b/examples/Spring/Spring.WcfQuickStart/Spring.WcfQuickStart.2008.sln @@ -10,9 +10,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.WcfQuickStart.Server EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.WcfQuickStart.ServerWeb.2008", "src\Spring.WcfQuickStart.ServerWeb\Spring.WcfQuickStart.ServerWeb.2008.csproj", "{EEC5B531-104B-44E6-975B-44C0C8973405}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.WcfQuickStart.Contracts", "src\Spring.WcfQuickStart.Contracts\Spring.WcfQuickStart.Contracts.csproj", "{53263837-0643-45FE-96A2-46D425E1A36F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.WcfQuickStart.Contracts.2008", "src\Spring.WcfQuickStart.Contracts\Spring.WcfQuickStart.Contracts.2008.csproj", "{53263837-0643-45FE-96A2-46D425E1A36F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.WcfQuickStart.Aspects", "src\Spring.WcfQuickStart.Aspects\Spring.WcfQuickStart.Aspects.csproj", "{B52BBAA3-1B30-4905-827C-1D81EBA56A15}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.WcfQuickStart.Aspects.2008", "src\Spring.WcfQuickStart.Aspects\Spring.WcfQuickStart.Aspects.2008.csproj", "{B52BBAA3-1B30-4905-827C-1D81EBA56A15}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.csproj b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.2008.csproj similarity index 87% rename from examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.csproj rename to examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.2008.csproj index 997028e9..89546754 100644 --- a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.csproj +++ b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.2008.csproj @@ -10,7 +10,7 @@ Properties Spring.WcfQuickStart Spring.WcfQuickStart.Aspects - v3.0 + v3.5 512 @@ -33,15 +33,18 @@ 4 - + False ..\..\..\..\..\bin\net\2.0\debug\Spring.Aop.dll - + False ..\..\..\..\..\bin\net\2.0\debug\Spring.Core.dll + + 3.5 + diff --git a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.2010.csproj b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.2010.csproj index ddfa05bd..3f46fc5b 100644 --- a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.2010.csproj +++ b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Aspects/Spring.WcfQuickStart.Aspects.2010.csproj @@ -10,7 +10,7 @@ Properties Spring.WcfQuickStart Spring.WcfQuickStart.Aspects - v3.0 + v4.0 512 @@ -31,6 +31,7 @@ false false true + true @@ -52,13 +53,13 @@ AllRules.ruleset - + False - ..\..\..\..\..\bin\net\2.0\debug\Spring.Aop.dll + ..\..\..\..\..\bin\net\4.0\debug\Spring.Aop.dll - + False - ..\..\..\..\..\bin\net\2.0\debug\Spring.Core.dll + ..\..\..\..\..\bin\net\4.0\debug\Spring.Core.dll @@ -68,23 +69,6 @@ - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - @@ -15,7 +18,11 @@ + + + + @@ -33,4 +40,5 @@ - + + diff --git a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.ClientApp/Spring.WcfQuickStart.ClientApp.2008.csproj b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.ClientApp/Spring.WcfQuickStart.ClientApp.2008.csproj index 7c35e6d6..402ed7d9 100644 --- a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.ClientApp/Spring.WcfQuickStart.ClientApp.2008.csproj +++ b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.ClientApp/Spring.WcfQuickStart.ClientApp.2008.csproj @@ -14,7 +14,7 @@ 2.0 - v3.0 + v3.5 http://localhost/Spring.WcfQuickStart.ClientApp/ true Web @@ -52,19 +52,22 @@ 4 - + False ..\..\..\..\..\bin\net\2.0\debug\Spring.Aop.dll - + False ..\..\..\..\..\bin\net\2.0\debug\Spring.Core.dll - + False - ..\..\..\..\..\bin\net\3.0\debug\Spring.Services.dll + ..\..\..\..\..\bin\net\3.5\debug\Spring.Services.dll + + 3.5 + @@ -78,33 +81,14 @@ - - - - False - .NET Framework 2.0 %28x86%29 - true - - - False - .NET Framework 3.0 %28x86%29 - false - - - False - .NET Framework 3.5 - false - - - - + {B52BBAA3-1B30-4905-827C-1D81EBA56A15} Spring.WcfQuickStart.Aspects - + {53263837-0643-45FE-96A2-46D425E1A36F} Spring.WcfQuickStart.Contracts diff --git a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.ClientApp/Spring.WcfQuickStart.ClientApp.2010.csproj b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.ClientApp/Spring.WcfQuickStart.ClientApp.2010.csproj index 24b0841c..58907b19 100644 --- a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.ClientApp/Spring.WcfQuickStart.ClientApp.2010.csproj +++ b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.ClientApp/Spring.WcfQuickStart.ClientApp.2010.csproj @@ -15,7 +15,7 @@ 3.5 - v3.0 + v4.0 true http://localhost/Spring.WcfQuickStart.ClientApp/ true @@ -31,6 +31,7 @@ 1.0.0.%2a false true + true @@ -53,21 +54,21 @@ AllRules.ruleset - + False - ..\..\..\..\..\bin\net\2.0\debug\Spring.Aop.dll + ..\..\..\..\..\bin\net\4.0\debug\Spring.Aop.dll - + False - ..\..\..\..\..\bin\net\2.0\debug\Spring.Core.dll + ..\..\..\..\..\bin\net\4.0\debug\Spring.Core.dll - + False - ..\..\..\..\..\bin\net\3.0\debug\Spring.Services.dll + ..\..\..\..\..\bin\net\4.0\debug\Spring.Services.dll - + @@ -79,43 +80,14 @@ - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 2.0 %28x86%29 - true - - - False - .NET Framework 3.0 %28x86%29 - false - - - False - .NET Framework 3.5 - false - - - False - .NET Framework 3.5 SP1 - false - - - - + {B52BBAA3-1B30-4905-827C-1D81EBA56A15} Spring.WcfQuickStart.Aspects - + {53263837-0643-45FE-96A2-46D425E1A36F} Spring.WcfQuickStart.Contracts diff --git a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.csproj b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.2008.csproj similarity index 90% rename from examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.csproj rename to examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.2008.csproj index a5b00d22..1139972e 100644 --- a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.csproj +++ b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.2008.csproj @@ -10,7 +10,7 @@ Properties Spring.WcfQuickStart Spring.WcfQuickStart.Contracts - v3.0 + v3.5 512 @@ -34,6 +34,9 @@ + + 3.5 + 3.0 diff --git a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.2010.csproj b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.2010.csproj index 8a7e21d9..e7fea581 100644 --- a/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.2010.csproj +++ b/examples/Spring/Spring.WcfQuickStart/src/Spring.WcfQuickStart.Contracts/Spring.WcfQuickStart.Contracts.2010.csproj @@ -10,7 +10,7 @@ Properties Spring.WcfQuickStart Spring.WcfQuickStart.Contracts - v3.0 + v4.0 512 @@ -31,6 +31,7 @@ false false true + true @@ -64,23 +65,6 @@ - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - From 88326436e240ebde9efdab1c3ee9781aa65e5293 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Tue, 1 Nov 2011 11:46:58 -0400 Subject: [PATCH 07/14] rename erroneous folder tools/ReporterGenerator --- build-support/solutions.build.nant | 2 +- .../LICENSE.txt | 0 .../Readme.txt | 0 .../bin/ICSharpCode.NRefactory.dll | Bin .../bin/LICENSE.txt | 0 .../bin/Readme.txt | 0 .../bin/ReportGenerator.exe | Bin .../bin/log4net.dll | Bin common-project.include | 2 +- 9 files changed, 2 insertions(+), 2 deletions(-) rename build-support/tools/{ReporterGenerator => ReportGenerator}/LICENSE.txt (100%) rename build-support/tools/{ReporterGenerator => ReportGenerator}/Readme.txt (100%) rename build-support/tools/{ReporterGenerator => ReportGenerator}/bin/ICSharpCode.NRefactory.dll (100%) rename build-support/tools/{ReporterGenerator => ReportGenerator}/bin/LICENSE.txt (100%) rename build-support/tools/{ReporterGenerator => ReportGenerator}/bin/Readme.txt (100%) rename build-support/tools/{ReporterGenerator => ReportGenerator}/bin/ReportGenerator.exe (100%) rename build-support/tools/{ReporterGenerator => ReportGenerator}/bin/log4net.dll (100%) diff --git a/build-support/solutions.build.nant b/build-support/solutions.build.nant index 18a41d8f..1759449b 100644 --- a/build-support/solutions.build.nant +++ b/build-support/solutions.build.nant @@ -52,7 +52,7 @@ Rebuilding Solutions using Nant and "solutions.build": - + diff --git a/build-support/tools/ReporterGenerator/LICENSE.txt b/build-support/tools/ReportGenerator/LICENSE.txt similarity index 100% rename from build-support/tools/ReporterGenerator/LICENSE.txt rename to build-support/tools/ReportGenerator/LICENSE.txt diff --git a/build-support/tools/ReporterGenerator/Readme.txt b/build-support/tools/ReportGenerator/Readme.txt similarity index 100% rename from build-support/tools/ReporterGenerator/Readme.txt rename to build-support/tools/ReportGenerator/Readme.txt diff --git a/build-support/tools/ReporterGenerator/bin/ICSharpCode.NRefactory.dll b/build-support/tools/ReportGenerator/bin/ICSharpCode.NRefactory.dll similarity index 100% rename from build-support/tools/ReporterGenerator/bin/ICSharpCode.NRefactory.dll rename to build-support/tools/ReportGenerator/bin/ICSharpCode.NRefactory.dll diff --git a/build-support/tools/ReporterGenerator/bin/LICENSE.txt b/build-support/tools/ReportGenerator/bin/LICENSE.txt similarity index 100% rename from build-support/tools/ReporterGenerator/bin/LICENSE.txt rename to build-support/tools/ReportGenerator/bin/LICENSE.txt diff --git a/build-support/tools/ReporterGenerator/bin/Readme.txt b/build-support/tools/ReportGenerator/bin/Readme.txt similarity index 100% rename from build-support/tools/ReporterGenerator/bin/Readme.txt rename to build-support/tools/ReportGenerator/bin/Readme.txt diff --git a/build-support/tools/ReporterGenerator/bin/ReportGenerator.exe b/build-support/tools/ReportGenerator/bin/ReportGenerator.exe similarity index 100% rename from build-support/tools/ReporterGenerator/bin/ReportGenerator.exe rename to build-support/tools/ReportGenerator/bin/ReportGenerator.exe diff --git a/build-support/tools/ReporterGenerator/bin/log4net.dll b/build-support/tools/ReportGenerator/bin/log4net.dll similarity index 100% rename from build-support/tools/ReporterGenerator/bin/log4net.dll rename to build-support/tools/ReportGenerator/bin/log4net.dll diff --git a/common-project.include b/common-project.include index 1d722bfe..01b454ca 100644 --- a/common-project.include +++ b/common-project.include @@ -319,7 +319,7 @@ ${tool.dir} : dir for tools - + From 6084b5d119eb35763ea78c672a3b7f319e2a7028 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Thu, 3 Nov 2011 19:02:44 -0400 Subject: [PATCH 08/14] SPRNET-1472 wire up opencover to run coverage on all tests aggregated together at once --- Spring.build | 15 ++++-- common-project.include | 103 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 112 insertions(+), 6 deletions(-) diff --git a/Spring.build b/Spring.build index 30dd8597..8243f7b7 100644 --- a/Spring.build +++ b/Spring.build @@ -148,6 +148,7 @@ Commandline Examples: + @@ -509,7 +510,7 @@ Commandline Examples: - + - + @@ -540,7 +542,7 @@ Commandline Examples: - + @@ -562,7 +564,7 @@ Commandline Examples: - + @@ -597,7 +599,7 @@ Commandline Examples: - + @@ -616,6 +618,9 @@ Commandline Examples: + + + - + @@ -347,6 +349,105 @@ ${tool.dir} : dir for tools + + + + + + + + + + + + + <NUnitProject> + <Settings activeconfig="Default" /> + <Config name="Default" binpathtype="Auto"> + </Config> + </NUnitProject> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6f4ffb9ade4436b4f42b53ad37c09190df80a79a Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Fri, 4 Nov 2011 08:43:49 -0400 Subject: [PATCH 09/14] SPRNET-1472 fixing quotes missing from targetargs passed to opencover command-line --- common-project.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-project.include b/common-project.include index 45ec587b..64a21ca4 100644 --- a/common-project.include +++ b/common-project.include @@ -386,7 +386,7 @@ ${tool.dir} : dir for tools - + From ca962bb6459fa308af798676ddbffbccd1a5701e Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Fri, 4 Nov 2011 11:40:05 -0400 Subject: [PATCH 10/14] SPRNET-1472 passing list of all individual test assemblies instead of nunit project file --- common-project.include | 79 ++++++------------------------------------ 1 file changed, 11 insertions(+), 68 deletions(-) diff --git a/common-project.include b/common-project.include index 64a21ca4..15f33f4f 100644 --- a/common-project.include +++ b/common-project.include @@ -352,23 +352,13 @@ ${tool.dir} : dir for tools - - - - - - <NUnitProject> - <Settings activeconfig="Default" /> - <Config name="Default" binpathtype="Auto"> - </Config> - </NUnitProject> - - - + + + @@ -376,17 +366,19 @@ ${tool.dir} : dir for tools - - + + - - + + + + - + @@ -399,58 +391,9 @@ ${tool.dir} : dir for tools - - - + From 87aa1288294dee8e44c392f6f48e28edd3cea600 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Fri, 4 Nov 2011 14:32:02 -0400 Subject: [PATCH 11/14] Revert "SPRNET-1472 passing list of all individual test assemblies instead of nunit project file" This reverts commit ca962bb6459fa308af798676ddbffbccd1a5701e. --- common-project.include | 79 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 11 deletions(-) diff --git a/common-project.include b/common-project.include index 15f33f4f..64a21ca4 100644 --- a/common-project.include +++ b/common-project.include @@ -352,13 +352,23 @@ ${tool.dir} : dir for tools + - - - + + + + + <NUnitProject> + <Settings activeconfig="Default" /> + <Config name="Default" binpathtype="Auto"> + </Config> + </NUnitProject> + + + @@ -366,19 +376,17 @@ ${tool.dir} : dir for tools - - + + - - - - + + - + @@ -391,9 +399,58 @@ ${tool.dir} : dir for tools + + - + From 1d2c891b902c3a26633993146237545b8661de77 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Fri, 4 Nov 2011 14:32:24 -0400 Subject: [PATCH 12/14] Revert "SPRNET-1472 fixing quotes missing from targetargs passed to opencover command-line" This reverts commit 6f4ffb9ade4436b4f42b53ad37c09190df80a79a. --- common-project.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-project.include b/common-project.include index 64a21ca4..45ec587b 100644 --- a/common-project.include +++ b/common-project.include @@ -386,7 +386,7 @@ ${tool.dir} : dir for tools - + From aecb61fa548e1ec41eddcc91d006aea5c643b971 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Fri, 4 Nov 2011 14:32:31 -0400 Subject: [PATCH 13/14] Revert "SPRNET-1472 wire up opencover to run coverage on all tests aggregated together at once" This reverts commit 6084b5d119eb35763ea78c672a3b7f319e2a7028. --- Spring.build | 15 ++---- common-project.include | 103 +---------------------------------------- 2 files changed, 6 insertions(+), 112 deletions(-) diff --git a/Spring.build b/Spring.build index 8243f7b7..30dd8597 100644 --- a/Spring.build +++ b/Spring.build @@ -148,7 +148,6 @@ Commandline Examples: - @@ -510,7 +509,7 @@ Commandline Examples: - @@ -519,14 +518,13 @@ Commandline Examples: - --> - + @@ -542,7 +540,7 @@ Commandline Examples: - + @@ -564,7 +562,7 @@ Commandline Examples: - + @@ -599,7 +597,7 @@ Commandline Examples: - + @@ -618,9 +616,6 @@ Commandline Examples: - - - - @@ -349,105 +347,6 @@ ${tool.dir} : dir for tools - - - - - - - - - - - - - <NUnitProject> - <Settings activeconfig="Default" /> - <Config name="Default" binpathtype="Auto"> - </Config> - </NUnitProject> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 43516e6dbefc7049b26f35ec04b2c9a0bd65c051 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Tue, 15 Nov 2011 11:11:09 -0500 Subject: [PATCH 14/14] merge mods to pull 6 for SPRNET-1470, SPRNET-1471 --- .../TypeConversion/TypeConversionUtils.cs | 59 ++++++-- .../Xml/collectionConversionGeneric.xml | 33 +++++ .../Xml/CollectionConversionGenericTests.cs | 131 ++++++++++++++++++ .../Spring.Core.Tests/Objects/TestObject.cs | 21 +++ .../Spring.Core.Tests.2008.csproj | 2 + .../Spring.Core.Tests.2010.csproj | 2 + 6 files changed, 240 insertions(+), 8 deletions(-) create mode 100644 test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/collectionConversionGeneric.xml create mode 100644 test/Spring/Spring.Core.Tests/Objects/Factory/Xml/CollectionConversionGenericTests.cs diff --git a/src/Spring/Spring.Core/Core/TypeConversion/TypeConversionUtils.cs b/src/Spring/Spring.Core/Core/TypeConversion/TypeConversionUtils.cs index fd38c7a8..bac5e3cc 100644 --- a/src/Spring/Spring.Core/Core/TypeConversion/TypeConversionUtils.cs +++ b/src/Spring/Spring.Core/Core/TypeConversion/TypeConversionUtils.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using System.ComponentModel; using Spring.Util; +using System.Reflection; #endregion @@ -116,6 +117,45 @@ namespace Spring.Core.TypeConversion return ToTypedCollectionWithTypeConversion(typeof(List<>), componentType, elements, propertyName); } } + + // if required type is some IDictionary, convert all the elements + if (requiredType != null && requiredType.IsGenericType && TypeImplementsGenericInterface(requiredType, typeof(IDictionary<,>))) + { + Type[] typeParameters = requiredType.GetGenericArguments(); + Type keyType = typeParameters[0]; + Type valueType = typeParameters[1]; + if (newValue is IDictionary) + { + IDictionary elements = (IDictionary)newValue; + Type targetCollectionType = typeof(Dictionary<,>); + Type collectionType = targetCollectionType.MakeGenericType(new Type[] { keyType, valueType }); + object typedCollection = Activator.CreateInstance(collectionType); + + MethodInfo addMethod = collectionType.GetMethod("Add", new Type[] { keyType, valueType }); + int i = 0; + foreach (DictionaryEntry entry in elements) + { + string propertyExpr = BuildIndexedPropertyName(propertyName, i); + object key = ConvertValueIfNecessary(keyType, entry.Key, propertyExpr + ".Key"); + object value = ConvertValueIfNecessary(valueType, entry.Value, propertyExpr + ".Value"); + addMethod.Invoke(typedCollection, new object[] { key, value }); + i++; + } + return typedCollection; + } + } + + // if required type is some IEnumerable, convert all the elements + if (requiredType != null && requiredType.IsGenericType && TypeImplementsGenericInterface(requiredType, typeof(IEnumerable<>))) + { + // convert individual elements to array elements + Type componentType = requiredType.GetGenericArguments()[0]; + if (newValue is ICollection) + { + ICollection elements = (ICollection)newValue; + return ToTypedCollectionWithTypeConversion(typeof(List<>), componentType, elements, propertyName); + } + } #endif // try to convert using type converter @@ -289,18 +329,16 @@ namespace Spring.Core.TypeConversion throw new ArgumentException("matchingInterface Type must be an Interface Type", "matchingInterface"); } - bool match = false; + if (candidateType.IsInterface && IsMatchingGenericInterface(candidateType, matchingInterface)) + { + return true; + } + bool match = false; Type[] implementedInterfaces = candidateType.GetInterfaces(); foreach (Type interfaceType in implementedInterfaces) { - if (false == interfaceType.IsGenericType) - { - continue; - } - - Type genericType = interfaceType.GetGenericTypeDefinition(); - if (genericType == matchingInterface) + if (IsMatchingGenericInterface(interfaceType, matchingInterface)) { match = true; break; @@ -309,6 +347,11 @@ namespace Spring.Core.TypeConversion return match; } + + private static bool IsMatchingGenericInterface(Type candidateInterfaceType, Type matchingGenericInterface) + { + return candidateInterfaceType.IsGenericType && candidateInterfaceType.GetGenericTypeDefinition() == matchingGenericInterface; + } #endif } } \ No newline at end of file diff --git a/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/collectionConversionGeneric.xml b/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/collectionConversionGeneric.xml new file mode 100644 index 00000000..02fd9c04 --- /dev/null +++ b/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/collectionConversionGeneric.xml @@ -0,0 +1,33 @@ + + + + + + + + 123 + 234 + 345 + + + + + + + + + + + + + + + + + + 123 + + + + + diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/CollectionConversionGenericTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/CollectionConversionGenericTests.cs new file mode 100644 index 00000000..503e81ca --- /dev/null +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/CollectionConversionGenericTests.cs @@ -0,0 +1,131 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +#region Imports + +using NUnit.Framework; +using Spring.Objects.Factory.Support; +using System.Collections; +using Spring.Core.TypeConversion; +using System.Collections.Generic; +using System.Collections.Specialized; + +#endregion + +namespace Spring.Objects.Factory.Xml +{ + /// + /// Unit and integration tests for collection conversion support + /// + /// Choy Rim + [TestFixture] + [Description("SPRNET-1470 Setting property of type IList using without the @element-type specified fails.")] + public class CollectionConversionGenericTests + { + private DefaultListableObjectFactory objectFactory; + + [SetUp] + public void SetUp() + { + this.objectFactory = new DefaultListableObjectFactory(); + IObjectDefinitionReader reader = new XmlObjectDefinitionReader(this.objectFactory); + reader.LoadObjectDefinitions(new ReadOnlyXmlTestResource("collectionConversionGeneric.xml", GetType())); + } + + [Test] + public void ShouldConvertListToGenericIList() + { + TestObject to = (TestObject)this.objectFactory.GetObject("HasGenericIListProperty"); + IList list = to.SomeGenericIListInt32; + Assert.That(list.Count, Is.EqualTo(3)); + Assert.That(list[0], Is.EqualTo(123)); + Assert.That(list[1], Is.EqualTo(234)); + Assert.That(list[2], Is.EqualTo(345)); + } + + [Test] + public void ShouldConvertDictionaryToGenericIDictionary() + { + TestObject to = (TestObject)this.objectFactory.GetObject("HasGenericIDictionaryProperty"); + IDictionary dict = to.SomeGenericIDictionaryStringInt32; + Assert.That(dict.Count, Is.EqualTo(3)); + Assert.That(dict["aaa"], Is.EqualTo(111)); + Assert.That(dict["bbb"], Is.EqualTo(222)); + Assert.That(dict["ccc"], Is.EqualTo(333)); + } + + [Test] + public void ShouldConvertListToGenericIEnumerable() + { + TestObject to = (TestObject)this.objectFactory.GetObject("HasGenericIEnumerableProperty"); + IEnumerable enumerable = to.SomeGenericIEnumerableInt32; + int enumerableLength = 0; + int first = 0; + + foreach (int i in enumerable) + { + enumerableLength += 1; + if (enumerableLength == 1) + { + first = i; + } + } + + Assert.That(enumerableLength, Is.EqualTo(1)); + Assert.That(first, Is.EqualTo(123)); + } + + [Test] + public void ConvertArrayListToGenericIList() + { + ArrayList xs = new ArrayList(); + xs.Add("Mark Pollack"); + object ys = TypeConversionUtils.ConvertValueIfNecessary(typeof(IList), xs, "ignored"); + Assert.That(ys as IList, Is.Not.Null); + IList zs = (IList)ys; + Assert.That(zs[0], Is.EqualTo("Mark Pollack")); + } + + [Test] + public void ConvertHybridDictionaryToGenericIDictionary() + { + HybridDictionary xs = new HybridDictionary(); + xs.Add("first", 1); + object ys = TypeConversionUtils.ConvertValueIfNecessary(typeof(IDictionary), xs, "ignored"); + Assert.That(ys as IDictionary, Is.Not.Null); + IDictionary zs = (IDictionary)ys; + Assert.That(zs["first"], Is.EqualTo(1)); + } + + [Test] + public void ConvertArrayListToGenericIEnumerable() + { + ArrayList xs = new ArrayList(); + xs.Add("Mark Pollack"); + object ys = TypeConversionUtils.ConvertValueIfNecessary(typeof(IEnumerable), xs, "ignored"); + Assert.That(ys as IEnumerable, Is.Not.Null); + IEnumerable zs = (IEnumerable)ys; + IEnumerator zse = zs.GetEnumerator(); + Assert.That(zse.MoveNext(), Is.True); + Assert.That(zse.Current, Is.EqualTo("Mark Pollack")); + } + + } +} diff --git a/test/Spring/Spring.Core.Tests/Objects/TestObject.cs b/test/Spring/Spring.Core.Tests/Objects/TestObject.cs index 1f9ed460..b34b43c1 100644 --- a/test/Spring/Spring.Core.Tests/Objects/TestObject.cs +++ b/test/Spring/Spring.Core.Tests/Objects/TestObject.cs @@ -273,6 +273,27 @@ namespace Spring.Objects set { this.someGenericStringList = value; } } + private IList someGenericIListInt32; + public virtual IList SomeGenericIListInt32 + { + get { return someGenericIListInt32; } + set { someGenericIListInt32 = value; } + } + + private IDictionary someGenericIDictionaryStringInt32; + public virtual IDictionary SomeGenericIDictionaryStringInt32 + { + get { return someGenericIDictionaryStringInt32; } + set { someGenericIDictionaryStringInt32 = value; } + } + + private IEnumerable someGenericIEnumerableInt32; + public virtual IEnumerable SomeGenericIEnumerableInt32 + { + get { return someGenericIEnumerableInt32; } + set { someGenericIEnumerableInt32 = value; } + } + public virtual NameValueCollection SomeNameValueCollection { get { return someNameValueCollection; } diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj index 1a9aadd6..ad8eee70 100644 --- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj +++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj @@ -343,6 +343,7 @@ + @@ -818,6 +819,7 @@ + diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj index c3e07eac..0529c137 100644 --- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj +++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj @@ -352,6 +352,7 @@ + @@ -827,6 +828,7 @@ +