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

Allow reading / writing comments #18

Closed
Bluscream opened this issue Apr 6, 2020 · 13 comments
Closed

Allow reading / writing comments #18

Bluscream opened this issue Apr 6, 2020 · 13 comments

Comments

@Bluscream
Copy link

It would be nice if the parser would try to parse commented lines and fallback to just storing them as strings when parsing fails (a regular comment)

Sent from my TAB 2 A10 using FastHub

@Bluscream
Copy link
Author

Bluscream commented Apr 8, 2020

I did something similar for another app once (it was regex tho):
https://github.com/Bluscream/MWR-Config-Editor/blob/master/CFGParser/Classes/CFGFile.cs#L28

@Bluscream
Copy link
Author

Any news on this @shravan2x? my app is depending on it :c

@shravan2x
Copy link
Owner

Any news on this @shravan2x? my app is depending on it :c

I didn't realize it was blocking, I'll work on it this weekend. But can't you just save without the comments?

I did something similar for another app once (it was regex tho):

I can't use Regex for performance reasons.

@Bluscream
Copy link
Author

I didn't realize it was blocking, I'll work on it this weekend. But can't you just save without the comments?

In my case the comments are used as "Disabled Entries" and they would be lost and had to be recreated

@shravan2x
Copy link
Owner

shravan2x commented May 17, 2020

@Bluscream Which of the following types of comments do you plan to use?

// Comment type A (at the start of the file)
"root"
{
    // Comment type B (as a child to an object)
    key1 "value1"
    "key2" // Comment type C (to the right of a property name)
    {
        "key3" "value3" // Comment type D (to the right of a property value)
    }
}
// Comment type E (at the end of the file)

Would it suffice if deserializing then re-serializing this file resulted in this?

"root"
{
        // Comment type B (as a child to an object)
        "key1" "value1"
        "key2"
        {
                "key3" "value3"
                // Comment type D (to the right of a property value)
        }
}

@Bluscream
Copy link
Author

Bluscream commented May 17, 2020

Only B is important to me when serializing but i think when deserializing it might be good to be able to get the others aswell

@shravan2x
Copy link
Owner

shravan2x commented May 17, 2020

I've built support for comments locally, I plan to commit them to the repo in the next few days and then release 0.6.0. So far, this is the progress:

  • A - unsupported (i.e. ignored)
  • B - full support
  • C - unsupported (i.e. ignored)
  • D - supported, but is moved to a new line during serialization
  • E - unsupported (i.e. ignored)

There are challenges associated with supporting the others, especially A and E (until #23 is resolved, there's no place to store these comments). I'll leave this issue open and revisit it after #23. But hopefully, support for B and D will unblock you.

@shravan2x
Copy link
Owner

shravan2x commented May 21, 2020

Resolved with 0855a05, I'll push 0.6.0 soon.

Note that this update includes a breaking change - myvobject.Children() now returns IEnumerable<VToken> instead of IEnumerable<VProperty>. If you want the old behavior, use myvobject.Properties() instead.

@shravan2x
Copy link
Owner

Fyi to create a comment from code you do VValue.CreateComment("some comment string").

@Bluscream
Copy link
Author

When is this pushed to nuget so i can use it in production?

@shravan2x
Copy link
Owner

Sorry, I'm polishing some other NRT issues on VObject because otherwise they'd become breaking changes in 0.7.0 (which I plan to add support for conditionals in). I'll push it tomorrow.

@shravan2x
Copy link
Owner

@Bluscream 0.6.0 is out.

@Bluscream
Copy link
Author

I might pick the project back up soon, so thanks <3

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

No branches or pull requests

2 participants