fluffynuts / PeanutButter

Tasty, versatile, nutritious; goes with many things in .net.
BSD 3-Clause "New" or "Revised" License
179 stars 32 forks source link

[PeanutButter.INI] How can I add an empty line at the last line? #74

Closed AndrewKeepCoding closed 2 years ago

AndrewKeepCoding commented 2 years ago

I'm working with an old library that load an INI file and I'm editing its INI file with PeanutButter.INI. The problem I'm facing is that PeanutButter.INI removes empty lines in at the bottom of the file. Apparently, the library needs those empty lines.

Expected Behavior

Not removing empty lines at the bottom.

Actual Behavior

Removes all empty lines at the bottom.

Steps to Reproduce the Problem

  1. Load an exsiting INI file.
  2. Call Persit().

Specifications

fluffynuts commented 2 years ago

Typically, PB.INI trims your INI file; but I don't see a problem with adding an extra newline - is that all that's required?

AndrewKeepCoding commented 2 years ago

Yes. I did a manual test and this old library didn't load the INI file until I added a new line to the INI file trimmed by PB.INI. Can I make PB.INI not to trim the line at the bottom?

fluffynuts commented 2 years ago

not currently - you're welcome to open a PR - I don't think this would negatively affect any other use-case, and the PR should be fairly simple:

2 modifications (for the 2 Persist methods that actually do work - one goes to a file, the other pushes lines to a stream) and 2 tests that prove that they happen. There may be other tests which are broken by the change, but they shouldn't be hard to fix - trim the result of the "Act" block and they should all pass again. Alternatively, I can look at this tomorrow, perhaps.

AndrewKeepCoding commented 2 years ago

I opened a PR. Please take a look. It's a bit different from what you suggested but I think we can avoid change in current use cases.

fluffynuts commented 2 years ago

@AndrewKeepCoding 3.0.6 contains the changes from your PR. Thanks for contributing!

AndrewKeepCoding commented 2 years ago

@fluffynuts The old library works now. Thanks for the quick support!