Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Strip path from AsEnumerable results #479

Closed
wants to merge 5 commits into from
Closed

Strip path from AsEnumerable results #479

wants to merge 5 commits into from

Conversation

HaoK
Copy link
Member

@HaoK HaoK commented Jul 11, 2016

Fixes #473

@divega

@davidfowl
Copy link
Member

This is a breaking change right?

@HaoK
Copy link
Member Author

HaoK commented Jul 11, 2016

I guess so, we can go back to the business of adding a bool flag to opt into this new 'stripPrefix' behavior

configurationBuilder.Add(memConfigSrc3);

var config = configurationBuilder.Build();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add // Assert comment

@divega
Copy link

divega commented Jul 12, 2016

Not against having a bool parameter on AsEnumerable() to opt in this behavior (I don't think the current behavior is necessarily wrong, just unexpected depending on what you are doing). Read naming, the high level semantics is that paths returned become relative. The fact that we are stripping prefixes is an implementation detail.

@HaoK
Copy link
Member Author

HaoK commented Jul 13, 2016

Updated, adding removePathFromChildKeys to opt into the new behavior, added a few more tests verifying that the value is not shown for children, and also empty keys are supported

@HaoK
Copy link
Member Author

HaoK commented Jul 13, 2016

Also added a test to confirm that this flag does nothing when called on the root (since it has no path)

{
var stack = new Stack<IConfiguration>();
stack.Push(configuration);
var rootSection = configuration as IConfigurationSection;
var prefixLength = (removePathFromChildKeys && rootSection != null) ? rootSection.Path.Length + 1 : 0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this code is kind of ugly, if we represented the Root as simply having a null/empty path with the property on IConfiguration, we wouldn't have to always do this cast to IConfigurationSection every time we do traversal code on config looking for a Path...

@HaoK
Copy link
Member Author

HaoK commented Aug 1, 2016

c202d31

@HaoK HaoK closed this Aug 1, 2016
@HaoK HaoK deleted the haok/7-11enum branch August 24, 2016 22:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants