Need help fixing yet another BeginEdit()/CopyState issue

Need help fixing yet another BeginEdit()/CopyState issue

Old forum URL: forums.lhotka.net/forums/t/6360.aspx


Jack posted on Friday, February 06, 2009

I've managed to identify my BeginEdit()/CopyState bug but I do not know how to fix it without changing some design.  Now maybe a design change is what will be needed but I thought I could at least get around the problem with the use of [NotUndoable].

My error is happening in the FieldDataManager at the
void Core.IUndoableObject.CopyState(int parentEditLevel, bool parentBindingEdit) function.

It is essentially a circular reference but I can't seem to short circuit it.

I have the following:

RootBO
    DataFieldListBO
         DataFieldBO
              MissingDataBO
    MissingDataFieldListBO
        MissingDataBO

The two lists are populated directly from the database and then I make a loop to link the dataFieldBOs to a related MissingDataFieldBO (although it may not have a record).

I chose this approach for a number of reasons including how the user works on the missingData (in batch or individually) and how the data is stored.

Anyhow - I thought that I could use the [NotUndoable] attribute to solve my issues.  My first thought was I could put it on the DataField.MissingData but that didn't work.  So I tried it on the MissingDataFieldList but that didn't work.  I even tried it on both but it still crashed.

I'm not even doing any databinding at this point.  I'm just retrieving my data and calling BeginEdit on the RootBO.

The only way to avoid the CopyState EditLevel mismatch is to remove the DataField.MissingData and then I have no issue.

It is almost as if the [NotUndoable] attribute isn't even being looked at when doing the copyState of the FieldDataManager...

Confused...

Any ideas on where to look or what I can do?

thanks

jack

ajj3085 replied on Friday, February 06, 2009

I think you need a NotSerializable attribute as well.

Jack replied on Friday, February 06, 2009

Makes no difference – I had tried that but thanks

 

 

 

From: ajj3085 [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 10:39 AM
To: jaddington@alexandergracie.com
Subject: Re: [CSLA .NET] Need help fixing yet another BeginEdit()/CopyState issue

 

I think you need a NotSerializable attribute as well.


Jack replied on Friday, February 06, 2009

The problem is within the FieldDataManager and it’s CopyState method.  If I swap the field from being a Managed backing field to a private backing field then the NotUndoable attribute works.

 

 [NotUndoable]

private MissingDataField _missingData;

//        private static PropertyInfo<MissingDataField> MissingDataProperty = RegisterProperty<MissingDataField>(typeof(DataField), new PropertyInfo<MissingDataField>("MissingData"));

 

Is this expected?  It seems to me that the FieldDataManager may not be checking if the underlying field is NotUndoable?

 

???

 

From: ajj3085 [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 10:39 AM
To: jaddington@alexandergracie.com
Subject: Re: [CSLA .NET] Need help fixing yet another BeginEdit()/CopyState issue

 

I think you need a NotSerializable attribute as well.


ajj3085 replied on Friday, February 06, 2009

Oh, well that changes things.

Yes, you need to use unmanaged fields to mark them as NotUndoable.  You can still do the managed property though.  Your property setters / getters change sliglhty though.

get { return GetProperty( MissingDataProperty, _missingData ); }
se { SetProperty( MissingDataProperty, value, ref _missingData ); }

rsbaker0 replied on Friday, February 06, 2009

Jack:

The problem is within the FieldDataManager and it’s CopyState method.  If I swap the field from being a Managed backing field to a private backing field then the NotUndoable attribute works.

Yes, I've found that managed fields (without backing fields) are generally always serialized and pushed/popped from the state stack in Undo.

I posted a request to have some way to tag such fields (e.g. properties in IPropertyInfo) so they could be not undoable or nonserialized, but I don't think it attracted much interest.

 

 

 

Jack replied on Friday, February 06, 2009

Well I’m on board J.  It seems there is one gotcha after another.   A slight misuse of the terminology and you waste a morning.  I’m sure I have type and read managed field, managed property, managed backed field, backed field, etc. and not really known what it means.

 

I think I’m going to suggest a Wiki or an online glossary to help make sense of all this stuff.

 

jack

 

From: rsbaker0 [mailto:cslanet@lhotka.net]
Sent: Friday, February 06, 2009 12:44 PM
To: jaddington@alexandergracie.com
Subject: Re: [CSLA .NET] RE: Need help fixing yet another BeginEdit()/CopyState issue

 

Jack:

The problem is within the FieldDataManager and it’s CopyState method.  If I swap the field from being a Managed backing field to a private backing field then the NotUndoable attribute works.

Yes, I've found that managed fields (without backing fields) are generally always serialized and pushed/popped from the state stack in Undo.

I posted a request to have some way to tag such fields (e.g. properties in IPropertyInfo) so they could be not undoable or nonserialized, but I don't think it attracted much interest.

 

 

 



Copyright (c) Marimer LLC