Skip to content

Commit 10247ff

Browse files
committed
make changes to get Spring.Aop work under .NET Core
1 parent 442688c commit 10247ff

19 files changed

+159
-315
lines changed

Spring.build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ Commandline Examples:
416416

417417
<exec program="dotnet" verbose="true">
418418
<arg line="test" />
419+
<arg line="/nodeReuse:false" />
419420
<arg line="-c ${current.build.config}" />
420421
<arg line="-f netcoreapp2.1" />
421422
<arg line="${file}" />
@@ -425,7 +426,7 @@ Commandline Examples:
425426
</target>
426427

427428
<target name="compile-net-4.5" description="Builds .NET Framework 4.5 version"
428-
depends="set-net-4.5-runtime-configuration, check-spring-basedir, clean-current-bin-dir, restore-nuget-packages">
429+
depends="set-net-4.5-runtime-configuration, check-spring-basedir, restore-nuget-packages">
429430

430431
<property name="test.withcoverage" value="false" overwrite="true"/>
431432

@@ -469,7 +470,7 @@ Commandline Examples:
469470
</target>
470471

471472
<target name="compile-mono-2.0" description="Builds MONO Framework 2.0 version"
472-
depends="set-mono-2.0-runtime-configuration, check-spring-basedir, clean-current-bin-dir">
473+
depends="set-mono-2.0-runtime-configuration, check-spring-basedir">
473474
<call target="copykeys" if="${project.build.sign}"/>
474475
<call target="common.generate-assemblyinfo"/>
475476
<property name="build-ems" value="false" overwrite="true" />

Spring.include

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,6 @@
151151
</if>
152152
</target>
153153
<!-- Targets for cleaning up -->
154-
<target name="clean-current-bin-dir" depends="check-current-bin-dir"
155-
description="Cleans the current binaries directory">
156-
<echo message="Cleaning the ${current.bin.dir} binaries directory."/>
157-
<delete dir="${current.bin.dir}" if="${directory::exists(current.bin.dir)}"/>
158-
<mkdir dir="${current.bin.dir}"/>
159-
</target>
160154
<target name="clean-current-sdkdoc-dir" depends="check-current-sdkdoc-dir"
161155
description="Cleans the current SDK documentation directory">
162156
<echo message="Cleaning the ${current.sdkdoc.dir} SDK documentation directory."/>

src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#region License
2-
31
/*
42
* Copyright © 2002-2011 the original author or authors.
53
*
@@ -16,13 +14,10 @@
1614
* limitations under the License.
1715
*/
1816

19-
#endregion
20-
21-
#region Imports
22-
2317
using System;
2418
using System.Collections;
2519
using System.Collections.Generic;
20+
using System.Runtime.Serialization;
2621

2722
using AopAlliance.Aop;
2823

@@ -34,8 +29,6 @@
3429
using Spring.Aop.Framework.DynamicProxy;
3530
using Spring.Core;
3631

37-
#endregion
38-
3932
namespace Spring.Aop.Framework.AutoProxy
4033
{
4134
/// <summary>
@@ -46,8 +39,6 @@ namespace Spring.Aop.Framework.AutoProxy
4639
/// <author>Bruno Baia</author>
4740
public class InheritanceBasedAopConfigurer : IObjectFactoryPostProcessor, IObjectFactoryAware, IOrdered
4841
{
49-
#region Fields
50-
5142
private IList objectNames;
5243
private string[] interceptorNames = new string[0];
5344
private bool proxyTargetAttributes = true;
@@ -58,10 +49,6 @@ public class InheritanceBasedAopConfigurer : IObjectFactoryPostProcessor, IObjec
5849
private int order = int.MaxValue;
5950
private IAdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.Instance;
6051

61-
#endregion
62-
63-
#region Properties
64-
6552
/// <summary>
6653
/// Set the names of the objects in IList fashioned way
6754
/// that should automatically get intercepted.
@@ -134,10 +121,6 @@ public bool ProxyInterfaces
134121
set { proxyInterfaces = value; }
135122
}
136123

137-
#endregion
138-
139-
#region IObjectFactoryAware Members
140-
141124
/// <summary>
142125
/// Callback that supplies the owning factory to an object instance.
143126
/// </summary>
@@ -162,10 +145,6 @@ public IObjectFactory ObjectFactory
162145
set { objectFactory = value; }
163146
}
164147

165-
#endregion
166-
167-
#region IObjectFactoryPostProcessor Members
168-
169148
/// <summary>
170149
/// Allows for custom modification of an application context's object definitions.
171150
/// </summary>
@@ -201,10 +180,6 @@ public void PostProcessObjectFactory(IConfigurableListableObjectFactory factory)
201180
}
202181
}
203182

204-
#endregion
205-
206-
#region IOrdered Members
207-
208183
/// <summary>
209184
/// Return the order value of this object, where a higher value means greater in
210185
/// terms of sorting.
@@ -221,10 +196,6 @@ public virtual int Order
221196
set { order = value; }
222197
}
223198

224-
#endregion
225-
226-
#region Protected methods
227-
228199
/// <summary>
229200
/// Determines whether the object is an infrastructure type,
230201
/// IAdvisor, IAdvice, IAdvisors, AbstractAutoProxyCreator or InheritanceBasedAopConfigurer.
@@ -302,10 +273,6 @@ protected virtual bool IsObjectNameMatch(string objectName)
302273
return false;
303274
}
304275

305-
#endregion
306-
307-
#region Private Methods
308-
309276
private IList<IAdvisor> ResolveInterceptorNames()
310277
{
311278
List<IAdvisor> advisors = new List<IAdvisor>();
@@ -324,12 +291,8 @@ private IList<IAdvisor> ResolveInterceptorNames()
324291
return advisors;
325292
}
326293

327-
#endregion
328-
329-
#region InheritanceBasedAopTargetSource inner class definition
330-
331294
[Serializable]
332-
private class InheritanceBasedAopTargetSource : ITargetSource
295+
private class InheritanceBasedAopTargetSource : ITargetSource, ISerializable
333296
{
334297
private readonly Type _targetType;
335298

@@ -338,7 +301,19 @@ public InheritanceBasedAopTargetSource(Type targetType)
338301
_targetType = targetType;
339302
}
340303

341-
#region ITargetSource Members
304+
305+
/// <inheritdoc />
306+
private InheritanceBasedAopTargetSource(SerializationInfo info, StreamingContext context)
307+
{
308+
var type = info.GetString("TargetType");
309+
_targetType = type != null ? Type.GetType(type) : null;
310+
}
311+
312+
/// <inheritdoc />
313+
public void GetObjectData(SerializationInfo info, StreamingContext context)
314+
{
315+
info.AddValue("TargetType", _targetType?.AssemblyQualifiedName);
316+
}
342317

343318
public object GetTarget()
344319
{
@@ -358,10 +333,6 @@ public Type TargetType
358333
{
359334
get { return _targetType; }
360335
}
361-
362-
#endregion
363336
}
364-
365-
#endregion
366337
}
367338
}

src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#region License
2-
31
/*
42
* Copyright © 2002-2011 the original author or authors.
53
*
@@ -16,8 +14,6 @@
1614
* limitations under the License.
1715
*/
1816

19-
#endregion
20-
2117
using System;
2218
using System.Collections;
2319
using System.Collections.Generic;
@@ -37,10 +33,8 @@ namespace Spring.Aop.Framework.DynamicProxy
3733
/// </summary>
3834
/// <author>Bruno Baia</author>
3935
[Serializable]
40-
public class AdvisedProxy : IAdvised //, ISerializable
36+
public class AdvisedProxy : IAdvised, ISerializable
4137
{
42-
#region Fields
43-
4438
/// <summary>
4539
/// Should we use dynamic reflection for method invocation ?
4640
/// </summary>
@@ -71,10 +65,6 @@ public class AdvisedProxy : IAdvised //, ISerializable
7165
/// </summary>
7266
public Type m_targetType;
7367

74-
#endregion
75-
76-
#region Constructor (s) / Destructor
77-
7868
/// <summary>
7969
/// Creates a new instance of the <see cref="AdvisedProxy"/> class.
8070
/// </summary>
@@ -130,7 +120,9 @@ protected AdvisedProxy(SerializationInfo info, StreamingContext context)
130120
m_advised = (IAdvised)info.GetValue("advised", typeof(IAdvised));
131121
m_introductions = (IAdvice[])info.GetValue("introductions", typeof(IAdvice[]));
132122
m_targetSource = (ITargetSource)info.GetValue("targetSource", typeof(ITargetSource));
133-
m_targetType = (Type)info.GetValue("targetType", typeof(Type));
123+
124+
var type = info.GetString("targetType");
125+
m_targetType = type != null ? Type.GetType(type) : null;
134126
}
135127

136128
/// <summary>
@@ -139,18 +131,14 @@ protected AdvisedProxy(SerializationInfo info, StreamingContext context)
139131
/// <param name="info">Serialization data.</param>
140132
/// <param name="context">Serialization context.</param>
141133
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
142-
protected virtual void GetObjectData(SerializationInfo info, StreamingContext context)
134+
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
143135
{
144136
info.AddValue("advised", m_advised);
145137
info.AddValue("introductions", m_introductions);
146138
info.AddValue("targetSource", m_targetSource);
147-
info.AddValue("targetType", m_targetType);
139+
info.AddValue("targetType", m_targetType?.AssemblyQualifiedName);
148140
}
149141

150-
#endregion
151-
152-
#region Protected Methods
153-
154142
/// <summary>
155143
/// Initialization method.
156144
/// </summary>
@@ -178,10 +166,6 @@ protected void Initialize(IAdvised advised, IAopProxy proxy)
178166
}
179167
}
180168

181-
#endregion
182-
183-
#region Public Methods
184-
185169
/// <summary>
186170
/// Invokes intercepted methods using reflection
187171
/// </summary>
@@ -228,10 +212,6 @@ public IList<object> GetInterceptors(Type targetType, MethodInfo method)
228212
}
229213
}
230214

231-
#endregion
232-
233-
#region IAdvised Members
234-
235215
bool IAdvised.ExposeProxy
236216
{
237217
get { return m_advised.ExposeProxy; }
@@ -400,10 +380,6 @@ string IAdvised.ToProxyConfigString()
400380
return m_advised.ToProxyConfigString();
401381
}
402382

403-
#endregion
404-
405-
#region ITargetTypeAware implementation
406-
407383
/// <summary>
408384
/// Gets the target type behind the implementing object.
409385
/// Ttypically a proxy configuration or an actual proxy.
@@ -413,7 +389,5 @@ public Type TargetType
413389
{
414390
get { return m_targetType; }
415391
}
416-
417-
#endregion
418392
}
419393
}

0 commit comments

Comments
 (0)