Skip to content

Commit f78411a

Browse files
authored
Support .NET Core 3 (#190)
* fix dynamic code generation issues * fix NmsQuickStart
1 parent 7580540 commit f78411a

File tree

30 files changed

+95
-269
lines changed

30 files changed

+95
-269
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: 1.0.{build}
2-
image: Visual Studio 2017
2+
image: Visual Studio 2019
33
services:
44
- mssql2017
55
- msmq

examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<ProjectReference Include="..\Spring.NmsQuickStart.Common\Spring.NmsQuickStart.Common.csproj" />
88
</ItemGroup>
99
<ItemGroup>
10-
<PackageReference Include="Apache.NMS.ActiveMQ" Version="1.7.2" />
1110
<PackageReference Include="Common.Logging" Version="$(CommonLoggingVersion)" />
1211
</ItemGroup>
1312
<ItemGroup>

examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<TargetFramework>net452</TargetFramework>
44
</PropertyGroup>
55
<ItemGroup>
6+
<PackageReference Include="Apache.NMS" Version="1.8.0" />
67
<PackageReference Include="Apache.NMS.ActiveMQ" Version="1.7.2" />
78
</ItemGroup>
89
<ItemGroup>

examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<ProjectReference Include="..\Spring.NmsQuickStart.Common\Spring.NmsQuickStart.Common.csproj" />
99
</ItemGroup>
1010
<ItemGroup>
11-
<PackageReference Include="Apache.NMS.ActiveMQ" Version="1.7.2" />
1211
<PackageReference Include="Common.Logging" Version="$(CommonLoggingVersion)" />
1312
</ItemGroup>
1413
<ItemGroup>

src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#region License
2+
13
/*
24
* Copyright © 2002-2011 the original author or authors.
35
*
@@ -14,8 +16,9 @@
1416
* limitations under the License.
1517
*/
1618

19+
#endregion
20+
1721
using System;
18-
using System.Collections;
1922
using System.Collections.Generic;
2023
using System.Reflection;
2124
using System.Runtime.Serialization;
@@ -368,13 +371,18 @@ protected void SetInterfacesInternal(IList<Type> value)
368371
/// <see cref="System.Type"/>s to their delegates.
369372
/// </value>
370373
/// <seealso cref="Spring.Aop.Framework.IAdvised.InterfaceMap"/>
371-
public virtual IDictionary InterfaceMap
374+
public virtual IDictionary<Type, object> InterfaceMap
372375
{
373376
get
374377
{
375-
lock (this.SyncRoot)
378+
lock (SyncRoot)
376379
{
377-
return new Hashtable(this.interfaceMap);
380+
var dictionary = new Dictionary<Type, object>(interfaceMap.Count);
381+
foreach (var entry in interfaceMap)
382+
{
383+
dictionary[entry.Key] = entry.Value;
384+
}
385+
return dictionary;
378386
}
379387
}
380388
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818

1919
#endregion
2020

21-
#region Imports
22-
2321
using System;
24-
using System.Collections;
2522
using System.Collections.Generic;
2623
using Common.Logging;
2724

@@ -31,8 +28,6 @@
3128

3229
using System.Linq;
3330

34-
#endregion
35-
3631
namespace Spring.Aop.Framework.AutoProxy
3732
{
3833
/// <summary>

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

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region License
22

33
/*
4-
* Copyright © 2002-2011 the original author or authors.
4+
* Copyright © 2002-2011 the original author or authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -18,18 +18,14 @@
1818

1919
#endregion
2020

21-
#region Imports
22-
2321
using System;
24-
using System.Collections;
22+
using System.Collections.Generic;
2523
using System.Reflection;
2624
using System.Reflection.Emit;
2725
using System.Runtime.Serialization;
2826

2927
using Spring.Proxy;
3028

31-
#endregion
32-
3329
namespace Spring.Aop.Framework.DynamicProxy
3430
{
3531
/// <summary>
@@ -39,8 +35,6 @@ namespace Spring.Aop.Framework.DynamicProxy
3935
/// <author>Bruno Baia</author>
4036
public abstract class AbstractAopProxyMethodBuilder : AbstractProxyMethodBuilder
4137
{
42-
#region Fields
43-
4438
/// <summary>
4539
/// The <see cref="IAopProxyTypeGenerator"/> implementation to use.
4640
/// </summary>
@@ -50,13 +44,13 @@ public abstract class AbstractAopProxyMethodBuilder : AbstractProxyMethodBuilder
5044
/// The dictionary to cache the list of target
5145
/// <see cref="System.Reflection.MethodInfo"/>s.
5246
/// </summary>
53-
protected IDictionary targetMethods;
47+
protected IDictionary<string, MethodInfo> targetMethods;
5448

5549
/// <summary>
5650
/// The dictionary to cache the list of target
5751
/// <see cref="System.Reflection.MethodInfo"/>s defined on the proxy.
5852
/// </summary>
59-
protected IDictionary onProxyTargetMethods;
53+
protected IDictionary<string, MethodInfo> onProxyTargetMethods;
6054

6155
// variables
6256

@@ -112,15 +106,11 @@ public abstract class AbstractAopProxyMethodBuilder : AbstractProxyMethodBuilder
112106

113107
// private fields
114108

115-
private static IDictionary ldindOpCodes;
116-
117-
#endregion
118-
119-
#region Constructor(s) / Destructor
109+
private static Dictionary<Type, OpCode> ldindOpCodes;
120110

121111
static AbstractAopProxyMethodBuilder()
122112
{
123-
ldindOpCodes = new Hashtable();
113+
ldindOpCodes = new Dictionary<Type, OpCode>();
124114
ldindOpCodes[typeof(sbyte)] = OpCodes.Ldind_I1;
125115
ldindOpCodes[typeof(short)] = OpCodes.Ldind_I2;
126116
ldindOpCodes[typeof(int)] = OpCodes.Ldind_I4;
@@ -152,8 +142,8 @@ static AbstractAopProxyMethodBuilder()
152142
/// </param>
153143
protected AbstractAopProxyMethodBuilder(
154144
TypeBuilder typeBuilder, IAopProxyTypeGenerator aopProxyGenerator,
155-
bool explicitImplementation, IDictionary targetMethods)
156-
: this(typeBuilder, aopProxyGenerator, explicitImplementation, targetMethods, new Hashtable())
145+
bool explicitImplementation, IDictionary<string, MethodInfo> targetMethods)
146+
: this(typeBuilder, aopProxyGenerator, explicitImplementation, targetMethods, new Dictionary<string, MethodInfo>())
157147
{
158148
}
159149

@@ -178,18 +168,14 @@ protected AbstractAopProxyMethodBuilder(
178168
/// </param>
179169
protected AbstractAopProxyMethodBuilder(
180170
TypeBuilder typeBuilder, IAopProxyTypeGenerator aopProxyGenerator,
181-
bool explicitImplementation, IDictionary targetMethods, IDictionary onProxyTargetMethods)
171+
bool explicitImplementation, IDictionary<string, MethodInfo> targetMethods, IDictionary<string, MethodInfo> onProxyTargetMethods)
182172
: base(typeBuilder, aopProxyGenerator, explicitImplementation)
183173
{
184174
this.aopProxyGenerator = aopProxyGenerator;
185175
this.targetMethods = targetMethods;
186176
this.onProxyTargetMethods = onProxyTargetMethods;
187177
}
188178

189-
#endregion
190-
191-
#region Protected Members
192-
193179
/// <summary>
194180
/// Generates the proxy method.
195181
/// </summary>
@@ -235,7 +221,7 @@ protected virtual void GenerateTargetMethodCacheField(
235221
targetMethods.Add(methodId, method);
236222

237223
targetMethodCacheField = typeBuilder.DefineField(methodId, typeof(MethodInfo),
238-
FieldAttributes.Private | FieldAttributes.Static | FieldAttributes.InitOnly);
224+
FieldAttributes.Private | FieldAttributes.Static);
239225

240226
MakeGenericMethod(il, method, targetMethodCacheField, genericTargetMethod);
241227
}
@@ -362,7 +348,7 @@ protected virtual void PushOnProxyTargetMethodInfo(ILGenerator il, MethodInfo me
362348
/// <param name="method">The method to proxy.</param>
363349
protected virtual void DeclareLocals(ILGenerator il, MethodInfo method)
364350
{
365-
interceptors = il.DeclareLocal(typeof(IList));
351+
interceptors = il.DeclareLocal(typeof(System.Collections.IList));
366352
targetType = il.DeclareLocal(typeof(Type));
367353
arguments = il.DeclareLocal(typeof(Object[]));
368354

@@ -604,10 +590,6 @@ protected virtual void EndMethod(ILGenerator il, MethodInfo method)
604590
il.Emit(OpCodes.Ldloc, returnValue);
605591
}
606592
}
607-
608-
#endregion
609-
610-
#region Reflection.Emit utility methods
611593

612594
/// <summary>
613595
/// Emits MSIL instructions to load a value of the specified <paramref name="type"/>
@@ -675,12 +657,8 @@ protected static void EmitUnboxIfNeeded(ILGenerator il, Type type)
675657
il.Emit(OpCodes.Unbox_Any, type);
676658
}
677659
}
678-
679-
#endregion
680660
}
681661

682-
#region References helper class definition
683-
684662
internal struct References
685663
{
686664
// fields
@@ -723,7 +701,7 @@ internal struct References
723701
typeof(AopContext).GetMethod("PopProxy", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null);
724702

725703
public static readonly MethodInfo InvokeMethod =
726-
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);
704+
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);
727705

728706
public static readonly MethodInfo GetInterceptorsMethod =
729707
typeof(AdvisedProxy).GetMethod("GetInterceptors", BindingFlags.Instance | BindingFlags.Public, null, new Type[] { typeof(Type), typeof(MethodInfo) }, null);
@@ -757,8 +735,6 @@ internal struct References
757735
typeof(IAdvised).GetProperty("ExposeProxy", typeof(Boolean)).GetGetMethod();
758736

759737
public static readonly MethodInfo CountProperty =
760-
typeof(ICollection).GetProperty("Count", typeof(Int32)).GetGetMethod();
738+
typeof(System.Collections.ICollection).GetProperty("Count", typeof(Int32)).GetGetMethod();
761739
}
762-
763-
#endregion
764740
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2002-2011 the original author or authors.
2+
* Copyright © 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -247,7 +247,7 @@ IList<Type> IAdvised.Interfaces
247247
get { return m_advised.Interfaces; }
248248
}
249249

250-
IDictionary IAdvised.InterfaceMap
250+
IDictionary<Type, object> IAdvised.InterfaceMap
251251
{
252252
get { return m_advised.InterfaceMap; }
253253
}

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region License
22

33
/*
4-
* Copyright © 2002-2011 the original author or authors.
4+
* Copyright © 2002-2011 the original author or authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -18,16 +18,12 @@
1818

1919
#endregion
2020

21-
#region Imports
22-
23-
using System.Collections;
21+
using System.Collections.Generic;
2422
using System.Reflection;
2523
using System.Reflection.Emit;
2624

2725
using Spring.Util;
2826

29-
#endregion
30-
3127
namespace Spring.Aop.Framework.DynamicProxy
3228
{
3329
/// <summary>
@@ -37,8 +33,6 @@ namespace Spring.Aop.Framework.DynamicProxy
3733
/// <author>Bruno Baia</author>
3834
public class BaseAopProxyMethodBuilder : AbstractAopProxyMethodBuilder
3935
{
40-
#region Constructor(s) / Destructor
41-
4236
/// <summary>
4337
/// Creates a new instance of the method builder.
4438
/// </summary>
@@ -56,15 +50,11 @@ public class BaseAopProxyMethodBuilder : AbstractAopProxyMethodBuilder
5650
/// </param>
5751
public BaseAopProxyMethodBuilder(
5852
TypeBuilder typeBuilder, IAopProxyTypeGenerator aopProxyGenerator,
59-
IDictionary targetMethods, IDictionary onProxyTargetMethods)
53+
IDictionary<string, MethodInfo> targetMethods, IDictionary<string, MethodInfo> onProxyTargetMethods)
6054
: base(typeBuilder, aopProxyGenerator, false, targetMethods, onProxyTargetMethods)
6155
{
6256
}
6357

64-
#endregion
65-
66-
#region Protected Methods
67-
6858
/// <summary>
6959
/// Create static field that will cache target method when defined on the proxy.
7060
/// </summary>
@@ -101,7 +91,7 @@ protected override void GenerateOnProxyTargetMethodCacheField(
10191
onProxyTargetMethods.Add(methodId, method);
10292

10393
onProxyTargetMethodCacheField = typeBuilder.DefineField(
104-
methodId, typeof(MethodInfo), FieldAttributes.Private | FieldAttributes.Static | FieldAttributes.InitOnly);
94+
methodId, typeof(MethodInfo), FieldAttributes.Private | FieldAttributes.Static);
10595

10696
MakeGenericMethod(il, method, onProxyTargetMethodCacheField, genericOnProxyTargetMethod);
10797
}
@@ -120,7 +110,5 @@ protected override void CallDirectProxiedMethod(
120110
{
121111
CallDirectBaseMethod(il, method);
122112
}
123-
124-
#endregion
125113
}
126114
}

0 commit comments

Comments
 (0)