@@ -36,12 +36,23 @@ public static Config Read(TextReader reader)
36
36
}
37
37
38
38
public static void Write ( Config config , TextWriter writer )
39
+ {
40
+ Write ( config , writer , newLine : string . Empty ) ;
41
+ }
42
+
43
+ public static void Write ( Config config , TextWriter writer , string newLine )
39
44
{
40
45
_logger . Debug ( "Starting serializing yaml configuration..." ) ;
41
46
var serializerBuilder = new SerializerBuilder ( )
42
47
. WithTypeInspector ( inner => new CommentGatheringTypeInspector ( inner ) )
43
48
. WithEmissionPhaseObjectGraphVisitor ( args => new CommentsObjectGraphVisitor ( args . InnerVisitor ) )
44
49
. WithNamingConvention ( HyphenatedNamingConvention . Instance ) ;
50
+
51
+ if ( ! string . IsNullOrEmpty ( newLine ) )
52
+ {
53
+ serializerBuilder = serializerBuilder . WithNewLine ( newLine ) ;
54
+ }
55
+
45
56
var serializer = serializerBuilder . Build ( ) ;
46
57
serializer . Serialize ( writer , config ) ;
47
58
_logger . Verbose ( "Successfully serialized configuration!" ) ;
@@ -67,11 +78,10 @@ public static void WriteSample(TextWriter writer)
67
78
var configType = config . GetType ( ) ;
68
79
69
80
writer . Write ( "#" ) ;
70
- writer . NewLine = Environment . NewLine + "#" ;
71
81
SetConfigurationSamples ( config , configType , writer ) ;
72
82
73
83
_logger . Verbose ( "Writing sample" ) ;
74
- Write ( config , writer ) ;
84
+ Write ( config , writer , newLine : Environment . NewLine + "#" ) ;
75
85
}
76
86
77
87
private static void SetConfigurationSamples ( object config , Type configType , TextWriter writer )
0 commit comments