Skip to content

Commit b617523

Browse files
committed
add runes to known safe types
1 parent e526f64 commit b617523

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

FastCloner.Tests/SpecialCaseTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,52 @@ public unsafe void Test_Unnamed_Type()
973973
});
974974
}
975975

976+
[Test]
977+
public void Test_Rune()
978+
{
979+
// Arrange
980+
Rune obj = new Rune(0x1F44D);
981+
982+
// Act
983+
Rune result = obj.DeepClone();
984+
985+
// Assert
986+
Assert.Multiple(() =>
987+
{
988+
Assert.That(result, Is.EqualTo(obj));
989+
Assert.That(result, Is.EqualTo(obj));
990+
Assert.That(result.Value, Is.EqualTo(obj.Value));
991+
Assert.That(result.ToString(), Is.EqualTo("👍"));
992+
});
993+
}
994+
995+
[Test]
996+
public void Test_RuneContainer()
997+
{
998+
// Arrange
999+
RuneContainer container = new RuneContainer
1000+
{
1001+
// Emoji '🚀' (ROCKET) - Unicode U+1F680
1002+
RuneValue = new Rune(0x1F680)
1003+
};
1004+
1005+
// Act
1006+
RuneContainer result = container.DeepClone();
1007+
1008+
// Assert
1009+
Assert.Multiple(() =>
1010+
{
1011+
Assert.That(ReferenceEquals(result, container), Is.False);
1012+
Assert.That(result.RuneValue, Is.EqualTo(container.RuneValue));
1013+
Assert.That(result.RuneValue.ToString(), Is.EqualTo("🚀"));
1014+
});
1015+
}
1016+
1017+
public class RuneContainer
1018+
{
1019+
public Rune RuneValue { get; set; }
1020+
}
1021+
9761022
[Test]
9771023
public void Test_TimeSpan()
9781024
{

FastCloner/Code/FastClonerSafeTypes.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Concurrent;
22
using System.Reflection;
3+
using System.Text;
34

45
namespace FastCloner.Code;
56

@@ -28,6 +29,7 @@ internal static class FastClonerSafeTypes
2829
[typeof(nint)] = true,
2930
[typeof(nuint)] = true,
3031
[typeof(Guid)] = true,
32+
[typeof(Rune)] = true,
3133

3234
// Time-related types
3335
[typeof(TimeSpan)] = true,

0 commit comments

Comments
 (0)