Config.Root should contain fallback values #181
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #177
The issue turned out to be little bit deeper then I thought at start.
Assuming that
config
has fallback values,config.Root.GetObject()
returns object not containing fallback values becauseRoot
property of typeHoconValue
does not contain them.Hocon core library does not work with fallbacks in any way - so
HoconValue
does not have any information about possible fallbacks it has.So the way to go is to aggregate all fallback values into Root property, which is what I am doing. Since
HoconValue
type is mutable, making separate value and putting values in reverse order - to support proper fallbacks ordering when hocon will merge inner objects.Also, seems like few more functions in
Config
file were trying to check if any fallbacks exist - there is no need to do this anymore, since we always have magicRoot
value that already contains aggregatedHoconValue
with all fallbacks included.Added more tests to verify that deep objects merge correctly. And, important thing - fixed
config.ToString(useFallbackValues: true)
implementation, since old one was dropping original values and was only using fallback values. Updated test for this as well.