Skip to content

Commit 14cfd74

Browse files
committed
XmlSerializer test for DefaultValueAttributes
1 parent 953ff59 commit 14cfd74

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Xml.Serialization;
2+
using System.ComponentModel;
3+
4+
using NUnit.Framework;
5+
6+
namespace System.XmlTests {
7+
public class C {
8+
[DefaultValue(typeof(C), "c")]
9+
public Type? T { get; }
10+
}
11+
12+
[TestFixture]
13+
public class XmlSerializerTest {
14+
15+
[Test]
16+
public void TrimmingDefaultValueAttribute ()
17+
{
18+
// Context: https://github.com/dotnet/runtime/issues/109724
19+
var s = new XmlSerializer(typeof(C));
20+
_ = new C().T; // Prevent C.T from being removed by trimming
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)