I can't see a warning in the log.

It verifies that every (non-private) member is at least "virtual
protected". "internal protected" is accepted by the session factory,
but doesn't seem to work.

On 22 Mrz., 17:12, Fabio Maulo <[email protected]> wrote:
> I think you should have a WARNING in the log.
>
> 2010/3/22 Stefan Steinegger <[email protected]>
>
>
>
> > Just found this very confusing situation. I have a private setter and
> > an internal method which modifies it. The proxy cannot interfere,
> > that's logical. But there is no error message, like when virtual is
> > missing. The effect is that at runtime, the modification on the
> > property is just lost.
>
> >        public class LazyLoadingTest
> >        {
> >                // ids and stuff
> >                // ...
>
> >                private string privateSetter;
> >                public virtual string PrivateSetter
> >                {
> >                        get { return privateSetter; }
> >                        private set { privateSetter = value; }
> >                }
> >                internal protected virtual void
> > InternallySetPrivateSetter(string
> > value)
> >                {
> >                        PrivateSetter = value;
> >                }
>
> >        }
>
> >        [TestMethod]
> >        public void Test()
> >        {
> >                // the object has been stored in TestInitialize
>
> >                var obj = session.Load<LazyLoadingTest>(id);
>
> >                Assert.AreEqual("A", obj.PrivateSetter);
>
> >                obj.InternallySetPrivateSetter("B");
> >                Assert.AreEqual("B", obj.PrivateSetter, "Changing the
> > property value
> > fails");
> >        }
>
> > The last line of the test fails. This applies not only to private
> > setters, also to internal and protected. Interestingly, the field
> > behind the property holds the new value "B" after it is set. Then it
> > is reverted to "A" when PrivateSetter is called the second time
> > without passing the private setter.
>
> > I understand that this can't work (except of the protected setter,
> > which actually should). But it produces very subtle problems which are
> > hard to find. Should internal methods be prohibited when loading the
> > session factory?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> Fabio Maulo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to