IndexOutOfRangeException in Child property

michael.proepster's Avatar

michael.proepster

20 Sep, 2017 12:32 PM

using 5.0.32, VS 2015:

at PostSharp.Patterns.Threading.ThreadAwareAttribute.IsEligibleChild(Object child, ChildInfo childInfo) at PostSharp.Patterns.Model.AggregatableClientAttribute.AdviseRecursive(Object child, ChildInfo childInfo, Object state) at PostSharp.Patterns.Model.AggregatableClientAttribute.OnChildAttached(Object child, ChildInfo childInfo) at PostSharpDemo.MainModel.OnChildAttached(Object child, ChildInfo childInfo) in :line 16707565 at PostSharp.Patterns.Model.AggregatableAttribute.InvokeOnChildAttached(Object child, ChildInfo childInfo, Object state) at PostSharp.Patterns.Model.AggregatableAttribute.VisitChildrenCore(ChildVisitor visitor, ChildVisitorOptions options, Object state) at PostSharp.Patterns.Model.AggregatableAttribute.VisitChildren(ChildVisitor visitor, ChildVisitorOptions options, Object state) at PostSharpDemo.MainModel.VisitChildren(ChildVisitor visitor, ChildVisitorOptions options, Object state) in :line 16707565 at PostSharp.Patterns.Model.AggregatableAttribute.OnInstanceConstructed() at PostSharpDemo.MainModel.OnInstanceConstructed() in :line 0 at PostSharpDemo.MainModel..ctor(ConstructorDepth __depth) in C:\dev\T1gui_PostSharpEval\50_src\PostSharpDemo\MainModel.cs:line 22 at PostSharpDemo.MainModel..ctor() in :line 16707565 at PostSharpDemo.Form1..ctor() in C:\dev\T1gui_PostSharpEval\50_src\PostSharpDemo\Form1.cs:line 11 at PostSharpDemo.Program.Main() in C:\dev\T1gui_PostSharpEval\50_src\PostSharpDemo\Program.cs:line 19 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

with this code:

[ReaderWriterSynchronized]
internal class MainModel
{

    [ExplicitlySynchronized]
    [Child]
    public ImmutableType ImmutableChild { get; }

    public MainModel()
    {
        ImmutableChild = new ImmutableType();
    }


}

[Immutable]
internal class ImmutableType
{
    public string SomeProperty { get; set; }
}
  1. 1 Posted by michael.proepst... on 20 Sep, 2017 12:37 PM

    michael.proepster's Avatar

    When I add another property, I now get a NullReferenceException:

    [ReaderWriterSynchronized]
    internal class MainModel
    {
    
        [Child]
        public SubModel SubModel { get; }
    
        [ExplicitlySynchronized]
        [Child]
        public ImmutableChild ImmutableChild { get; }
    
        public MainModel()
        {
            SubModel = new SubModel();
            ImmutableChild = new ImmutableChild();
        }
    
  2. Support Staff 2 Posted by PostSharp Techn... on 21 Sep, 2017 02:41 PM

    PostSharp Technologies's Avatar

    Hello,

    this is a bug caused by [ExplicitlySynchronized] being present on a [Child] field (marking the property with it causes it to multicast to field and accessors). A workaround is to apply [ExplicitlySynchronized ] only to the property getter and/or setter.

    (bug #15521)

    Best,
    Daniel

  3. Support Staff 3 Posted by PostSharp Techn... on 09 Oct, 2017 12:07 PM

    PostSharp Technologies's Avatar

    Hello,

    We're closing the ticket for now as the bug has been internally filed as issue #15521. We will contact you as soon as the bug fix has been released.

    For more details on our support policies and prioritization of bug fixes, please visit https://www.postsharp.net/support/policies

    PostSharp Team

  4. PostSharp Technologies closed this discussion on 09 Oct, 2017 12:07 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac