Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Moryx/Serialization/EntryConvert/EntryConvert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public static Entry EncodeObject(object instance, ICustomSerialization customSer
{
//exclude property that can lead to self reference
var propertyType = property.PropertyType;
if (propertyType == instanceType)
if (propertyType == instanceType || propertyType.IsAssignableFrom(instanceType))
{
continue;
}
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Moryx.Tests/Moryx.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Moryx.AbstractionLayer\Moryx.AbstractionLayer.csproj" />
Comment thread
juzo1306 marked this conversation as resolved.
Resolved
<ProjectReference Include="..\..\Moryx.TestTools.UnitTest\Moryx.TestTools.UnitTest.csproj" />
<ProjectReference Include="..\..\Moryx\Moryx.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0

using Moryx.AbstractionLayer.Resources;
using Moryx.Serialization;

namespace Moryx.Tests.Serialization;
Expand Down Expand Up @@ -124,3 +125,9 @@ public class AlwaysAttributedDerivedType : NeverAttributedBaseType

public bool NullProperty3 { get; set; }
}

public class MyResourceWithStateBaseProperty : Resource
{
[EntrySerialize]
internal MyStateBase State { get; private set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0

using System.Globalization;
using Moryx.AbstractionLayer.Resources;
using Moryx.Serialization;
using NUnit.Framework;

Expand Down Expand Up @@ -224,4 +225,13 @@ public void ClassWithSerializationAttribute()
var alwaysProperties = 3;
Assert.That(alwaysProperties, Is.EqualTo(encoded.SubEntries.Count));
}

[Test]
public void SerializeStateBaseClass()
{
//Arrange
var resource = new MyResourceWithStateBaseProperty();
Assert.DoesNotThrow(() => EntryConvert.EncodeObject(resource));
}
}

Loading