Hi,
Sorry if this comes as a duplicate post. I think google might have
eaten my first so here it is again.
First off, mad props to all of you involved in the FNH - it rocks!
That said, I've come across what seems to be a bug in the method
FindMapping<T> of the AutoPersistenceModel class. Here's a sample
stack trace:

TestCase 'Can_Write_XML_Mapping_Metadata_To_Folder'
failed: System.Reflection.TargetInvocationException : Exception has
been thrown by the target of an invocation.
  ----> System.IndexOutOfRangeException : Index was outside the bounds
of the array.
        at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object
[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
        at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object
[] arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
        at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean skipVisibilityChecks)
        at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture)
        at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters)
        at
FluentNHibernate.InvocationHelper.InvokeGenericMethodWithDynamicTypeArguments
[T](T target, Expression`1 expression, Object[] methodArguments, Type
[] typeArguments)
        at FluentNHibernate.AutoMap.AutoPersistenceModel.FindMapping(Type
type)
        at FluentNHibernate.AutoMap.AutoPersistenceModel.CompileMappings()
        C:\Projects\Dev\Source\Core\Tests\Unit Tests
\Core.Infrastructure.Data.NHibernate.Tests\MappingTests.cs(47,0): at
Core.Infrastructure.Data.NHibernate.Tests.MappingTests.Can_Write_XML_Mapping_Metadata_To_Folder
()
        --IndexOutOfRangeException
        at FluentNHibernate.AutoMap.AutoPersistenceModel.<FindMapping>b__7[T]
(IMapping t)
        at System.Collections.Generic.List`1.Find(Predicate`1 match)
        at FluentNHibernate.AutoMap.AutoPersistenceModel.FindMapping[T]()

The test above simply instantiates a new AutoPersistenceModel, calls
MergeWithMappingsFromAssembly<T>() to add some custom mappings
(classes inheriting from Automap<T>), calls CompileMappings() and
attempts to write them to a folder using WriteMappingsTo().

I believe the culprit is this line in FindMapping<T>:

            // standard AutoMap<T> not found for the type, so looking
for one for it's base type.
            return (IClassMap)_mappings.Find(t => t.GetType
().GetGenericArguments()[0] == typeof(T).BaseType);
Because _mappings contains instances of classes that are derivatives
of AutoMap<T> and aren't actually generic types, the array returned
from Type.GetGenericArguments() contains no elements and thus you get
the IndexOutOfRangeException.

I think the solution is to modify the predicate to allow for none
generic types by casting to Automap<T> first.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to