Skip to content

Commit 442688c

Browse files
committed
create some workarounds
1 parent e0ff80e commit 442688c

25 files changed

+192
-198
lines changed

Spring.build

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ Commandline Examples:
375375
</items>
376376
</in>
377377
<do>
378-
<echo message="Running tests for ${path}" />
378+
<echo message="Running .NET Framework tests for ${path}" />
379379
<property name="test.bin.dir" value="${path}/net452" />
380380
<property name="test.assemblyname" value="${string::substring(path, string::last-index-of(path, '\') + 1, string::get-length(path) - string::last-index-of(path, '\') - 1)}" />
381381
<property name="test.assemblyfile" value="${test.assemblyname}.dll" />
@@ -384,6 +384,9 @@ Commandline Examples:
384384
</do>
385385
</foreach>
386386

387+
<!-- run .NET Core separately for now -->
388+
<call target="compile-test-netcore" />
389+
387390
<!-- build coverage summary -->
388391
<exec program="${tool.dir}/ncoverexplorer/ncoverexplorer.console.exe" workingdir="${current.bin.dir}" failonerror="false" if="${test.coverage.tool == 'ncover' and test.withcoverage}">
389392
<arg value="/xml:&quot;${current.bin.dir}/TestCoverageSummary.xml&quot;" />
@@ -400,6 +403,27 @@ Commandline Examples:
400403
</exec>
401404
</target>
402405

406+
<target name="compile-test-netcore">
407+
<foreach item="File" property="file">
408+
<in>
409+
<items>
410+
<include name="${spring.basedir}/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj" />
411+
<include name="${spring.basedir}/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2010.csproj" />
412+
</items>
413+
</in>
414+
<do>
415+
<echo message="Running .NET Core tests for ${file}" />
416+
417+
<exec program="dotnet" verbose="true">
418+
<arg line="test" />
419+
<arg line="-c ${current.build.config}" />
420+
<arg line="-f netcoreapp2.1" />
421+
<arg line="${file}" />
422+
</exec>
423+
</do>
424+
</foreach>
425+
</target>
426+
403427
<target name="compile-net-4.5" description="Builds .NET Framework 4.5 version"
404428
depends="set-net-4.5-runtime-configuration, check-spring-basedir, clean-current-bin-dir, restore-nuget-packages">
405429

build-support/solutions.build.nant

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Rebuilding Solutions using Nant and "solutions.build":
3131
<exclude name="examples/**/Spring.EmsQuickStart/*" />
3232
<exclude name="examples/**/Spring.Examples.Pool/*" />
3333
<exclude name="examples/**/SpringAir/*" />
34+
<exclude name="examples/**/Spring.WebQuickStart/*" />
3435
</items>
3536
</in>
3637
<do>

src/Spring/Spring.Core/Core/InvalidPropertyException.cs

Lines changed: 3 additions & 26 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,18 +14,12 @@
1614
* limitations under the License.
1715
*/
1816

19-
#endregion
20-
21-
#region Imports
22-
2317
using System;
2418
using System.Globalization;
2519
using System.Runtime.Serialization;
2620
using System.Security.Permissions;
2721
using Spring.Util;
2822

29-
#endregion
30-
3123
namespace Spring.Core
3224
{
3325
/// <summary>
@@ -37,8 +29,6 @@ namespace Spring.Core
3729
[Serializable]
3830
public class InvalidPropertyException : FatalReflectionException
3931
{
40-
#region Constructor (s) / Destructor
41-
4232
/// <summary>
4333
/// Creates a new instance of the
4434
/// <see cref="InvalidPropertyException"/> class.
@@ -151,14 +141,11 @@ public InvalidPropertyException(string message, Exception rootCause)
151141
protected InvalidPropertyException(SerializationInfo info, StreamingContext context)
152142
: base(info, context)
153143
{
154-
offendingObjectType = info.GetValue("ObjectType", typeof (Type)) as Type;
144+
var typeName = info.GetString("ObjectTypeName");
145+
offendingObjectType = typeName != null ? Type.GetType(typeName) : null;
155146
offendingPropertyName = info.GetString("OffendingPropertyName");
156147
}
157148

158-
#endregion
159-
160-
#region Properties
161-
162149
/// <summary>
163150
/// The <see cref="System.Type"/> that is (or rather was) the source of the
164151
/// offending property.
@@ -176,10 +163,6 @@ public string OffendingPropertyName
176163
get { return offendingPropertyName; }
177164
}
178165

179-
#endregion
180-
181-
#region Methods
182-
183166
/// <summary>
184167
/// Populates a <see cref="System.Runtime.Serialization.SerializationInfo"/> with
185168
/// the data needed to serialize the target object.
@@ -197,17 +180,11 @@ public override void GetObjectData(
197180
SerializationInfo info, StreamingContext context)
198181
{
199182
base.GetObjectData(info, context);
200-
info.AddValue("ObjectType", ObjectType, typeof (Type));
183+
info.AddValue("ObjectTypeName", ObjectType?.AssemblyQualifiedNameWithoutVersion());
201184
info.AddValue("OffendingPropertyName", OffendingPropertyName);
202185
}
203186

204-
#endregion
205-
206-
#region Fields
207-
208187
private Type offendingObjectType;
209188
private string offendingPropertyName;
210-
211-
#endregion
212189
}
213190
}

src/Spring/Spring.Core/Objects/Factory/Config/ConfigurationReader.cs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,27 @@ private static Type GetSectionHandlerType(XmlDocument document, string configSec
353353
if (xmlConfig == null)
354354
{
355355
// none specified, use machine inherited
356-
XmlDocument machineConfig = new XmlDocument();
357-
machineConfig.Load(RuntimeEnvironment.SystemConfigurationFile);
358-
xmlConfig = machineConfig.SelectSingleNode(sectionHandlerPath);
359-
if (xmlConfig == null)
356+
try
360357
{
361-
// TOOD: better throw a sensible exception in case of a missing handler configuration?
362-
handlerType = defaultConfigurationSectionHandlerType;
358+
XmlDocument machineConfig = new XmlDocument();
359+
machineConfig.Load(RuntimeEnvironment.SystemConfigurationFile);
360+
xmlConfig = machineConfig.SelectSingleNode(sectionHandlerPath);
361+
if (xmlConfig == null)
362+
{
363+
// TOOD: better throw a sensible exception in case of a missing handler configuration?
364+
handlerType = defaultConfigurationSectionHandlerType;
365+
}
366+
}
367+
catch (PlatformNotSupportedException)
368+
{
369+
if (configSectionName == "connectionStrings")
370+
{
371+
handlerType = typeof(ConnectionStringsSectionHandler);
372+
}
373+
else
374+
{
375+
handlerType = typeof(NameValueSectionHandler);
376+
}
363377
}
364378
}
365379

@@ -376,6 +390,23 @@ private static Type GetSectionHandlerType(XmlDocument document, string configSec
376390
return handlerType;
377391
}
378392

393+
private class ConnectionStringsSectionHandler : IConfigurationSectionHandler
394+
{
395+
public object Create(object parent, object configContext, XmlNode section)
396+
{
397+
var data = new ConnectionStringsSection();
398+
foreach (XmlNode node in section.ChildNodes)
399+
{
400+
var settings = new ConnectionStringSettings(
401+
node.Attributes["name"].Value,
402+
node.Attributes["connectionString"]?.Value,
403+
node.Attributes["providerName"]?.Value);
404+
data.ConnectionStrings.Add(settings);
405+
}
406+
return data;
407+
}
408+
}
409+
379410

380411
private delegate void DeserializeSectionMethod(ConfigurationSection section, XmlReader reader);
381412
private static DeserializeSectionMethod deserialized = (DeserializeSectionMethod)Delegate.CreateDelegate(typeof(DeserializeSectionMethod),

src/Spring/Spring.Core/Objects/Factory/Config/TypedStringValue.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#region Imports
2222

2323
using System;
24+
using System.Runtime.Serialization;
25+
2426
using Spring.Util;
2527
using Spring.Core.TypeResolution;
2628

@@ -48,13 +50,11 @@ namespace Spring.Objects.Factory.Config
4850
/// <author>Rick Evans (.NET)</author>
4951
/// <author>Bruno Baia (.NET)</author>
5052
[Serializable]
51-
public class TypedStringValue
53+
public class TypedStringValue : ISerializable
5254
{
5355
private string theValue;
5456
private object targetType;
5557

56-
#region Constructor (s) / Destructor
57-
5858
/// <summary>
5959
/// Creates a new instance of the
6060
/// <see cref="Spring.Objects.Factory.Config.TypedStringValue"/>
@@ -115,7 +115,12 @@ public TypedStringValue(string value, string targetTypeName)
115115
TargetTypeName = targetTypeName;
116116
}
117117

118-
#endregion
118+
protected TypedStringValue(SerializationInfo info, StreamingContext context)
119+
{
120+
var type = info.GetString("TargetTypeName");
121+
targetType = type != null ? Type.GetType(type) : null;
122+
theValue = info.GetString("Value");
123+
}
119124

120125
/// <summary>
121126
/// The value that is to be converted.
@@ -209,5 +214,20 @@ public Type ResolveTargetType()
209214
this.targetType = resolvedType;
210215
return resolvedType;
211216
}
217+
218+
public void GetObjectData(SerializationInfo info, StreamingContext context)
219+
{
220+
string targetTypeName = null;
221+
if (targetType is string x)
222+
{
223+
targetTypeName = x;
224+
}
225+
else if (targetType is Type t)
226+
{
227+
targetTypeName = t.AssemblyQualifiedNameWithoutVersion();
228+
}
229+
info.AddValue("TargetTypeName", targetTypeName);
230+
info.AddValue("Value", theValue);
231+
}
212232
}
213233
}

src/Spring/Spring.Core/Objects/Factory/NoSuchObjectDefinitionException.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ protected NoSuchObjectDefinitionException(SerializationInfo info, StreamingConte
148148
: base(info, context)
149149
{
150150
_objectName = info.GetString("ObjectName");
151-
_objectType = info.GetValue("ObjectType", typeof (Type)) as Type;
151+
var typeName = info.GetString("ObjectTypeName");
152+
_objectType = typeName != null ? Type.GetType(typeName) : null;
152153
}
153154

154155
#endregion
@@ -173,7 +174,7 @@ public override void GetObjectData(
173174
{
174175
base.GetObjectData(info, context);
175176
info.AddValue("ObjectName", ObjectName);
176-
info.AddValue("ObjectType", ObjectType);
177+
info.AddValue("ObjectTypeName", ObjectType?.AssemblyQualifiedNameWithoutVersion());
177178
}
178179

179180
#endregion

src/Spring/Spring.Core/Spring.Core.2010.csproj

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,14 @@
1313
<Reference Include="System.Configuration" />
1414
</ItemGroup>
1515
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
16-
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
17-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
18-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.0.0" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
20-
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.0.0" />
21-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
22-
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
23-
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="2.0.0" />
24-
<PackageReference Include="Microsoft.Win32.Registry" Version="4.0.0" />
25-
<PackageReference Include="System.CodeDom" Version="4.4.0" />
26-
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" />
16+
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
17+
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
18+
<PackageReference Include="System.CodeDom" Version="4.5.0" />
19+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
2720
<PackageReference Include="System.Reflection" Version="4.3.0" />
2821
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
2922
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
3023
<PackageReference Include="System.Reflection.Primitives" Version="4.3.0" />
31-
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.4.0" />
3224
</ItemGroup>
3325
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
3426
<Compile Remove="Threading\CallContextStorage.cs" />

src/Spring/Spring.Core/Util/ConfigurationUtils.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public static object GetSection(string sectionName)
6161
{
6262
try
6363
{
64-
return ConfigurationManager.GetSection(sectionName.TrimEnd('/'));
64+
var name = sectionName.TrimEnd('/');
65+
var section = ConfigurationManager.GetSection(name);
66+
return section;
6567
}
6668
catch (ConfigurationException)
6769
{

src/Spring/Spring.Core/Util/ReflectionUtils.cs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,29 +1238,20 @@ public static IList GetCustomAttributes(MemberInfo member)
12381238
}
12391239
else if (attrsData.Count > 0)
12401240
{
1241-
if (SystemUtils.Clr4Runtime)
1241+
bool hasSecurityAttribute = false;
1242+
foreach (CustomAttributeData cad in attrsData)
12421243
{
1243-
bool hasSecurityAttribute = false;
1244-
foreach (CustomAttributeData cad in attrsData)
1245-
{
1246-
if (typeof(SecurityAttribute).IsAssignableFrom(cad.Constructor.DeclaringType))
1247-
{
1248-
hasSecurityAttribute = true;
1249-
break;
1250-
}
1251-
}
1252-
if (hasSecurityAttribute)
1253-
{
1254-
attributes.AddRange(attrs);
1255-
}
1256-
else
1244+
if (typeof(SecurityAttribute).IsAssignableFrom(cad.Constructor.DeclaringType))
12571245
{
1258-
foreach (CustomAttributeData cad in attrsData)
1259-
{
1260-
attributes.Add(cad);
1261-
}
1246+
hasSecurityAttribute = true;
1247+
break;
12621248
}
12631249
}
1250+
1251+
if (hasSecurityAttribute)
1252+
{
1253+
attributes.AddRange(attrs);
1254+
}
12641255
else
12651256
{
12661257
foreach (CustomAttributeData cad in attrsData)
@@ -1645,6 +1636,7 @@ private static MemberwiseCopyHandler GetImpl(Type type)
16451636
return handler;
16461637
}
16471638

1639+
16481640
#region Field Cache Management for "MemberwiseCopy"
16491641

16501642
private const BindingFlags FIELDBINDINGS =

src/Spring/Spring.Core/Util/SystemUtils.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ public sealed class SystemUtils
3838
private static readonly object assemblyResolverLock;
3939

4040
private static readonly bool isMono;
41-
private static readonly bool isClr4;
4241

4342
static SystemUtils()
4443
{
45-
isMono = Type.GetType("Mono.Runtime") == null ? false : true;
46-
isClr4 = Environment.Version.Major == 4 ? true : false;
44+
isMono = Type.GetType("Mono.Runtime") != null;
4745
assemblyResolverLock = new object();
4846
}
4947

@@ -93,14 +91,6 @@ public static bool MonoRuntime
9391
get { return isMono; }
9492
}
9593

96-
/// <summary>
97-
/// Returns true if running on CLR 4.0 under InProc SxS mode
98-
/// </summary>
99-
public static bool Clr4Runtime
100-
{
101-
get { return isClr4; }
102-
}
103-
10494
/// <summary>
10595
/// Gets the thread id for the current thread. Use thread name is available,
10696
/// otherwise use CurrentThread.GetHashCode() for .NET 1.0/1.1 and

0 commit comments

Comments
 (0)