Skip to content

Commit 1d81ae7

Browse files
IgorFedchenkoAaronontheweb
authored andcommitted
Fix config.ToString (#143)
* Fixed config.ToString indent exception * Minor warning fix
1 parent 3cca01a commit 1d81ae7

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/Hocon.Immutable/HoconImmutableLiteral.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public sealed class HoconImmutableLiteral : HoconImmutableElement, IEquatable<Ho
1919
{
2020
public static readonly HoconImmutableLiteral Null = HoconImmutableLiteral.Create(null);
2121

22-
public string Value { get; }
22+
public new string Value { get; }
2323

2424
private HoconImmutableLiteral(string value)
2525
{

src/Hocon.Tests/HoconTests.cs

+18
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,24 @@ public void CanAssignArrayToField()
395395
//Assert.True(new[] { 1, 2, 3 }.SequenceEqual(Parser.Parse(hocon).GetIntList("a")));
396396
}
397397

398+
/// <summary>
399+
/// Related issue: https://github.com/akkadotnet/HOCON/issues/108
400+
/// </summary>
401+
[Fact]
402+
public void Config_ToString_Should_work_properly()
403+
{
404+
var hocon = @"
405+
a {
406+
b = 1
407+
c : {
408+
d = 2
409+
}
410+
}
411+
";
412+
var config = Parser.Parse(hocon);
413+
Record.Exception(() => config.ToString()).Should().BeNull();
414+
}
415+
398416
[Fact]
399417
public void CanConcatenateArray()
400418
{

src/Hocon/Impl/HoconValue.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//-----------------------------------------------------------------------
1+
//-----------------------------------------------------------------------
22
// <copyright file="HoconValue.cs" company="Hocon Project">
33
// Copyright (C) 2009-2018 Lightbend Inc. <http://www.lightbend.com>
44
// Copyright (C) 2013-2018 .NET Foundation <https://github.com/akkadotnet/hocon>
@@ -682,7 +682,7 @@ internal void ReParent(HoconValue value)
682682
/// <returns>A HOCON string representation of this <see cref="HoconValue"/>.</returns>
683683
public override string ToString()
684684
{
685-
return ToString(0, 2);
685+
return ToString(1, 2);
686686
}
687687

688688
/// <inheritdoc />

0 commit comments

Comments
 (0)