Uh oh!
There was an error while loading. Please reload this page.
Custom Grade on ItemOptionRandom, Parse map xblock file - #75
Conversation
📝 WalkthroughWalkthroughAdds XML-serializable models for map configuration data, exposes an ChangesParser model updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Maple2.File.Parser/Xml/Map/MapXBlock.cs`:
- Around line 54-55: Update XmlVector3Generator so M2dVector3 serialization
formats all Vector3 components with invariant culture and parsing uses the same
invariant provider. Preserve the X,Y,Z representation used by
MapXBlockCamera.position and camera.rotation, and add a regression test that
exercises round-trip XML serialization/parsing under a culture using comma
decimal separators.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 1f763c35-a322-4cd2-bc36-a0ba21e2b54e
📒 Files selected for processing (3)
Maple2.File.Parser/Maple2.File.Parser.csprojMaple2.File.Parser/Xml/Map/MapXBlock.csMaple2.File.Parser/Xml/Table/Server/ItemOptionRandom.cs
| [M2dVector3] public Vector3 position; | ||
| [M2dVector3] public Vector3 rotation; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bashset -euo pipefail
echo"== files =="
git ls-files | rg '(^|/)MapXBlock\.cs$|(^|/)XmlVector3Generator\.cs$|XBlockParser|Xml'||trueecho"== candidate file sizes =="forfin$(git ls-files | rg '(^|/)MapXBlock\.cs$|(^|/)XmlVector3Generator\.cs$');do
stat -c '%n %s bytes'"$f"doneecho"== outlines =="forfin$(git ls-files | rg '(^|/)MapXBlock\.cs$|(^|/)XmlVector3Generator\.cs$');doecho"--- $f ---"
ast-grep outline "$f"||truedoneecho"== MapXBlock excerpt =="
f=$(git ls-files | rg '(^|/)MapXBlock\.cs$'| head -n1)if [ -n"${f:-}" ];then
nl -ba "$f"| sed -n '1,120p'fiecho"== XmlVector3Generator excerpt =="
g=$(git ls-files | rg '(^|/)XmlVector3Generator\.cs$'| head -n1)if [ -n"${g:-}" ];then
nl -ba "$g"| sed -n '1,240p'fiRepository: MS2Community/Maple2.File
Length of output: 18515
🏁 Script executed:
#!/bin/bashset -euo pipefail
echo"== MapXBlock excerpt =="
f=$(git ls-files | rg '(^|/)MapXBlock\.cs$'| head -n1)if [ -n"${f:-}" ];then
nl -ba "$f"| sed -n '1,140p'fiecho"== XmlVector3Generator excerpt =="
g=$(git ls-files | rg '(^|/)XmlVector3Generator\.cs$'| head -n1)if [ -n"${g:-}" ];then
nl -ba "$g"| sed -n '1,260p'fiecho"== XBlockParser relevant excerpts =="
p=$(git ls-files | rg '(^|/)XBlockParser\.cs$'| head -n1)if [ -n"${p:-}" ];then
nl -ba "$p"| sed -n '1,220p'fiecho"== culture-sensitive parse/format behavior with fr-FR =="
python3 - <<'PY'from decimal import Decimal, DecimalContextErrorvalues = ["123.45", "123,456"]for v in values: for locale_decimal in [".", ","]: # Simulate C# float.Split(' ') + decimal.Parse(string, currentCulture) # when currentCulture DecimalSeparator == "." if locale_decimal == ".": try: parsed = float(v.replace(",", ".")) except ValueError as e: parsed = f"parse-fail-{type(e).__name__}" else: try: parsed = float(v.replace(",", ".")) except ValueError as e: parsed = f"parse-fail-{type(e).__name__}" print(f"value={v}, locale_decimal={locale_decimal!r}, parsed={parsed}")PYecho"== behavioral probe of C# culture parsing in Python? only locale examples maybe sufficient =="Repository: MS2Community/Maple2.File
Length of output: 226
🏁 Script executed:
#!/bin/env shset -euo pipefail
awk '{ printf "%6d\t%s\n", NR, $0 }' Maple2.File.Parser/Xml/Map/MapXBlock.cs | sed -n '1,140p'
awk '{ printf "%6d\t%s\n", NR, $0 }' Maple2.File.Generator/XmlVector3Generator.cs | sed -n '1,260p'
awk '{ printf "%6d\t%s\n", NR, $0 }' Maple2.File.Parser/MapXBlock/XBlockParser.cs | sed -n '1,240p'
awk '{ printf "%6d\t%s\n", NR, $0 }' Maple2.File.Parser/MapXBlock/XBlockParserTest.cs | sed -n '1,400p'Repository: MS2Community/Maple2.File
Length of output: 15378
Make generated Vector3 XML serialization culture-invariant.
MapXBlockCamera.position and camera.rotation use M2dVector3, which emits X,Y,Z and parses components with float.Parse without an invariant provider. In a culture where , is the decimal separator, serialized values can split/misparse or reject valid xblock XML. Update XmlVector3Generator to use invariant formatting/parsing and add a regression test under such a culture.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Maple2.File.Parser/Xml/Map/MapXBlock.cs` around lines 54 - 55, Update
XmlVector3Generator so M2dVector3 serialization formats all Vector3 components
with invariant culture and parsing uses the same invariant provider. Preserve
the X,Y,Z representation used by MapXBlockCamera.position and camera.rotation,
and add a regression test that exercises round-trip XML serialization/parsing
under a culture using comma decimal separators.
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit