fixed SPRNET-957
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2005 the original author or authors.
|
||||
* Copyright <20> 2002-2008 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.
|
||||
@@ -97,8 +97,12 @@ namespace Spring.Core.TypeResolution
|
||||
|
||||
private void SplitTypeAndAssemblyNames(string originalTypeName)
|
||||
{
|
||||
int typeAssemblyIndex
|
||||
= originalTypeName.IndexOf(TypeAssemblySeparator);
|
||||
// generic types may look like:
|
||||
// Spring.Objects.TestGenericObject`2[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][] , Spring.Core.Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
//
|
||||
// start searching for assembly separator after the last bracket if any
|
||||
int typeAssemblyIndex = originalTypeName.LastIndexOf(']');
|
||||
typeAssemblyIndex = originalTypeName.IndexOf(TypeAssemblySeparator, typeAssemblyIndex+1);
|
||||
if (typeAssemblyIndex < 0)
|
||||
{
|
||||
unresolvedTypeName = originalTypeName;
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2008 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 System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Spring.Objects;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Core.TypeResolution
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[TestFixture]
|
||||
public class TypeAssemblyHolderTests
|
||||
{
|
||||
[Test]
|
||||
public void CanTakeQualifiedType()
|
||||
{
|
||||
string tn = typeof(int[]).AssemblyQualifiedName;
|
||||
tn = typeof(TestGenericObject<int,string>[]).AssemblyQualifiedName;
|
||||
tn = typeof(List<int>).AssemblyQualifiedName;
|
||||
|
||||
Type testType = typeof(TestObject);
|
||||
TypeAssemblyHolder tah = new TypeAssemblyHolder(testType.AssemblyQualifiedName);
|
||||
Assert.IsTrue(tah.IsAssemblyQualified);
|
||||
Assert.AreEqual(testType.FullName, tah.TypeName);
|
||||
Assert.AreEqual(testType.Assembly.FullName, tah.AssemblyName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanTakeUnqualifiedType()
|
||||
{
|
||||
Type testType = typeof(TestObject);
|
||||
TypeAssemblyHolder tah = new TypeAssemblyHolder(testType.FullName);
|
||||
Assert.IsFalse(tah.IsAssemblyQualified);
|
||||
Assert.AreEqual(testType.FullName, tah.TypeName);
|
||||
Assert.AreEqual(null, tah.AssemblyName);
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
[Test]
|
||||
public void CanTakeUnqualifiedGenericType()
|
||||
{
|
||||
Type testType = typeof(TestGenericObject<int, string>);
|
||||
TypeAssemblyHolder tah = new TypeAssemblyHolder(testType.FullName);
|
||||
Assert.IsFalse(tah.IsAssemblyQualified);
|
||||
Assert.AreEqual(testType.FullName, tah.TypeName);
|
||||
Assert.AreEqual(null, tah.AssemblyName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanTakeQualifiedGenericType()
|
||||
{
|
||||
Type testType = typeof(TestGenericObject<int, string>);
|
||||
TypeAssemblyHolder tah = new TypeAssemblyHolder(testType.AssemblyQualifiedName);
|
||||
Assert.IsTrue(tah.IsAssemblyQualified);
|
||||
Assert.AreEqual(testType.FullName, tah.TypeName);
|
||||
Assert.AreEqual(testType.Assembly.FullName, tah.AssemblyName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -265,6 +265,7 @@
|
||||
<Compile Include="Core\TypeConversion\UriConverterTests.cs" />
|
||||
<Compile Include="Core\TypeResolution\CachedTypeResolverTests.cs" />
|
||||
<Compile Include="Core\TypeResolution\GenericTypeResolverTests.cs" />
|
||||
<Compile Include="Core\TypeResolution\TypeAssemblyHolderTests.cs" />
|
||||
<Compile Include="Core\TypeResolution\TypeRegistryTests.cs" />
|
||||
<Compile Include="Core\TypeResolution\TypeResolutionUtilsTests.cs" />
|
||||
<Compile Include="Core\TypeResolution\TypeResolverTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user