File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
- //-----------------------------------------------------------------------
1
+ //-----------------------------------------------------------------------
2
2
// <copyright file="HoconTests.cs" company="Hocon Project">
3
3
// Copyright (C) 2009-2018 Lightbend Inc. <http://www.lightbend.com>
4
4
// Copyright (C) 2013-2018 .NET Foundation <https://github.com/akkadotnet/hocon>
@@ -230,6 +230,19 @@ public void CanParseObject()
230
230
Assert . Equal ( "1" , Parser . Parse ( hocon ) . GetString ( "a.b" ) ) ;
231
231
}
232
232
233
+ [ Fact ]
234
+ public void CanParseQuotedElements ( )
235
+ {
236
+ var hocon = @"
237
+ A.B = 1
238
+ A {
239
+ ""X.Y"" = 1
240
+ }
241
+ " ;
242
+ var ex = Record . Exception ( ( ) => Parser . Parse ( hocon ) . GetObject ( "A" ) ) ;
243
+ Assert . Null ( ex ) ;
244
+ }
245
+
233
246
[ Fact ]
234
247
public void CanTrimValue ( )
235
248
{
Original file line number Diff line number Diff line change @@ -171,9 +171,15 @@ public HoconField GetField(HoconPath path)
171
171
172
172
if ( path . Count == 0 )
173
173
throw new ArgumentException ( "Path is empty." , nameof ( path ) ) ;
174
-
175
- var pathIndex = 0 ;
174
+
176
175
var currentObject = this ;
176
+
177
+ // Sometimes path may be a double-quoted string like "a.b.c" with quotes ommited,
178
+ // so check if there is such key first
179
+ if ( currentObject . TryGetValue ( path . ToString ( ) , out var rootField ) )
180
+ return rootField ;
181
+
182
+ var pathIndex = 0 ;
177
183
while ( true )
178
184
{
179
185
var key = path [ pathIndex ] ;
You can’t perform that action at this time.
0 commit comments