cwensley / Portable.Xaml

Portable .NET library for reading/writing xaml files.
Other
157 stars 39 forks source link

Exception thrown: 'Portable.Xaml.XamlObjectWriterException' in Portable.Xaml.dll #20

Closed wieslawsoltes closed 7 years ago

wieslawsoltes commented 8 years ago

This exception is thrown when trying to load Xaml that was written automatically by Portable.Xaml from the object graph.

Exception thrown: 'Portable.Xaml.XamlObjectWriterException' in Portable.Xaml.dll
Core2D.Perspex.vshost.exe Error: 0 : Unresolved object reference 'AND' was found
   w Portable.Xaml.XamlObjectWriterInternal.ResolvePendingReferences()
   w Portable.Xaml.XamlObjectWriterInternal.OnWriteEndObject()
   w Portable.Xaml.XamlWriterInternalBase.WriteEndObject()
   w Portable.Xaml.XamlWriterInternalBase.CloseAll()
   w Portable.Xaml.XamlObjectWriter.Dispose(Boolean disposing)
   w Portable.Xaml.XamlWriter.System.IDisposable.Dispose()
   w Core2D.Xaml.Serializer.CoreXamlReader.Load(XamlXmlReader reader) w C:\DOWNLOADS\GitHub-Core2D\Core2D\src\Core2D\Xaml\Serializer\CoreXamlReader.cs:wiersz 19
   w Core2D.Xaml.Serializer.CoreXamlReader.Load(TextReader textReader) w C:\DOWNLOADS\GitHub-Core2D\Core2D\src\Core2D\Xaml\Serializer\CoreXamlReader.cs:wiersz 43
   w Core2D.Xaml.Serializer.CoreXamlSerializer.Deserialize[T](String xaml) w C:\DOWNLOADS\GitHub-Core2D\Core2D\src\Core2D\Xaml\Serializer\CoreXamlSerializer.cs:wiersz 55
   w Serializer.Xaml.PortableXamlSerializer.Deserialize[T](String text) w C:\DOWNLOADS\GitHub-Core2D\Core2D\src\Dependencies\Serializer.Xaml\PortableXamlSerializer.cs:wiersz 22
   w Core2D.Editor.ProjectEditor.OnImportXamlString(String xaml) w C:\DOWNLOADS\GitHub-Core2D\Core2D\src\Core2D\Editor\ProjectEditor.cs:wiersz 579
   w Core2D.Editor.ProjectEditor.OnImportXaml(String path) w C:\DOWNLOADS\GitHub-Core2D\Core2D\src\Core2D\Editor\ProjectEditor.cs:wiersz 548

Xaml to reproduce:

<XGroup xmlns="https://github.com/Core2D" xmlns:sci="clr-namespace:System.Collections.Immutable;assembly=System.Collections.Immutable" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <XGroup.Connectors>
        <sci:ImmutableArray x:TypeArguments="XPoint">
            <XPoint>
                <XPoint.Data>
                    <XContext Record="{x:Null}">
                        <sci:ImmutableArray x:TypeArguments="XProperty" />
                    </XContext>
                </XPoint.Data>
                <XPoint.IsFilled>False</XPoint.IsFilled>
                <XPoint.IsStroked>False</XPoint.IsStroked>
                <XPoint.Name>""</XPoint.Name>
                <XPoint.Owner>
                    <x:Reference>AND</x:Reference>
                </XPoint.Owner>
                <XPoint.Resources>
                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                </XPoint.Resources>
                <XPoint.Shape>
                    <XRectangle>
                        <XRectangle.BottomRight>
                            <XPoint>
                                <XPoint.Data>
                                    <XContext Record="{x:Null}">
                                        <sci:ImmutableArray x:TypeArguments="XProperty" />
                                    </XContext>
                                </XPoint.Data>
                                <XPoint.IsFilled>False</XPoint.IsFilled>
                                <XPoint.IsStroked>False</XPoint.IsStroked>
                                <XPoint.Name>""</XPoint.Name>
                                <XPoint.Owner>
                                    <x:Null />
                                </XPoint.Owner>
                                <XPoint.Resources>
                                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                </XPoint.Resources>
                                <XPoint.Shape>
                                    <x:Null />
                                </XPoint.Shape>
                                <XPoint.State>Visible, Printable, Standalone</XPoint.State>
                                <XPoint.Style>
                                    <x:Null />
                                </XPoint.Style>
                                <XPoint.X>4</XPoint.X>
                                <XPoint.Y>4</XPoint.Y>
                            </XPoint>
                        </XRectangle.BottomRight>
                        <XRectangle.CellHeight>30</XRectangle.CellHeight>
                        <XRectangle.CellWidth>30</XRectangle.CellWidth>
                        <XRectangle.Data>
                            <XContext Record="{x:Null}">
                                <sci:ImmutableArray x:TypeArguments="XProperty" />
                            </XContext>
                        </XRectangle.Data>
                        <XRectangle.IsFilled>False</XRectangle.IsFilled>
                        <XRectangle.IsGrid>False</XRectangle.IsGrid>
                        <XRectangle.IsStroked>True</XRectangle.IsStroked>
                        <XRectangle.Name>""</XRectangle.Name>
                        <XRectangle.OffsetX>30</XRectangle.OffsetX>
                        <XRectangle.OffsetY>30</XRectangle.OffsetY>
                        <XRectangle.Owner>
                            <x:Null />
                        </XRectangle.Owner>
                        <XRectangle.Resources>
                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                        </XRectangle.Resources>
                        <XRectangle.State>Visible, Printable, Standalone</XRectangle.State>
                        <XRectangle.Style>
                            <ShapeStyle DashOffset="0" Dashes="{x:Null}">
                                <ShapeStyle.EndArrowStyle>
                                    <ArrowStyle ArrowType="None" DashOffset="0" Dashes="{x:Null}" Fill="#FF000000" IsFilled="False" IsStroked="True" LineCap="Round" Name="End" RadiusX="5" RadiusY="5">
                                        <ArrowStyle.Resources>
                                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                        </ArrowStyle.Resources>
                                        <ArrowStyle.Stroke>#FF000000</ArrowStyle.Stroke>
                                        <ArrowStyle.Thickness>1</ArrowStyle.Thickness>
                                    </ArrowStyle>
                                </ShapeStyle.EndArrowStyle>
                                <ShapeStyle.Fill>#FF000000</ShapeStyle.Fill>
                                <ShapeStyle.LineCap>Round</ShapeStyle.LineCap>
                                <ShapeStyle.LineStyle>
                                    <LineStyle>
                                        <LineStyle.FixedLength>
                                            <LineFixedLength All="False" Disabled="True" End="False" EndTrigger="Connector, Input" Horizontal="False" Length="15" Start="False" StartTrigger="Connector, Output" Vertical="False">Disabled</LineFixedLength>
                                        </LineStyle.FixedLength>
                                        <LineStyle.Name>Line</LineStyle.Name>
                                    </LineStyle>
                                </ShapeStyle.LineStyle>
                                <ShapeStyle.Name>Point</ShapeStyle.Name>
                                <ShapeStyle.Resources>
                                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                </ShapeStyle.Resources>
                                <ShapeStyle.StartArrowStyle>
                                    <ArrowStyle ArrowType="None" DashOffset="0" Dashes="{x:Null}" Fill="#FF000000" IsFilled="False" IsStroked="True" LineCap="Round" Name="Start" RadiusX="5" RadiusY="5">
                                        <ArrowStyle.Resources>
                                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                        </ArrowStyle.Resources>
                                        <ArrowStyle.Stroke>#FF000000</ArrowStyle.Stroke>
                                        <ArrowStyle.Thickness>1</ArrowStyle.Thickness>
                                    </ArrowStyle>
                                </ShapeStyle.StartArrowStyle>
                                <ShapeStyle.Stroke>#FF000000</ShapeStyle.Stroke>
                                <ShapeStyle.TextStyle>
                                    <TextStyle FontFile="C:\Windows\Fonts\calibri.ttf" FontName="Calibri" FontSize="12" FontStyle="Regular" Name="Text" TextHAlignment="Center" TextVAlignment="Center" />
                                </ShapeStyle.TextStyle>
                                <ShapeStyle.Thickness>1</ShapeStyle.Thickness>
                            </ShapeStyle>
                        </XRectangle.Style>
                        <XRectangle.Text>
                            <x:Null />
                        </XRectangle.Text>
                        <XRectangle.TopLeft>
                            <XPoint>
                                <XPoint.Data>
                                    <XContext Record="{x:Null}">
                                        <sci:ImmutableArray x:TypeArguments="XProperty" />
                                    </XContext>
                                </XPoint.Data>
                                <XPoint.IsFilled>False</XPoint.IsFilled>
                                <XPoint.IsStroked>False</XPoint.IsStroked>
                                <XPoint.Name>""</XPoint.Name>
                                <XPoint.Owner>
                                    <x:Null />
                                </XPoint.Owner>
                                <XPoint.Resources>
                                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                </XPoint.Resources>
                                <XPoint.Shape>
                                    <x:Null />
                                </XPoint.Shape>
                                <XPoint.State>Visible, Printable, Standalone</XPoint.State>
                                <XPoint.Style>
                                    <x:Null />
                                </XPoint.Style>
                                <XPoint.X>-4</XPoint.X>
                                <XPoint.Y>-4</XPoint.Y>
                            </XPoint>
                        </XRectangle.TopLeft>
                    </XRectangle>
                </XPoint.Shape>
                <XPoint.State>Visible, Printable, Connector, None</XPoint.State>
                <XPoint.Style>
                    <x:Null />
                </XPoint.Style>
                <XPoint.X>15</XPoint.X>
                <XPoint.Y>30</XPoint.Y>
            </XPoint>
            <XPoint>
                <XPoint.Data>
                    <XContext Record="{x:Null}">
                        <sci:ImmutableArray x:TypeArguments="XProperty" />
                    </XContext>
                </XPoint.Data>
                <XPoint.IsFilled>False</XPoint.IsFilled>
                <XPoint.IsStroked>False</XPoint.IsStroked>
                <XPoint.Name>""</XPoint.Name>
                <XPoint.Owner>
                    <x:Reference>AND</x:Reference>
                </XPoint.Owner>
                <XPoint.Resources>
                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                </XPoint.Resources>
                <XPoint.Shape>
                    <x:Reference>""</x:Reference>
                </XPoint.Shape>
                <XPoint.State>Visible, Printable, Connector, None</XPoint.State>
                <XPoint.Style>
                    <x:Null />
                </XPoint.Style>
                <XPoint.X>30</XPoint.X>
                <XPoint.Y>15</XPoint.Y>
            </XPoint>
            <XPoint>
                <XPoint.Data>
                    <XContext Record="{x:Null}">
                        <sci:ImmutableArray x:TypeArguments="XProperty" />
                    </XContext>
                </XPoint.Data>
                <XPoint.IsFilled>False</XPoint.IsFilled>
                <XPoint.IsStroked>False</XPoint.IsStroked>
                <XPoint.Name>""</XPoint.Name>
                <XPoint.Owner>
                    <x:Reference>AND</x:Reference>
                </XPoint.Owner>
                <XPoint.Resources>
                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                </XPoint.Resources>
                <XPoint.Shape>
                    <x:Reference>""</x:Reference>
                </XPoint.Shape>
                <XPoint.State>Visible, Printable, Connector, None</XPoint.State>
                <XPoint.Style>
                    <x:Null />
                </XPoint.Style>
                <XPoint.X>0</XPoint.X>
                <XPoint.Y>15</XPoint.Y>
            </XPoint>
            <XPoint>
                <XPoint.Data>
                    <XContext Record="{x:Null}">
                        <sci:ImmutableArray x:TypeArguments="XProperty" />
                    </XContext>
                </XPoint.Data>
                <XPoint.IsFilled>False</XPoint.IsFilled>
                <XPoint.IsStroked>False</XPoint.IsStroked>
                <XPoint.Name>""</XPoint.Name>
                <XPoint.Owner>
                    <x:Reference>AND</x:Reference>
                </XPoint.Owner>
                <XPoint.Resources>
                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                </XPoint.Resources>
                <XPoint.Shape>
                    <x:Reference>""</x:Reference>
                </XPoint.Shape>
                <XPoint.State>Visible, Printable, Connector, None</XPoint.State>
                <XPoint.Style>
                    <x:Null />
                </XPoint.Style>
                <XPoint.X>15</XPoint.X>
                <XPoint.Y>0</XPoint.Y>
            </XPoint>
        </sci:ImmutableArray>
    </XGroup.Connectors>
    <XGroup.Data>
        <XContext Record="{x:Null}">
            <sci:ImmutableArray x:TypeArguments="XProperty" />
        </XContext>
    </XGroup.Data>
    <XGroup.IsFilled>False</XGroup.IsFilled>
    <XGroup.IsStroked>False</XGroup.IsStroked>
    <XGroup.Name>AND</XGroup.Name>
    <XGroup.Owner>
        <x:Null />
    </XGroup.Owner>
    <XGroup.Resources>
        <sci:ImmutableArray x:TypeArguments="ObservableObject" />
    </XGroup.Resources>
    <XGroup.Shapes>
        <sci:ImmutableArray x:TypeArguments="BaseShape">
            <XText>
                <XText.BottomRight>
                    <XPoint>
                        <XPoint.Data>
                            <XContext Record="{x:Null}">
                                <sci:ImmutableArray x:TypeArguments="XProperty" />
                            </XContext>
                        </XPoint.Data>
                        <XPoint.IsFilled>False</XPoint.IsFilled>
                        <XPoint.IsStroked>False</XPoint.IsStroked>
                        <XPoint.Name>""</XPoint.Name>
                        <XPoint.Owner>
                            <x:Null />
                        </XPoint.Owner>
                        <XPoint.Resources>
                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                        </XPoint.Resources>
                        <XPoint.Shape>
                            <x:Reference>""</x:Reference>
                        </XPoint.Shape>
                        <XPoint.State>Visible, Printable, Standalone</XPoint.State>
                        <XPoint.Style>
                            <x:Null />
                        </XPoint.Style>
                        <XPoint.X>30</XPoint.X>
                        <XPoint.Y>30</XPoint.Y>
                    </XPoint>
                </XText.BottomRight>
                <XText.Data>
                    <XContext x:Name="__ReferenceID0" Record="{x:Null}">
                        <sci:ImmutableArray x:TypeArguments="XProperty">
                            <XProperty x:Name="__ReferenceID1" Name="Label" Owner="{x:Reference __ReferenceID0}">&amp;</XProperty>
                        </sci:ImmutableArray>
                    </XContext>
                </XText.Data>
                <XText.IsFilled>False</XText.IsFilled>
                <XText.IsStroked>True</XText.IsStroked>
                <XText.Name>""</XText.Name>
                <XText.Owner>
                    <x:Reference>AND</x:Reference>
                </XText.Owner>
                <XText.Resources>
                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                </XText.Resources>
                <XText.State>Visible, Printable</XText.State>
                <XText.Style>
                    <ShapeStyle DashOffset="0" Dashes="{x:Null}">
                        <ShapeStyle.EndArrowStyle>
                            <ArrowStyle ArrowType="None" DashOffset="0" Dashes="{x:Null}" Fill="#FF000000" IsFilled="False" IsStroked="True" LineCap="Round" Name="End" RadiusX="5" RadiusY="5">
                                <ArrowStyle.Resources>
                                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                </ArrowStyle.Resources>
                                <ArrowStyle.Stroke>#FF000000</ArrowStyle.Stroke>
                                <ArrowStyle.Thickness>2</ArrowStyle.Thickness>
                            </ArrowStyle>
                        </ShapeStyle.EndArrowStyle>
                        <ShapeStyle.Fill>#FF000000</ShapeStyle.Fill>
                        <ShapeStyle.LineCap>Round</ShapeStyle.LineCap>
                        <ShapeStyle.LineStyle>
                            <LineStyle>
                                <LineStyle.FixedLength>
                                    <LineFixedLength All="False" Disabled="True" End="False" EndTrigger="Connector, Input" Horizontal="False" Length="0" Start="False" StartTrigger="Connector, Output" Vertical="False">Disabled</LineFixedLength>
                                </LineStyle.FixedLength>
                                <LineStyle.Name>Line</LineStyle.Name>
                            </LineStyle>
                        </ShapeStyle.LineStyle>
                        <ShapeStyle.Name>TextCenterLarge</ShapeStyle.Name>
                        <ShapeStyle.Resources>
                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                        </ShapeStyle.Resources>
                        <ShapeStyle.StartArrowStyle>
                            <ArrowStyle ArrowType="None" DashOffset="0" Dashes="{x:Null}" Fill="#FF000000" IsFilled="False" IsStroked="True" LineCap="Round" Name="Start" RadiusX="5" RadiusY="5">
                                <ArrowStyle.Resources>
                                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                </ArrowStyle.Resources>
                                <ArrowStyle.Stroke>#FF000000</ArrowStyle.Stroke>
                                <ArrowStyle.Thickness>2</ArrowStyle.Thickness>
                            </ArrowStyle>
                        </ShapeStyle.StartArrowStyle>
                        <ShapeStyle.Stroke>#FF000000</ShapeStyle.Stroke>
                        <ShapeStyle.TextStyle>
                            <TextStyle FontFile="C:\Windows\Fonts\calibri.ttf" FontName="Calibri" FontSize="13" FontStyle="Regular" Name="Text" TextHAlignment="Center" TextVAlignment="Center" />
                        </ShapeStyle.TextStyle>
                        <ShapeStyle.Thickness>2</ShapeStyle.Thickness>
                    </ShapeStyle>
                </XText.Style>
                <XText.Text>{0}</XText.Text>
                <XText.TopLeft>
                    <XPoint>
                        <XPoint.Data>
                            <XContext Record="{x:Null}">
                                <sci:ImmutableArray x:TypeArguments="XProperty" />
                            </XContext>
                        </XPoint.Data>
                        <XPoint.IsFilled>False</XPoint.IsFilled>
                        <XPoint.IsStroked>False</XPoint.IsStroked>
                        <XPoint.Name>""</XPoint.Name>
                        <XPoint.Owner>
                            <x:Null />
                        </XPoint.Owner>
                        <XPoint.Resources>
                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                        </XPoint.Resources>
                        <XPoint.Shape>
                            <x:Reference>""</x:Reference>
                        </XPoint.Shape>
                        <XPoint.State>Visible, Printable, Standalone</XPoint.State>
                        <XPoint.Style>
                            <x:Null />
                        </XPoint.Style>
                        <XPoint.X>0</XPoint.X>
                        <XPoint.Y>0</XPoint.Y>
                    </XPoint>
                </XText.TopLeft>
            </XText>
            <XRectangle>
                <XRectangle.BottomRight>
                    <XPoint>
                        <XPoint.Data>
                            <XContext Record="{x:Null}">
                                <sci:ImmutableArray x:TypeArguments="XProperty" />
                            </XContext>
                        </XPoint.Data>
                        <XPoint.IsFilled>False</XPoint.IsFilled>
                        <XPoint.IsStroked>False</XPoint.IsStroked>
                        <XPoint.Name>""</XPoint.Name>
                        <XPoint.Owner>
                            <x:Null />
                        </XPoint.Owner>
                        <XPoint.Resources>
                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                        </XPoint.Resources>
                        <XPoint.Shape>
                            <x:Reference>""</x:Reference>
                        </XPoint.Shape>
                        <XPoint.State>Visible, Printable, Standalone</XPoint.State>
                        <XPoint.Style>
                            <x:Null />
                        </XPoint.Style>
                        <XPoint.X>30</XPoint.X>
                        <XPoint.Y>30</XPoint.Y>
                    </XPoint>
                </XRectangle.BottomRight>
                <XRectangle.CellHeight>30</XRectangle.CellHeight>
                <XRectangle.CellWidth>30</XRectangle.CellWidth>
                <XRectangle.Data>
                    <XContext Record="{x:Null}">
                        <sci:ImmutableArray x:TypeArguments="XProperty" />
                    </XContext>
                </XRectangle.Data>
                <XRectangle.IsFilled>False</XRectangle.IsFilled>
                <XRectangle.IsGrid>False</XRectangle.IsGrid>
                <XRectangle.IsStroked>True</XRectangle.IsStroked>
                <XRectangle.Name>""</XRectangle.Name>
                <XRectangle.OffsetX>30</XRectangle.OffsetX>
                <XRectangle.OffsetY>30</XRectangle.OffsetY>
                <XRectangle.Owner>
                    <x:Reference>AND</x:Reference>
                </XRectangle.Owner>
                <XRectangle.Resources>
                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                </XRectangle.Resources>
                <XRectangle.State>Visible, Printable</XRectangle.State>
                <XRectangle.Style>
                    <ShapeStyle DashOffset="0" Dashes="{x:Null}">
                        <ShapeStyle.EndArrowStyle>
                            <ArrowStyle ArrowType="None" DashOffset="0" Dashes="{x:Null}" Fill="#FF000000" IsFilled="False" IsStroked="True" LineCap="Round" Name="End" RadiusX="5" RadiusY="5">
                                <ArrowStyle.Resources>
                                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                </ArrowStyle.Resources>
                                <ArrowStyle.Stroke>#FF000000</ArrowStyle.Stroke>
                                <ArrowStyle.Thickness>2</ArrowStyle.Thickness>
                            </ArrowStyle>
                        </ShapeStyle.EndArrowStyle>
                        <ShapeStyle.Fill>#FF000000</ShapeStyle.Fill>
                        <ShapeStyle.LineCap>Round</ShapeStyle.LineCap>
                        <ShapeStyle.LineStyle>
                            <LineStyle>
                                <LineStyle.FixedLength>
                                    <LineFixedLength All="False" Disabled="True" End="False" EndTrigger="Connector, Input" Horizontal="False" Length="0" Start="False" StartTrigger="Connector, Output" Vertical="False">Disabled</LineFixedLength>
                                </LineStyle.FixedLength>
                                <LineStyle.Name>Line</LineStyle.Name>
                            </LineStyle>
                        </ShapeStyle.LineStyle>
                        <ShapeStyle.Name>LineBold</ShapeStyle.Name>
                        <ShapeStyle.Resources>
                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                        </ShapeStyle.Resources>
                        <ShapeStyle.StartArrowStyle>
                            <ArrowStyle ArrowType="None" DashOffset="0" Dashes="{x:Null}" Fill="#FF000000" IsFilled="False" IsStroked="True" LineCap="Round" Name="Start" RadiusX="5" RadiusY="5">
                                <ArrowStyle.Resources>
                                    <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                                </ArrowStyle.Resources>
                                <ArrowStyle.Stroke>#FF000000</ArrowStyle.Stroke>
                                <ArrowStyle.Thickness>2</ArrowStyle.Thickness>
                            </ArrowStyle>
                        </ShapeStyle.StartArrowStyle>
                        <ShapeStyle.Stroke>#FF000000</ShapeStyle.Stroke>
                        <ShapeStyle.TextStyle>
                            <TextStyle FontFile="C:\Windows\Fonts\calibri.ttf" FontName="Calibri" FontSize="12" FontStyle="Regular" Name="Text" TextHAlignment="Center" TextVAlignment="Center" />
                        </ShapeStyle.TextStyle>
                        <ShapeStyle.Thickness>2</ShapeStyle.Thickness>
                    </ShapeStyle>
                </XRectangle.Style>
                <XRectangle.Text>
                    <x:Null />
                </XRectangle.Text>
                <XRectangle.TopLeft>
                    <XPoint>
                        <XPoint.Data>
                            <XContext Record="{x:Null}">
                                <sci:ImmutableArray x:TypeArguments="XProperty" />
                            </XContext>
                        </XPoint.Data>
                        <XPoint.IsFilled>False</XPoint.IsFilled>
                        <XPoint.IsStroked>False</XPoint.IsStroked>
                        <XPoint.Name>""</XPoint.Name>
                        <XPoint.Owner>
                            <x:Null />
                        </XPoint.Owner>
                        <XPoint.Resources>
                            <sci:ImmutableArray x:TypeArguments="ObservableObject" />
                        </XPoint.Resources>
                        <XPoint.Shape>
                            <x:Reference>""</x:Reference>
                        </XPoint.Shape>
                        <XPoint.State>Visible, Printable, Standalone</XPoint.State>
                        <XPoint.Style>
                            <x:Null />
                        </XPoint.Style>
                        <XPoint.X>0</XPoint.X>
                        <XPoint.Y>0</XPoint.Y>
                    </XPoint>
                </XRectangle.TopLeft>
            </XRectangle>
        </sci:ImmutableArray>
    </XGroup.Shapes>
    <x:Reference>__ReferenceID1</x:Reference>
    <XGroup.State>Visible, Printable, Standalone</XGroup.State>
    <XGroup.Style>
        <x:Null />
    </XGroup.Style>
</XGroup>
cwensley commented 7 years ago

@wieslawsoltes Ok, I've tried but I can't seem to replicate this issue. Is this still occurring for you?

wieslawsoltes commented 7 years ago

@cwensley

Yes I still get the exception and its easily reproducible in my app. I'm using version 0.15.0 from NuGet and latest appveyor build.

This is my serializer code:

https://github.com/wieslawsoltes/Core2D/tree/master/src/Serializer.Xaml

This is my app:

https://github.com/wieslawsoltes/Core2D/tree/master/src/Core2D.Wpf

Video how to reproduce:

2017-03-05_09-37-03

wieslawsoltes commented 7 years ago

@cwensley Tested with version 0.16.0

Core2D.Avalonia.Direct2D.exe Error: 0 : Unresolved object reference 'AND' was found
   w Portable.Xaml.XamlObjectWriterInternal.ResolvePendingReferences()
   w Portable.Xaml.XamlObjectWriterInternal.OnWriteEndObject()
   w Portable.Xaml.XamlWriterInternalBase.WriteEndObject()
   w Portable.Xaml.XamlWriterInternalBase.CloseAll()
   w Portable.Xaml.XamlObjectWriter.Dispose(Boolean disposing)
   w Portable.Xaml.XamlWriter.System.IDisposable.Dispose()
   w Serializer.Xaml.CoreXamlReader.Load(XamlXmlReader reader)
   w Serializer.Xaml.CoreXamlReader.Load(TextReader textReader)
   w Serializer.Xaml.CoreXamlSerializer.Deserialize[T](String xaml)
   w Serializer.Xaml.PortableXamlSerializer.Core2D.Interfaces.IXamlSerializer.Deserialize[T](String xaml)
   w Core2D.Editor.ProjectEditor.OnImportXamlString(String xaml)
   w Core2D.Editor.ProjectEditor.OnImportXaml(String path)

Updated Xaml for latest version of Core2D https://gist.github.com/wieslawsoltes/dcc5ee153d1bdd8d89a654ac13750b2f

wieslawsoltes commented 7 years ago

This may be related to how the Name property is written by Portable.Xaml as cs:Name="AND": https://gist.github.com/wieslawsoltes/dcc5ee153d1bdd8d89a654ac13750b2f#file-and-xaml-L1 https://github.com/wieslawsoltes/Core2D/blob/master/src/Serializer.Xaml/CoreAttributeProvider.cs#L24 https://github.com/wieslawsoltes/Core2D/blob/master/src/Core2D/Attributes/NameAttribute.cs#L11 https://github.com/wieslawsoltes/Core2D/blob/master/src/Core2D/Shape/BaseShape.cs#L42 https://github.com/wieslawsoltes/Core2D/blob/master/src/Core2D/Shapes/XGroup.cs#L16

wieslawsoltes commented 7 years ago

@cwensley I have created minimal reproduction for this issue here (standalone .Net Core console app): https://github.com/wieslawsoltes/Core2D/tree/PortableXamlIssue20/apps/PortableXamlRepro

cwensley commented 7 years ago

@wieslawsoltes, awesome thanks for putting together a more minimal reproduction! I'll try to get this down to "unit test size", e.g. the most minimal to repro the issue without dependencies so I can add a unit test for it.

I think you might be right in that the namespaces that are causing the issue here. It's pretty odd that it's using a different namespace for the properties of the class and it could be something to do with how it resolves base class property namespaces. This points mainly to a writer problem where I was looking at the reader before.

My guess is that it should be writing the properties without a namespace prefix here, which may end up fixing loading. However, I'll also test to see if System.Xaml can handle this particular situation, and if so, the reader should be updated for that too.

cwensley commented 7 years ago

Ok, this should hopefully be fixed! Thanks for the pointer on the namespaces as Portable.Xaml was writing invalid xaml in that case. All attributes and elements of the parent element should not have a namespace defined even if they are from a base class in a different namespace.

If you have time, I'd love it if you can give it a go and see if it works for your app.

wieslawsoltes commented 7 years ago

@cwensley Tested merged fixes and generated xaml is better: https://gist.github.com/wieslawsoltes/38b21783d88dba1e0c022599011a9131 and this exception is gone.

But got another issue reported here https://github.com/cwensley/Portable.Xaml/issues/55