File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
YamlDotNet.Test/Serialization Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ using Xunit ;
2
+ using Xunit . Abstractions ;
3
+ using YamlDotNet . Serialization ;
4
+
5
+ namespace YamlDotNet . Test . Serialization
6
+ {
7
+ public class YamlCommentTests
8
+ {
9
+ protected readonly ITestOutputHelper Output ;
10
+ public YamlCommentTests ( ITestOutputHelper helper )
11
+ {
12
+ Output = helper ;
13
+ }
14
+
15
+ [ Fact ]
16
+ public void SerializationWithComment ( )
17
+ {
18
+ var person = new Person ( ) ;
19
+ person . Name = "PandaTea" ;
20
+ person . Age = 100 ;
21
+ person . Sex = "male" ;
22
+
23
+ Serializer serializer = new Serializer ( ) ;
24
+ string result = serializer . Serialize ( person ) ;
25
+
26
+ Output . WriteLine ( result ) ;
27
+ }
28
+
29
+ class Person
30
+ {
31
+ [ YamlMember ( Description = "this is a yaml comment about name property" ) ]
32
+ public string Name { get ; set ; }
33
+ [ YamlMember ( Description = "this is age" ) ]
34
+ public int Age { get ; set ; }
35
+ [ YamlMember ( Description = "male or female" ) ]
36
+ public string Sex { get ; set ; }
37
+ }
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments