From f78411ac14404c7b9db5b4b6bf6d98e8f29ab8c5 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Thu, 26 Sep 2019 17:52:11 +0300 Subject: [PATCH] Support .NET Core 3 (#190) * fix dynamic code generation issues * fix NmsQuickStart --- appveyor.yml | 2 +- .../Spring.NmsQuickStart.Client.csproj | 1 - .../Spring.NmsQuickStart.Common.csproj | 1 + .../Spring.NmsQuickStart.Server.csproj | 1 - .../Aop/Framework/AdvisedSupport.cs | 16 ++++-- .../AbstractAdvisorAutoProxyCreator.cs | 5 -- .../AbstractAopProxyMethodBuilder.cs | 50 +++++------------ .../Framework/DynamicProxy/AdvisedProxy.cs | 4 +- .../DynamicProxy/BaseAopProxyMethodBuilder.cs | 20 ++----- .../CompositionAopProxyTypeBuilder.cs | 51 ++++-------------- .../DecoratorAopProxyTypeBuilder.cs | 47 ++++------------ .../InheritanceAopProxyTypeBuilder.cs | 54 ++++--------------- .../IntroductionProxyMethodBuilder.cs | 22 ++------ .../TargetAopProxyMethodBuilder.cs | 22 ++------ .../Spring.Aop/Aop/Framework/IAdvised.cs | 9 +--- .../Attributes/ConfigurationClassEnhancer.cs | 4 +- .../Aop/Framework/IsModifiedMixin.cs | 2 +- .../Spring.Aop.Tests/Spring.Aop.Tests.csproj | 4 +- .../Spring.Benchmark/Spring.Benchmark.csproj | 2 +- .../Spring.Core.Tests.csproj | 5 +- .../Spring.Data.Integration.Tests.csproj | 6 +-- ....Data.NHibernate5.Integration.Tests.csproj | 4 +- .../Spring.Data.NHibernate5.Tests.csproj | 2 +- .../Spring.Data.Tests.csproj | 6 +-- .../App.config | 14 ----- ...ing.Messaging.Nms.Integration.Tests.csproj | 2 +- .../Spring.Messaging.Nms.Tests.csproj | 2 +- ...cheduling.Quartz3.Integration.Tests.csproj | 2 +- .../Spring.Scheduling.Quartz3.Tests.csproj | 2 +- .../Spring.Testing.NUnit.Tests.csproj | 2 +- 30 files changed, 95 insertions(+), 269 deletions(-) delete mode 100644 test/Spring/Spring.Messaging.Nms.Integration.Tests/App.config diff --git a/appveyor.yml b/appveyor.yml index 3584e4c2..0e6d68f6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.{build} -image: Visual Studio 2017 +image: Visual Studio 2019 services: - mssql2017 - msmq diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj index fc22dcef..54128f39 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj @@ -7,7 +7,6 @@ - diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj index 212170cd..9398460d 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj @@ -3,6 +3,7 @@ net452 + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj index 4a43af81..2374b4ee 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj @@ -8,7 +8,6 @@ - diff --git a/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs b/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs index cdb91435..5920abd6 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs @@ -1,3 +1,5 @@ +#region License + /* * Copyright © 2002-2011 the original author or authors. * @@ -14,8 +16,9 @@ * limitations under the License. */ +#endregion + using System; -using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Runtime.Serialization; @@ -368,13 +371,18 @@ namespace Spring.Aop.Framework /// s to their delegates. /// /// - public virtual IDictionary InterfaceMap + public virtual IDictionary InterfaceMap { get { - lock (this.SyncRoot) + lock (SyncRoot) { - return new Hashtable(this.interfaceMap); + var dictionary = new Dictionary(interfaceMap.Count); + foreach (var entry in interfaceMap) + { + dictionary[entry.Key] = entry.Value; + } + return dictionary; } } } diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs index d4431331..34eabafa 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs @@ -18,10 +18,7 @@ #endregion -#region Imports - using System; -using System.Collections; using System.Collections.Generic; using Common.Logging; @@ -31,8 +28,6 @@ using Spring.Objects.Factory.Config; using System.Linq; -#endregion - namespace Spring.Aop.Framework.AutoProxy { /// diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyMethodBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyMethodBuilder.cs index 28693d8b..dc5a2ef4 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyMethodBuilder.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyMethodBuilder.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * 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. @@ -18,18 +18,14 @@ #endregion -#region Imports - using System; -using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.Serialization; using Spring.Proxy; -#endregion - namespace Spring.Aop.Framework.DynamicProxy { /// @@ -39,8 +35,6 @@ namespace Spring.Aop.Framework.DynamicProxy /// Bruno Baia public abstract class AbstractAopProxyMethodBuilder : AbstractProxyMethodBuilder { - #region Fields - /// /// The implementation to use. /// @@ -50,13 +44,13 @@ namespace Spring.Aop.Framework.DynamicProxy /// The dictionary to cache the list of target /// s. /// - protected IDictionary targetMethods; + protected IDictionary targetMethods; /// /// The dictionary to cache the list of target /// s defined on the proxy. /// - protected IDictionary onProxyTargetMethods; + protected IDictionary onProxyTargetMethods; // variables @@ -112,15 +106,11 @@ namespace Spring.Aop.Framework.DynamicProxy // private fields - private static IDictionary ldindOpCodes; - - #endregion - - #region Constructor(s) / Destructor + private static Dictionary ldindOpCodes; static AbstractAopProxyMethodBuilder() { - ldindOpCodes = new Hashtable(); + ldindOpCodes = new Dictionary(); ldindOpCodes[typeof(sbyte)] = OpCodes.Ldind_I1; ldindOpCodes[typeof(short)] = OpCodes.Ldind_I2; ldindOpCodes[typeof(int)] = OpCodes.Ldind_I4; @@ -152,8 +142,8 @@ namespace Spring.Aop.Framework.DynamicProxy /// protected AbstractAopProxyMethodBuilder( TypeBuilder typeBuilder, IAopProxyTypeGenerator aopProxyGenerator, - bool explicitImplementation, IDictionary targetMethods) - : this(typeBuilder, aopProxyGenerator, explicitImplementation, targetMethods, new Hashtable()) + bool explicitImplementation, IDictionary targetMethods) + : this(typeBuilder, aopProxyGenerator, explicitImplementation, targetMethods, new Dictionary()) { } @@ -178,7 +168,7 @@ namespace Spring.Aop.Framework.DynamicProxy /// protected AbstractAopProxyMethodBuilder( TypeBuilder typeBuilder, IAopProxyTypeGenerator aopProxyGenerator, - bool explicitImplementation, IDictionary targetMethods, IDictionary onProxyTargetMethods) + bool explicitImplementation, IDictionary targetMethods, IDictionary onProxyTargetMethods) : base(typeBuilder, aopProxyGenerator, explicitImplementation) { this.aopProxyGenerator = aopProxyGenerator; @@ -186,10 +176,6 @@ namespace Spring.Aop.Framework.DynamicProxy this.onProxyTargetMethods = onProxyTargetMethods; } - #endregion - - #region Protected Members - /// /// Generates the proxy method. /// @@ -235,7 +221,7 @@ namespace Spring.Aop.Framework.DynamicProxy targetMethods.Add(methodId, method); targetMethodCacheField = typeBuilder.DefineField(methodId, typeof(MethodInfo), - FieldAttributes.Private | FieldAttributes.Static | FieldAttributes.InitOnly); + FieldAttributes.Private | FieldAttributes.Static); MakeGenericMethod(il, method, targetMethodCacheField, genericTargetMethod); } @@ -362,7 +348,7 @@ namespace Spring.Aop.Framework.DynamicProxy /// The method to proxy. protected virtual void DeclareLocals(ILGenerator il, MethodInfo method) { - interceptors = il.DeclareLocal(typeof(IList)); + interceptors = il.DeclareLocal(typeof(System.Collections.IList)); targetType = il.DeclareLocal(typeof(Type)); arguments = il.DeclareLocal(typeof(Object[])); @@ -604,10 +590,6 @@ namespace Spring.Aop.Framework.DynamicProxy il.Emit(OpCodes.Ldloc, returnValue); } } - - #endregion - - #region Reflection.Emit utility methods /// /// Emits MSIL instructions to load a value of the specified @@ -675,12 +657,8 @@ namespace Spring.Aop.Framework.DynamicProxy il.Emit(OpCodes.Unbox_Any, type); } } - - #endregion } - #region References helper class definition - internal struct References { // fields @@ -723,7 +701,7 @@ namespace Spring.Aop.Framework.DynamicProxy typeof(AopContext).GetMethod("PopProxy", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null); public static readonly MethodInfo InvokeMethod = - typeof(AdvisedProxy).GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public, null, new Type[] { typeof(Object), typeof(Object), typeof(Type), typeof(MethodInfo), typeof(MethodInfo), typeof(Object[]), typeof(IList) }, null); + typeof(AdvisedProxy).GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public, null, new Type[] { typeof(Object), typeof(Object), typeof(Type), typeof(MethodInfo), typeof(MethodInfo), typeof(Object[]), typeof(System.Collections.IList) }, null); public static readonly MethodInfo GetInterceptorsMethod = typeof(AdvisedProxy).GetMethod("GetInterceptors", BindingFlags.Instance | BindingFlags.Public, null, new Type[] { typeof(Type), typeof(MethodInfo) }, null); @@ -757,8 +735,6 @@ namespace Spring.Aop.Framework.DynamicProxy typeof(IAdvised).GetProperty("ExposeProxy", typeof(Boolean)).GetGetMethod(); public static readonly MethodInfo CountProperty = - typeof(ICollection).GetProperty("Count", typeof(Int32)).GetGetMethod(); + typeof(System.Collections.ICollection).GetProperty("Count", typeof(Int32)).GetGetMethod(); } - - #endregion } diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs index 4d63f9ac..f20b45ef 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs @@ -1,5 +1,5 @@ /* - * Copyright © 2002-2011 the original author or authors. + * 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. @@ -247,7 +247,7 @@ namespace Spring.Aop.Framework.DynamicProxy get { return m_advised.Interfaces; } } - IDictionary IAdvised.InterfaceMap + IDictionary IAdvised.InterfaceMap { get { return m_advised.InterfaceMap; } } diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseAopProxyMethodBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseAopProxyMethodBuilder.cs index 42d3638d..a9a911ed 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseAopProxyMethodBuilder.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseAopProxyMethodBuilder.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * 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. @@ -18,16 +18,12 @@ #endregion -#region Imports - -using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using Spring.Util; -#endregion - namespace Spring.Aop.Framework.DynamicProxy { /// @@ -37,8 +33,6 @@ namespace Spring.Aop.Framework.DynamicProxy /// Bruno Baia public class BaseAopProxyMethodBuilder : AbstractAopProxyMethodBuilder { - #region Constructor(s) / Destructor - /// /// Creates a new instance of the method builder. /// @@ -56,15 +50,11 @@ namespace Spring.Aop.Framework.DynamicProxy /// public BaseAopProxyMethodBuilder( TypeBuilder typeBuilder, IAopProxyTypeGenerator aopProxyGenerator, - IDictionary targetMethods, IDictionary onProxyTargetMethods) + IDictionary targetMethods, IDictionary onProxyTargetMethods) : base(typeBuilder, aopProxyGenerator, false, targetMethods, onProxyTargetMethods) { } - #endregion - - #region Protected Methods - /// /// Create static field that will cache target method when defined on the proxy. /// @@ -101,7 +91,7 @@ namespace Spring.Aop.Framework.DynamicProxy onProxyTargetMethods.Add(methodId, method); onProxyTargetMethodCacheField = typeBuilder.DefineField( - methodId, typeof(MethodInfo), FieldAttributes.Private | FieldAttributes.Static | FieldAttributes.InitOnly); + methodId, typeof(MethodInfo), FieldAttributes.Private | FieldAttributes.Static); MakeGenericMethod(il, method, onProxyTargetMethodCacheField, genericOnProxyTargetMethod); } @@ -120,7 +110,5 @@ namespace Spring.Aop.Framework.DynamicProxy { CallDirectBaseMethod(il, method); } - - #endregion } } diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs index 8849464d..cab04055 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs @@ -18,18 +18,14 @@ #endregion -#region Imports - using System; -using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.Serialization; using Spring.Util; -#endregion - namespace Spring.Aop.Framework.DynamicProxy { /// @@ -39,16 +35,10 @@ namespace Spring.Aop.Framework.DynamicProxy /// Bruno Baia public class CompositionAopProxyTypeBuilder : AbstractAopProxyTypeBuilder { - #region Fields - - private const string PROXY_TYPE_NAME = "CompositionAopProxy"; + private const string PROXY_TYPE_NAME = "CompositionAopProxy"; private readonly IAdvised advised; - #endregion - - #region Constructor (s) / Destructor - /// /// Creates a new instance of the /// class. @@ -65,17 +55,13 @@ namespace Spring.Aop.Framework.DynamicProxy ProxyTargetAttributes = advised.ProxyTargetAttributes; } - #endregion - - #region IProxyTypeBuilder Members - /// /// Creates the proxy type. /// /// The generated proxy type. public override Type BuildProxyType() { - IDictionary targetMethods = new Hashtable(); + Dictionary targetMethods = new Dictionary(); TypeBuilder typeBuilder = CreateTypeBuilder(Name, BaseType); @@ -93,11 +79,11 @@ namespace Spring.Aop.Framework.DynamicProxy ImplementConstructors(typeBuilder); // implement interfaces - IDictionary interfaceMap = advised.InterfaceMap; + IDictionary interfaceMap = advised.InterfaceMap; foreach (Type intf in Interfaces) { - object target = interfaceMap[intf]; - if (target == null) + interfaceMap.TryGetValue(intf, out var target); + if (target is null) { // implement interface ImplementInterface(typeBuilder, @@ -112,24 +98,19 @@ namespace Spring.Aop.Framework.DynamicProxy intf, TargetType); } } - - Type proxyType; - proxyType = typeBuilder.CreateTypeInfo(); + + Type proxyType = typeBuilder.CreateTypeInfo(); // set target method references - foreach (DictionaryEntry entry in targetMethods) + foreach (KeyValuePair entry in targetMethods) { - FieldInfo field = proxyType.GetField((string) entry.Key, BindingFlags.NonPublic | BindingFlags.Static); + FieldInfo field = proxyType.GetField(entry.Key, BindingFlags.NonPublic | BindingFlags.Static); field.SetValue(proxyType, entry.Value); } return proxyType; } - #endregion - - #region IAopProxyTypeGenerator Members - /// /// Generates the IL instructions that pushes /// the current @@ -141,10 +122,6 @@ namespace Spring.Aop.Framework.DynamicProxy il.Emit(OpCodes.Ldarg_0); } - #endregion - - #region Protected Methods - /// /// Implements serialization constructor. /// @@ -189,10 +166,6 @@ namespace Spring.Aop.Framework.DynamicProxy il.Emit(OpCodes.Ret); } - #endregion - - #region Public Methods - /// /// Determines if the specified /// is one of those generated by this builder. @@ -206,7 +179,5 @@ namespace Spring.Aop.Framework.DynamicProxy { return type.FullName.StartsWith(PROXY_TYPE_NAME); } - - #endregion - } + } } \ No newline at end of file diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs index ca9314ac..320c2136 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * 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. @@ -18,10 +18,8 @@ #endregion -#region Imports - using System; -using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.Serialization; @@ -29,8 +27,6 @@ using System.Runtime.Serialization; using Spring.Util; using Spring.Proxy; -#endregion - namespace Spring.Aop.Framework.DynamicProxy { /// @@ -39,8 +35,6 @@ namespace Spring.Aop.Framework.DynamicProxy /// Bruno Baia public class DecoratorAopProxyTypeBuilder : AbstractAopProxyTypeBuilder { - #region Fields - private const string PROXY_TYPE_NAME = "DecoratorAopProxy"; private IAdvised advised; @@ -49,10 +43,6 @@ namespace Spring.Aop.Framework.DynamicProxy /// AdvisedProxy instance calls should be delegated to. /// protected FieldBuilder advisedProxyField; - - #endregion - - #region Constructor (s) / Destructor /// /// Creates a new instance of the @@ -82,17 +72,13 @@ namespace Spring.Aop.Framework.DynamicProxy ProxyTargetAttributes = advised.ProxyTargetAttributes; } - #endregion - - #region IProxyTypeBuilder Members - /// /// Creates the proxy type. /// /// The generated proxy class. public override Type BuildProxyType() { - IDictionary targetMethods = new Hashtable(); + var targetMethods = new Dictionary(); TypeBuilder typeBuilder = CreateTypeBuilder(Name, BaseType); @@ -115,11 +101,11 @@ namespace Spring.Aop.Framework.DynamicProxy ImplementConstructors(typeBuilder); // implement interfaces - IDictionary interfaceMap = advised.InterfaceMap; + var interfaceMap = advised.InterfaceMap; foreach (Type intf in Interfaces) { - object target = interfaceMap[intf]; - if (target == null) + interfaceMap.TryGetValue(intf, out var target); + if (target is null) { // implement interface (proxy only final methods) ImplementInterface(typeBuilder, @@ -148,23 +134,18 @@ namespace Spring.Aop.Framework.DynamicProxy // implement IAopProxy interface ImplementIAopProxy(typeBuilder); - Type proxyType; - proxyType = typeBuilder.CreateTypeInfo(); + Type proxyType = typeBuilder.CreateTypeInfo(); // set target method references - foreach (DictionaryEntry entry in targetMethods) + foreach (var entry in targetMethods) { - FieldInfo field = proxyType.GetField((string)entry.Key, BindingFlags.NonPublic | BindingFlags.Static); + FieldInfo field = proxyType.GetField(entry.Key, BindingFlags.NonPublic | BindingFlags.Static); field.SetValue(proxyType, entry.Value); } return proxyType; } - #endregion - - #region IAopProxyTypeGenerator Members - /// /// Generates the IL instructions that pushes /// the current @@ -177,10 +158,6 @@ namespace Spring.Aop.Framework.DynamicProxy il.Emit(OpCodes.Ldfld, advisedProxyField); } - #endregion - - #region Protected Methods - /// /// Declares field that holds the /// instance used by the proxy. @@ -293,10 +270,6 @@ namespace Spring.Aop.Framework.DynamicProxy typeBuilder.DefineMethodOverride(mb, getProxyMethod); } - #endregion - - #region Public Methods - /// /// Determines if the specified /// is one of those generated by this builder. @@ -310,7 +283,5 @@ namespace Spring.Aop.Framework.DynamicProxy { return type.FullName.StartsWith(PROXY_TYPE_NAME); } - - #endregion } } \ No newline at end of file diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs index 26256398..e0d0c701 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * 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. @@ -18,10 +18,8 @@ #endregion -#region Imports - using System; -using System.Collections; +using System.Collections.Generic; using System.Runtime.Serialization; using System.Reflection; using System.Reflection.Emit; @@ -29,8 +27,6 @@ using System.Reflection.Emit; using Spring.Proxy; using Spring.Util; -#endregion - namespace Spring.Aop.Framework.DynamicProxy { /// @@ -39,8 +35,6 @@ namespace Spring.Aop.Framework.DynamicProxy /// Bruno Baia public class InheritanceAopProxyTypeBuilder : AbstractAopProxyTypeBuilder { - #region Fields - private const string PROXY_TYPE_NAME = "InheritanceAopProxy"; private IAdvised advised; @@ -49,11 +43,7 @@ namespace Spring.Aop.Framework.DynamicProxy /// /// AdvisedProxy instance calls should be delegated to. /// - protected FieldBuilder advisedProxyField; - - #endregion - - #region Properties + protected FieldBuilder advisedProxyField; /// /// Gets or sets a value indicating whether inherited members should be proxied. @@ -68,10 +58,6 @@ namespace Spring.Aop.Framework.DynamicProxy set { proxyDeclaredMembersOnly = value; } } - #endregion - - #region Constructor (s) / Destructor - /// /// Creates a new instance of the /// class. @@ -100,18 +86,14 @@ namespace Spring.Aop.Framework.DynamicProxy ProxyTargetAttributes = advised.ProxyTargetAttributes; } - #endregion - - #region IProxyTypeBuilder Members - /// /// Creates the proxy type. /// /// The generated proxy class. public override Type BuildProxyType() { - IDictionary targetMethods = new Hashtable(); - IDictionary proxyMethods = new Hashtable(); + var targetMethods = new Dictionary(); + var proxyMethods = new Dictionary(); TypeBuilder typeBuilder = CreateTypeBuilder(Name, BaseType); @@ -134,7 +116,7 @@ namespace Spring.Aop.Framework.DynamicProxy ImplementConstructors(typeBuilder); // implement interfaces - IDictionary interfaceMap = advised.InterfaceMap; + var interfaceMap = advised.InterfaceMap; foreach (Type intf in Interfaces) { object target = interfaceMap[intf]; @@ -171,27 +153,23 @@ namespace Spring.Aop.Framework.DynamicProxy proxyType = typeBuilder.CreateTypeInfo(); // set target method references - foreach (DictionaryEntry entry in targetMethods) + foreach (var entry in targetMethods) { - FieldInfo field = proxyType.GetField((string)entry.Key, BindingFlags.NonPublic | BindingFlags.Static); + FieldInfo field = proxyType.GetField(entry.Key, BindingFlags.NonPublic | BindingFlags.Static); field.SetValue(proxyType, entry.Value); } // set proxy method references - foreach (DictionaryEntry entry in proxyMethods) + foreach (var entry in proxyMethods) { - FieldInfo field = proxyType.GetField((string)entry.Key, BindingFlags.NonPublic | BindingFlags.Static); - MethodInfo proxyMethod = proxyType.GetMethod("proxy_" + (string)entry.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + FieldInfo field = proxyType.GetField(entry.Key, BindingFlags.NonPublic | BindingFlags.Static); + MethodInfo proxyMethod = proxyType.GetMethod("proxy_" + entry.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); field.SetValue(proxyType, proxyMethod); } return proxyType; } - #endregion - - #region IAopProxyTypeGenerator Members - /// /// Generates the IL instructions that pushes /// the target instance on which calls should be delegated to. @@ -214,10 +192,6 @@ namespace Spring.Aop.Framework.DynamicProxy il.Emit(OpCodes.Ldfld, advisedProxyField); } - #endregion - - #region Protected Methods - /// /// Declares field that holds the /// instance used by the proxy. @@ -346,10 +320,6 @@ namespace Spring.Aop.Framework.DynamicProxy typeBuilder.DefineMethodOverride(mb, getProxyMethod); } - #endregion - - #region Public Methods - /// /// Determines if the specified /// is one of those generated by this builder. @@ -363,7 +333,5 @@ namespace Spring.Aop.Framework.DynamicProxy { return type.FullName.StartsWith(PROXY_TYPE_NAME); } - - #endregion } } \ No newline at end of file diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IntroductionProxyMethodBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IntroductionProxyMethodBuilder.cs index 3a828ddc..5f3155ac 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IntroductionProxyMethodBuilder.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IntroductionProxyMethodBuilder.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * 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. @@ -18,14 +18,10 @@ #endregion -#region Imports - -using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; -#endregion - namespace Spring.Aop.Framework.DynamicProxy { /// @@ -36,17 +32,11 @@ namespace Spring.Aop.Framework.DynamicProxy /// Bruno Baia public class IntroductionProxyMethodBuilder : AbstractAopProxyMethodBuilder { - #region Fields - /// /// The index of the introduction to delegate call to. /// protected int index; - #endregion - - #region Constructor(s) / Destructor - /// /// Creates a new instance of the method builder. /// @@ -60,16 +50,12 @@ namespace Spring.Aop.Framework.DynamicProxy /// index of the introduction to delegate call to public IntroductionProxyMethodBuilder( TypeBuilder typeBuilder, IAopProxyTypeGenerator aopProxyGenerator, - IDictionary targetMethods, int index) + IDictionary targetMethods, int index) : base(typeBuilder, aopProxyGenerator, true, targetMethods) { this.index = index; } - #endregion - - #region Protected Methods - /// /// Generates the IL instructions that pushes /// the introduction type on stack. @@ -107,7 +93,5 @@ namespace Spring.Aop.Framework.DynamicProxy { CallDirectTargetMethod(il, interfaceMethod); } - - #endregion } } diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/TargetAopProxyMethodBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/TargetAopProxyMethodBuilder.cs index da923d1a..3d37b3fa 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/TargetAopProxyMethodBuilder.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/TargetAopProxyMethodBuilder.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * 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. @@ -18,14 +18,10 @@ #endregion -#region Imports - -using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; -#endregion - namespace Spring.Aop.Framework.DynamicProxy { /// @@ -36,17 +32,11 @@ namespace Spring.Aop.Framework.DynamicProxy /// Bruno Baia public class TargetAopProxyMethodBuilder : AbstractAopProxyMethodBuilder { - #region Fields - /// /// The local variable to store the target instance. /// protected LocalBuilder target; - #endregion - - #region Constructor(s) / Destructor - /// /// Creates a new instance of the method builder. /// @@ -63,15 +53,11 @@ namespace Spring.Aop.Framework.DynamicProxy /// s. /// public TargetAopProxyMethodBuilder(TypeBuilder typeBuilder, - IAopProxyTypeGenerator aopProxyGenerator, bool explicitImplementation, IDictionary targetMethods) + IAopProxyTypeGenerator aopProxyGenerator, bool explicitImplementation, IDictionary targetMethods) : base(typeBuilder, aopProxyGenerator, explicitImplementation, targetMethods) { } - #endregion - - #region Protected Methods - /// /// Creates local variable declarations. /// @@ -137,7 +123,5 @@ namespace Spring.Aop.Framework.DynamicProxy else CallDirectTargetMethod(il, method); } - - #endregion } } diff --git a/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs b/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs index f372be8b..b73fd0c0 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * 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. @@ -18,18 +18,13 @@ #endregion -#region Imports - using System; -using System.Collections; using System.Collections.Generic; using AopAlliance.Aop; using Spring.Proxy; -#endregion - namespace Spring.Aop.Framework { /// @@ -148,7 +143,7 @@ namespace Spring.Aop.Framework /// The mapping of the proxied interface /// s to their delegates. /// - IDictionary InterfaceMap { get; } + IDictionary InterfaceMap { get; } /// /// Is this configuration frozen? diff --git a/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassEnhancer.cs b/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassEnhancer.cs index 9ae6fb61..02d256dd 100644 --- a/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassEnhancer.cs +++ b/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassEnhancer.cs @@ -163,7 +163,7 @@ namespace Spring.Context.Attributes // declare interceptor field interceptorField = typeBuilder.DefineField("__Interceptor", typeof(IConfigurationClassInterceptor), - FieldAttributes.Private | FieldAttributes.Static | FieldAttributes.InitOnly); + FieldAttributes.Private | FieldAttributes.Static); // create constructors ImplementConstructors(typeBuilder); @@ -235,7 +235,7 @@ namespace Spring.Context.Attributes string methodId = "_m" + Guid.NewGuid().ToString("N"); targetMethods.Add(methodId, method); FieldBuilder targetMethodCacheField = typeBuilder.DefineField(methodId, typeof(MethodInfo), - FieldAttributes.Private | FieldAttributes.Static | FieldAttributes.InitOnly); + FieldAttributes.Private | FieldAttributes.Static); // Call IConfigurationClassInterceptor.TryGetObject method il.Emit(OpCodes.Ldnull); diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/IsModifiedMixin.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/IsModifiedMixin.cs index 4ab1a2bf..a2d04c26 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/IsModifiedMixin.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/IsModifiedMixin.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * 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. diff --git a/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.csproj b/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.csproj index ff0e7de4..6e772f13 100644 --- a/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.csproj +++ b/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;$(TargetFullFrameworkVersion) + netcoreapp3.0;$(TargetFullFrameworkVersion) @@ -16,7 +16,7 @@ - + diff --git a/test/Spring/Spring.Benchmark/Spring.Benchmark.csproj b/test/Spring/Spring.Benchmark/Spring.Benchmark.csproj index 9687bb2a..69df9ad6 100644 --- a/test/Spring/Spring.Benchmark/Spring.Benchmark.csproj +++ b/test/Spring/Spring.Benchmark/Spring.Benchmark.csproj @@ -2,7 +2,7 @@ Exe - net472;netcoreapp2.1 + net472;netcoreapp3.0 Spring.Benchmark diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj index 8dff6bbc..0bcb149d 100644 --- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj +++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;$(TargetFullFrameworkVersion) + netcoreapp3.0;$(TargetFullFrameworkVersion) @@ -30,7 +30,7 @@ - + @@ -40,6 +40,7 @@ + diff --git a/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.csproj b/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.csproj index 6221192a..cd411d05 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.csproj +++ b/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;$(TargetFullFrameworkVersion) + netcoreapp3.0;$(TargetFullFrameworkVersion) @@ -21,8 +21,8 @@ - - + + diff --git a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate5.Integration.Tests.csproj b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate5.Integration.Tests.csproj index 8d301552..d4e6fa66 100644 --- a/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate5.Integration.Tests.csproj +++ b/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate5.Integration.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;net461 + netcoreapp3.0;net461 @@ -15,7 +15,7 @@ - + diff --git a/test/Spring/Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate5.Tests.csproj b/test/Spring/Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate5.Tests.csproj index e940656c..e6c98126 100644 --- a/test/Spring/Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate5.Tests.csproj +++ b/test/Spring/Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate5.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;net461 + netcoreapp3.0;net461 diff --git a/test/Spring/Spring.Data.Tests/Spring.Data.Tests.csproj b/test/Spring/Spring.Data.Tests/Spring.Data.Tests.csproj index 607202e3..10e40358 100644 --- a/test/Spring/Spring.Data.Tests/Spring.Data.Tests.csproj +++ b/test/Spring/Spring.Data.Tests/Spring.Data.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;$(TargetFullFrameworkVersion) + netcoreapp3.0;$(TargetFullFrameworkVersion) false @@ -22,8 +22,8 @@ - - + + diff --git a/test/Spring/Spring.Messaging.Nms.Integration.Tests/App.config b/test/Spring/Spring.Messaging.Nms.Integration.Tests/App.config deleted file mode 100644 index 6321cfbf..00000000 --- a/test/Spring/Spring.Messaging.Nms.Integration.Tests/App.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/test/Spring/Spring.Messaging.Nms.Integration.Tests/Spring.Messaging.Nms.Integration.Tests.csproj b/test/Spring/Spring.Messaging.Nms.Integration.Tests/Spring.Messaging.Nms.Integration.Tests.csproj index 04a8b072..f3ad1354 100644 --- a/test/Spring/Spring.Messaging.Nms.Integration.Tests/Spring.Messaging.Nms.Integration.Tests.csproj +++ b/test/Spring/Spring.Messaging.Nms.Integration.Tests/Spring.Messaging.Nms.Integration.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;net452 + netcoreapp3.0;net452 diff --git a/test/Spring/Spring.Messaging.Nms.Tests/Spring.Messaging.Nms.Tests.csproj b/test/Spring/Spring.Messaging.Nms.Tests/Spring.Messaging.Nms.Tests.csproj index 03a2edad..29b7b903 100644 --- a/test/Spring/Spring.Messaging.Nms.Tests/Spring.Messaging.Nms.Tests.csproj +++ b/test/Spring/Spring.Messaging.Nms.Tests/Spring.Messaging.Nms.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;net452 + netcoreapp3.0;net452 diff --git a/test/Spring/Spring.Scheduling.Quartz3.Integration.Tests/Spring.Scheduling.Quartz3.Integration.Tests.csproj b/test/Spring/Spring.Scheduling.Quartz3.Integration.Tests/Spring.Scheduling.Quartz3.Integration.Tests.csproj index 87bb9c0b..bda5b5e7 100644 --- a/test/Spring/Spring.Scheduling.Quartz3.Integration.Tests/Spring.Scheduling.Quartz3.Integration.Tests.csproj +++ b/test/Spring/Spring.Scheduling.Quartz3.Integration.Tests/Spring.Scheduling.Quartz3.Integration.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;$(TargetFullFrameworkVersion) + netcoreapp3.0;$(TargetFullFrameworkVersion) diff --git a/test/Spring/Spring.Scheduling.Quartz3.Tests/Spring.Scheduling.Quartz3.Tests.csproj b/test/Spring/Spring.Scheduling.Quartz3.Tests/Spring.Scheduling.Quartz3.Tests.csproj index 6901c20a..96c0aea3 100644 --- a/test/Spring/Spring.Scheduling.Quartz3.Tests/Spring.Scheduling.Quartz3.Tests.csproj +++ b/test/Spring/Spring.Scheduling.Quartz3.Tests/Spring.Scheduling.Quartz3.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;$(TargetFullFrameworkVersion) + netcoreapp3.0;$(TargetFullFrameworkVersion) diff --git a/test/Spring/Spring.Testing.NUnit.Tests/Spring.Testing.NUnit.Tests.csproj b/test/Spring/Spring.Testing.NUnit.Tests/Spring.Testing.NUnit.Tests.csproj index e991f12b..3364dd5d 100644 --- a/test/Spring/Spring.Testing.NUnit.Tests/Spring.Testing.NUnit.Tests.csproj +++ b/test/Spring/Spring.Testing.NUnit.Tests/Spring.Testing.NUnit.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1;$(TargetFullFrameworkVersion) + netcoreapp3.0;$(TargetFullFrameworkVersion)