[WIP] KeyValue: Handle (ignore) conditionals - #232
Conversation
Current coverage is
|
|
Ignoring them is good enough for now, to be honest. |
| { | ||
| return kv.AsString() | ||
| .Replace("\r\n", @"\n") | ||
| .Replace("\n", @"\n"); |
There was a problem hiding this comment.
Is this a mistake? You're replacing \n with \n.
There was a problem hiding this comment.
This replaces <newline> with \n. The @ means an unescaped string :)
|
I made a simple fix for my personal needs. I might add pull request if you think it's useful. It could be sufficient until we have full support for conditionals. It correctly loads up stil/SteamKit@7fcc2418a835c4fba865b8621286211026cd6770 |
|
Closing in favour of new draft PR. |
As pointed out by @xPaw, we crash when reading
tf_english.txt.I narrowed this down to our handling of conditionals - it's completely broken. We count the conditional as a key, then read the next key as a value, etc. until our keys and values are swapped.
Therefore, an empty value after a conditional will trigger the exception that fails a parse on an empty key.
I don't think this is necessarily the best way to handle them, but at least it doesn't crash 😄
Do not merge (yet), I'm only posting this for discussion. How do we want to handle conditionals, and is this the best way?
I think I can see some implementation flaws in this code (i.e. the green part of the diff) but it's getting late and I need to go to bed so I'm stopping for tonight. I know it's not perfect.