-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Null Object Reference - DeepClone #209
Comments
Oh, and I'm calling the clone simply with: private readonly ViewDataGridPreferencesDto _viewData; // set in constructor
private ViewDataGridPreferencesDto _originalViewData;
protected some method
{
_originalViewData = Mapper.DeepClone(_viewData);
} |
Hello! Thanks for letting me know about this - could I have the source for Cheers, Steve |
I replied to the email and attached the files. Do they get to you that way? If I have to put them here I can do that. |
Unfortunately not! You could attach them here or make a Git repo with them in? |
Files attached! |
Thanks very much - I'll check this out as soon as I can 👍🏻 |
I'm not sure if it's related, but we are seeing null ref's internally occurring in EDIT: some context in my case
|
my comment above was moved to it's own issue as it's different: #212 |
Hi @vsederburg, Just looking at this now - could you let me know where the Also - and this isn't the cause of this issue and you may have already found it, but just in case - to deep-clone a _originalViewData = Mapper.DeepClone(_viewData, cfg => cfg
.Map((svd, tvd) => svd.Source)
.ToCtor<GridPreferenceCallerSource>()); Cheers, Steve |
I've attached the ObservableObject class. Sorry I missed that one. For the ViewDataGridPreferencesDto you mentioned... would it fix that if I just changed the corresponding property name to CallerSource, or make them match one way or the other? |
Hi, Thanks for If Thanks again for reporting the issue! All the best, Steve |
That's weird, that has been the base class forever and it's never complained before. Oh well, looking forward to the update. This mapper is super useful. :-) |
Hi, I've now uploaded a preview v1.8 release to NuGet with this issue fixed - please could you try it out and let me know how you get on? Thanks, Steve |
YES! All seems to be working again. Thanks so much! |
Excellent! You're welcome, thanks for checking :) |
* Updating AO packages * Adding .NET Standard 2.0 target / Rationalising compiler directives / Removing non-latest-major-version .NET Core test projects * Fixing caching thread safety issue / Handling null keys in default key comparer, re: #212 * Throwing ObjectDisposedException on attempt to use a disposed mapper * Simplifying numeric constants setup, re: #213 * Tidying * Improving target member selection, re: #209 * Adding v1.8 preview NuGet package * Tidying documentation * Organising classes * Features/target member matcher data sources (#214) * Adding data source -> target member matcher selection * Member matcher data sources / Conflict testing / Documentation improvements * Fixing query projection * All fixed * Adding documentation * Updating release notes / Updating to v1.8 * Extra test coverage * Adding v1.8 NuGet package
This fix is in the full v1.8 release, which is now available on NuGet. Thanks! |
I'm getting an error using Mapper.DeepClone to clone a class. This was working sometime in the past few weeks, so I'm not sure what has changed. I'm using the current Mapper version 1.7.2 via nuGet.
I seem to remember at one point there was a problem cloning an object that included a dictionary, but I think that was fixed.
I've attached the class and base class that I'm trying to clone. Let me know if I can provide any other information.
Thank you!
This is the error:
System.NullReferenceException: Object reference not set to an instance of an object.
at AgileObjects.AgileMapper.Members.QualifiedMember.Append(Member childMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.GetNonEnumerableChildMember(QualifiedMember parentMember, Member childMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.TargetMemberEverRepeatsWithin(QualifiedMember parentMember, IQualifiedMember subjectMember)
at AgileObjects.AgileMapper.Members.MemberMapperDataExtensions.IsRepeatMapping(IQualifiedMemberContext context)
at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperData.get_IsRepeatMapping()
at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperData.IsNotTargetTypeFirstMapping(ObjectMapperData parent)
at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperData..ctor(IMappingContext mappingContext, IQualifiedMember sourceMember, QualifiedMember targetMember, Nullable
1 dataSourceIndex, ObjectMapperData declaredTypeMapperData, ObjectMapperData parent, Boolean isForStandaloneMapping) at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperData.For[TSource,TTarget](ObjectMappingData
2 mappingData)at AgileObjects.AgileMapper.ObjectPopulation.ObjectMappingData
2.get_MapperData() at AgileObjects.AgileMapper.ObjectPopulation.MappingFactory.GetChildMapping(IObjectMappingData childMappingData, MappingValues mappingValues, ObjectMapperData declaredTypeMapperData) at AgileObjects.AgileMapper.ObjectPopulation.MappingFactory.GetChildMapping(IQualifiedMember sourceMember, Expression sourceMemberAccess, Int32 dataSourceIndex, IChildMemberMappingData childMappingData) at AgileObjects.AgileMapper.DataSources.EnumerableDataSource.GetMapping(IDataSource sourceEnumerableDataSource, Int32 dataSourceIndex, IChildMemberMappingData enumerableMappingData) at AgileObjects.AgileMapper.DataSources.Factories.DataSourceFindContext.GetFinalDataSource(IDataSource foundDataSource, IChildMemberMappingData mappingData) at AgileObjects.AgileMapper.DataSources.Factories.DataSourceFindContext.GetSourceMemberDataSource() at AgileObjects.AgileMapper.DataSources.Factories.DataSourceFindContext.get_MatchingSourceMemberDataSource() at AgileObjects.AgileMapper.DataSources.Factories.DataSourceFindContext.UseSourceMemberDataSource() at AgileObjects.AgileMapper.DataSources.Factories.SourceMemberDataSourcesFactory.<Create>d__0.MoveNext() at AgileObjects.AgileMapper.DataSources.Factories.MemberDataSourceSetFactory.<EnumerateDataSources>d__2.MoveNext() at System.Linq.Buffer
1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source)at AgileObjects.AgileMapper.DataSources.Factories.MemberDataSourceSetFactory.CreateFor(DataSourceFindContext findContext)
at AgileObjects.AgileMapper.Members.Population.MemberPopulatorFactory.Create(MemberPopulationContext context)
at AgileObjects.AgileMapper.Members.Population.MemberPopulatorFactory.<>c.b__3_0(MemberPopulationContext ctx, QualifiedMember tm)
at AgileObjects.AgileMapper.Extensions.PublicEnumerableExtensions.d__1
3.MoveNext() at AgileObjects.AgileMapper.Extensions.PublicEnumerableExtensions.<Filter>d__4
2.MoveNext()at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.PopulationExpressionFactoryBase.d__3.MoveNext()
at System.Collections.Generic.List
1..ctor(IEnumerable
1 collection)at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.PopulationExpressionFactoryBase.AddPopulation(MappingCreationContext context) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeMappingExpressionFactory.AddObjectPopulation(MappingCreationContext context) at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.<AddPopulationsAndCallbacks>b__11_0(MappingExpressionFactoryBase factory, MappingCreationContext ctx) at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.AddPopulationsAndCallbacks[TArg](TArg argument, MappingCreationContext context, Action
2 mappingBodyPopulator)at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.AddPopulationsAndCallbacks(MappingCreationContext context)
at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.Create(IObjectMappingData mappingData)
at AgileObjects.AgileMapper.DataSources.ComplexTypeDataSource.Create(IObjectMappingData mappingData)
at AgileObjects.AgileMapper.DataSources.Factories.Mapping.ComplexTypeMappingDataSourceFactory.CreateFor(IObjectMappingData mappingData)
at AgileObjects.AgileMapper.DataSources.Factories.Mapping.MappingDataSourceSetFactory.CreateFor(IObjectMappingData mappingData)
at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperFactory.Create[TSource,TTarget](ObjectMappingData
2 mappingData) at AgileObjects.AgileMapper.ObjectPopulation.ObjectMappingData
2.GetOrCreateMapper()at AgileObjects.AgileMapper.ObjectPopulation.MappingFactory.GetInlineMappingBlock(IObjectMappingData mappingData, MappingValues mappingValues, CreateMappingDataCallFactory createMappingDataCallFactory)
at AgileObjects.AgileMapper.ObjectPopulation.MappingFactory.GetElementMapping(IObjectMappingData elementMappingData, Expression sourceElementValue, Expression targetElementValue)
at AgileObjects.AgileMapper.ObjectPopulation.MappingFactory.GetElementMapping(Expression sourceElementValue, Expression targetElementValue, IObjectMappingData mappingData)
at AgileObjects.AgileMapper.ObjectPopulation.Enumerables.EnumerablePopulationBuilder.GetElementConversion(Expression sourceElement, IObjectMappingData enumerableMappingData)
at AgileObjects.AgileMapper.ObjectPopulation.Enumerables.Looping.IndexedSourcePopulationLoopData.GetElementMapping(IObjectMappingData enumerableMappingData)
at AgileObjects.AgileMapper.ObjectPopulation.Enumerables.EnumerablePopulationBuilder.GetElementPopulation(IPopulationLoopData loopData, IObjectMappingData enumerableMappingData)
at AgileObjects.AgileMapper.ObjectPopulation.Enumerables.Looping.PopulationLoopDataExtensions.BuildPopulationLoop[TLoopData](TLoopData loopData, EnumerablePopulationBuilder builder, IObjectMappingData mappingData, Func
3 elementPopulationFactory) at AgileObjects.AgileMapper.ObjectPopulation.Enumerables.EnumerablePopulationBuilder.BuildPopulationLoop(Func
3 elementPopulationFactory, IObjectMappingData mappingData)at AgileObjects.AgileMapper.ObjectPopulation.Enumerables.EnumerablePopulationBuilder.AddNewItemsToTargetVariable(IObjectMappingData enumerableMappingData)
at AgileObjects.AgileMapper.ObjectPopulation.Enumerables.CopySourceEnumerablePopulationStrategy.Create(EnumerablePopulationBuilder builder, IObjectMappingData enumerableMappingData)
at AgileObjects.AgileMapper.ObjectPopulation.Enumerables.EnumerableMappingExpressionFactory.AddObjectPopulation(MappingCreationContext context)
at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.b__11_0(MappingExpressionFactoryBase factory, MappingCreationContext ctx)
at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.AddPopulationsAndCallbacks[TArg](TArg argument, MappingCreationContext context, Action
2 mappingBodyPopulator) at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.AddPopulationsAndCallbacks(MappingCreationContext context) at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.Create(IObjectMappingData mappingData) at AgileObjects.AgileMapper.DataSources.Factories.Mapping.MappingDataSourceFactoryBase.CreateFor(IObjectMappingData mappingData) at AgileObjects.AgileMapper.DataSources.Factories.Mapping.MappingDataSourceSetFactory.CreateFor(IObjectMappingData mappingData) at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperFactory.Create[TSource,TTarget](ObjectMappingData
2 mappingData)at AgileObjects.AgileMapper.ObjectPopulation.ObjectMappingData
2.GetOrCreateMapper() at AgileObjects.AgileMapper.ObjectPopulation.MappingFactory.GetInlineMappingBlock(IObjectMappingData mappingData, MappingValues mappingValues, CreateMappingDataCallFactory createMappingDataCallFactory) at AgileObjects.AgileMapper.ObjectPopulation.MappingFactory.GetChildMapping(IObjectMappingData childMappingData, MappingValues mappingValues, ObjectMapperData declaredTypeMapperData) at AgileObjects.AgileMapper.ObjectPopulation.MappingFactory.GetChildMapping(IQualifiedMember sourceMember, Expression sourceMemberAccess, Int32 dataSourceIndex, IChildMemberMappingData childMappingData) at AgileObjects.AgileMapper.DataSources.EnumerableDataSource.GetMapping(IDataSource sourceEnumerableDataSource, Int32 dataSourceIndex, IChildMemberMappingData enumerableMappingData) at AgileObjects.AgileMapper.DataSources.Factories.DataSourceFindContext.GetFinalDataSource(IDataSource foundDataSource, IChildMemberMappingData mappingData) at AgileObjects.AgileMapper.DataSources.Factories.DataSourceFindContext.GetSourceMemberDataSource() at AgileObjects.AgileMapper.DataSources.Factories.DataSourceFindContext.get_MatchingSourceMemberDataSource() at AgileObjects.AgileMapper.DataSources.Factories.DataSourceFindContext.UseSourceMemberDataSource() at AgileObjects.AgileMapper.DataSources.Factories.SourceMemberDataSourcesFactory.<Create>d__0.MoveNext() at AgileObjects.AgileMapper.DataSources.Factories.MemberDataSourceSetFactory.<EnumerateDataSources>d__2.MoveNext() at System.Linq.Buffer
1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source)at AgileObjects.AgileMapper.DataSources.Factories.MemberDataSourceSetFactory.CreateFor(DataSourceFindContext findContext)
at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.ConstructionDataInfo
1..ctor(TInvokable invokable, ConstructionKey key, Int32 priority) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.ObjectNewingInfo..ctor(ConstructorInfo ctor, ConstructionKey key) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.<>c__DisplayClass9_0.<GetGreediestAvailableNewingInfos>b__0(ConstructorInfo ctor) at AgileObjects.AgileMapper.Extensions.PublicEnumerableExtensions.<>c__0
2.b__0_0(Func2 p, TItem item) at AgileObjects.AgileMapper.Extensions.PublicEnumerableExtensions.<Project>d__1
3.MoveNext()at AgileObjects.AgileMapper.Extensions.PublicEnumerableExtensions.d__4
2.MoveNext() at AgileObjects.AgileMapper.Extensions.Internal.EnumerableExtensions.<TakeUntil>d__6
1.MoveNext()at System.Linq.Buffer
1..ctor(IEnumerable
1 source)at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.CreateConstructionInfo[T](IEnumerable
1 invokables, Func2 dataFactory) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.GetGreediestAvailableNewingInfos(IEnumerable
1 constructors, ConstructionKey key, IBasicConstructionInfo greediestUnconditionalFactoryInfo)at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.AddAutoConstructionInfos(IList
1 constructionInfos, ConstructionKey key) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.<>c.<GetTargetObjectCreationInfos>b__4_0(ConstructionKey key) at AgileObjects.AgileMapper.Caching.ArrayCache
2.GetOrAdd(TKey key, Func2 valueFactory) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.GetTargetObjectCreationInfos(IObjectMappingData mappingData, ConstructionKey& constructionKey) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeConstructionFactory.GetTargetObjectCreationInfos(IObjectMappingData mappingData) at AgileObjects.AgileMapper.MappingDataExtensions.GetTargetObjectCreationInfos(IObjectMappingData mappingData) at AgileObjects.AgileMapper.ObjectPopulation.ComplexTypes.ComplexTypeMappingExpressionFactory.TargetCannotBeMapped(IObjectMappingData mappingData, String& reason) at AgileObjects.AgileMapper.ObjectPopulation.MappingExpressionFactoryBase.Create(IObjectMappingData mappingData) at AgileObjects.AgileMapper.DataSources.ComplexTypeDataSource.Create(IObjectMappingData mappingData) at AgileObjects.AgileMapper.DataSources.Factories.Mapping.ComplexTypeMappingDataSourceFactory.CreateFor(IObjectMappingData mappingData) at AgileObjects.AgileMapper.DataSources.Factories.Mapping.MappingDataSourceSetFactory.CreateFor(IObjectMappingData mappingData) at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperFactory.Create[TSource,TTarget](ObjectMappingData
2 mappingData)at AgileObjects.AgileMapper.ObjectPopulation.ObjectMappingData
2.GetOrCreateMapper() at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperFactory.<>c__6
2.b__6_0(IRootMapperKey key)at AgileObjects.AgileMapper.Caching.ArrayCache
2.GetOrAdd(TKey key, Func
2 valueFactory)at AgileObjects.AgileMapper.ObjectPopulation.ObjectMapperFactory.GetOrCreateRoot[TSource,TTarget](ObjectMappingData
2 mappingData) at AgileObjects.AgileMapper.ObjectPopulation.ObjectMappingData
2..ctor(TSource source, TTarget target, Nullable1 elementIndex, Object elementKey, MappingTypes mappingTypes, IMappingContext mappingContext, IObjectMappingData declaredTypeMappingData, IObjectMappingData parent, Boolean createMapper) at AgileObjects.AgileMapper.ObjectPopulation.ObjectMappingDataFactory.ForRootFixedTypes[TSource,TTarget](TSource source, TTarget target, MappingTypes mappingTypes, IMappingContext mappingContext, Boolean createMapper) at AgileObjects.AgileMapper.ObjectPopulation.ObjectMappingDataFactory.ForRootFixedTypes[TSource,TTarget](TSource source, TTarget target, IMappingContext mappingContext, Boolean createMapper) at AgileObjects.AgileMapper.MappingExecutor
1.PerformMapping[TTarget](TTarget target)at AgileObjects.AgileMapper.MappingExecutor
1.PerformMapping[TTarget](MappingRuleSet ruleSet, TTarget target) at AgileObjects.AgileMapper.MappingExecutor
1.ToANewTResultat AgileObjects.AgileMapper.Mapper.AgileObjects.AgileMapper.IMapper.DeepClone[TSource](TSource source)
at AgileObjects.AgileMapper.Mapper.DeepClone[TSource](TSource source)
at mt.Client.Common.ViewModels.Activity.AttendanceGridSettingsViewModel.OnInitialize(Object[] args) in C:\Data\mt_src\csharp\mt\mt.Client.Common\ViewModels\Activity\AttendanceGridSettingsViewModel.cs:line 98
at mt.Shared.Base.MtViewModelBase.Initialize(IMtViewModelParent parent, Object[] args) in C:\Data\mt_src\csharp\mt\mt.Shared\Base\MtViewModelBase.cs:line 93
at mt.Shared.Base.MtViewModelBase.Initialize(IMtViewModelParent parent) in C:\Data\mt_src\csharp\mt\mt.Shared\Base\MtViewModelBase.cs:line 76
at mt.Client.Common.UserControls.Activity.AttendanceGridSettingsUserControl.InitializeStart(Object[] args) in C:\Data\mt_src\csharp\mt\mt.Client.Common\UserControls\Activity\AttendanceGridSettingsUserControl.cs:line 49
at mt.Shared.Base.MtUserControlBase.Initialize(Object[] args) in C:\Data\mt_src\csharp\mt\mt.Shared\Base\MtUserControlBase.cs:line 148
2021-03-09 08:02:36,278 [1] INFO - Notification: Object reference not set to an instance of an object.
ViewDataDto.cs.txt
ViewDataGridPreferencesDto.cs.txt
The text was updated successfully, but these errors were encountered: