NHibernate.Util.TypeNameParser doesn't parse correctly generic types

Description

Hello,
I'm using the collection-type attribute to customize the collection class. The collection is implemented as a generic type with two type paramaters and the second type parameter is also a generic type. The full qualified name of the collection class is like this:

Test.NHMapping.CustomCollection`2[[Test.Common.InvoiceDetail, Test.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a873a127e0d1872],[Test.ReadOnlyBusinessObjectList`1[[Test.Common.InvoiceDetail, Test.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a873a127e0d1872]],Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a873a127e0d1872]], Test.NHMapping, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a873a127e0d1872

The class NHibernate.Util.TypeNameParser.Parse mehod fails to parse the class name correctly, generating an invalid AssemblyQualifiedTypeName object.
The string the parser generates is:

Test.NHMapping.CustomCollection`2[[Test.Common.InvoiceDetail, Test.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a873a127e0d1872],[[[Test.ReadOnlyBusinessObjectList`1Test.Common.InvoiceDetail, Test.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a873a127e0d1872]], Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a873a127e0d1872]], Test.NHMapping, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a873a127e0d1872

So NHibernate will then fail to create the type.

I've solved the problem modifying the NHibernate.Util.TypeNameParser, but I don't like the solution.
I think is needed a real parser to do this kind of operation.
The Backus-Naur Form Grammar is available at http://msdn.microsoft.com/en-us/library/yfsftwz6(VS.80).aspx .

Thanks,
Andrei

Environment

None

Activity

Show:

Dawid Mostert May 18, 2009 at 8:33 AM

After this fix, the following parses incorrectly:

"
<property name="Channel" type="OldMutual.SalesGear.Data.ReferenceType`2[
[OldMutual.SalesGear.Reference.Core.Channel, OldMutual.SalesGear.Reference.Core],
[OldMutual.SalesGear.Reference.Core.Channels, OldMutual.SalesGear.Reference.Core]
], OldMutual.SalesGear.Data"/>
"

The second generic type parameter, is parsed with a starting '['.

Thanks,
Dawid

Fabio Maulo April 14, 2009 at 9:46 PM

which is the mapping ?

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created April 8, 2009 at 6:30 AM
Updated July 22, 2009 at 7:21 AM
Resolved April 17, 2009 at 7:23 AM
Who's Looking?