Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve round-tripping and be a bit more liberal #7

Merged
merged 4 commits into from
Jul 14, 2015

Conversation

colinbate
Copy link
Contributor

I'm not expecting this PR to be taken at face value necessarily because I know that I've changed a fair bit, including one breaking change with the keys not within a section.

My motivation was to allow the library to handle Mercurial .hgrc files which are .ini-like, and to enable better round-tripping of the files.

The changes include:

  • Using an OrderedDictionary (in a PowerShell 2.0 friendly way) instead of normal hashtables.
  • Providing an option to treat lines starting with # as comments in addition to ;.
  • Providing an option to not add comments to the resulting data structure.
  • Using the underscore _ as the section-less section instead of No-Section. I'd be okay to change that back if desired.
  • Using UTF8 as the default encoding.
  • Adding an option to have spaces around the equal sign when writing out.
  • Not requiring that files end with .ini

@colinbate colinbate changed the title Use OrderedDictionary, support # comments, utf8 by default and better ro... Improve round-tripping and be a bit more liberal Apr 6, 2015
@craibuc
Copy link
Collaborator

craibuc commented Apr 9, 2015

Please post an example of an INI file that includes a section-less key. Is this a feature that is supported elsewhere in Windows?

Otherwise, I'm OK w/ the enhancements.

I added Pester unit tests to Master. Please run them on you enhancements--add and modify tests if necessary.

@colinbate
Copy link
Contributor Author

Honestly, I don't know whether other Windows apps support section-less keys, but PsIni supported them, I just changed the support so they would round-trip. I'm on vacation at the moment and don't have access to a Windows machine until the second week of May. I will update/add tests when I get back to work. Thanks.

@lipkau lipkau self-assigned this Jun 19, 2015
@lipkau lipkau added the on hold label Jun 19, 2015
@lipkau
Copy link
Owner

lipkau commented Jun 19, 2015

Hi
can you update your code to release v1.0.4?
if so I will merge the PR.

thanks

@colinbate
Copy link
Contributor Author

I'm in the midst of sorting out the tests and I wanted to mention that as they are, the tests don't pass because of the FilePath validation for creating a file. It doesn't like the : or \ used in a full path. I'm going to add them into the regex so that the tests pass (and it seems like supporting full paths is probably the intention).

Is there a reason to have the complex regex there and not just let the call to New-Item fail if an invalid path is given?

@colinbate
Copy link
Contributor Author

I've merged with 1.0.4 and I've added some tests. However one of the existing tests was failing and is still failing due to the ordering issue with hashtables. I'm not sure you can input a hashtable and assert an exact string match. Let me know if there are more changes necessary.

lipkau added a commit that referenced this pull request Jul 14, 2015
Improve round-tripping and be a bit more liberal
@lipkau lipkau merged commit c3addce into lipkau:master Jul 14, 2015
@lipkau
Copy link
Owner

lipkau commented Jul 14, 2015

Thank you Colin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants