Skip to content

Hand out the defaults when an older project has no automatic RT correction parameter - #837

Merged
htsugawa merged 1 commit into
masterfrom
fix/automatic-rt-correction-null-on-old-projects
Oct 18, 2026
Merged

htsugawa merged 1 commit into
masterfrom
fix/automatic-rt-correction-null-on-old-projects

Conversation

@htsugawa

Copy link
Copy Markdown
Contributor

Problem

Opening a project saved before automatic alignment RT correction existed, and exporting its parameters, throws:

CompMs.MsdialCore.Parameter.AlignmentBaseParameter.AutomaticRtCorrection.get returned null.

AlignmentBaseParameter.AutomaticRtCorrection is MessagePack key 10, added after projects with keys 0-9 were saved. MessagePack 1.x gives an absent key its type's default (null), not the member initialiser, so the nested parameter loads as null. ParameterBase.ParametersAsText dereferences it (the "Execute automatic RT correction for alignment" line and the 15 after it), and so does the GUI's LcmsAlignmentModel (AutomaticRtCorrection.Execute), so the same project would also fail when its LC-MS alignment opens.

Fix

The getter hands out the defaults when the value is null, put in place once and atomically, the same way ParameterBase.LipidRtCheckParam already handles its key 18. An older project therefore exports its parameters and aligns with automatic RT correction off, as it was saved. A stored value is kept, and the MessagePack layout is unchanged.

Tests

New MsdialCoreTests/Parameter/AlignmentBaseParameterTests, using the existing pattern of saving with a type that predates the key and loading as the current type:

  • a project saved without key 10 loads with the defaults (Execute false), keeps its other values, and returns the same instance each time;
  • such a project's ParametersAsText() no longer throws;
  • a stored AutomaticRtCorrection round-trips;
  • assigning null hands out the defaults.

Without the fix, 3 of the 4 fail, and the export test fails with the NullReferenceException reported above.

Local runs (Release):

  • MsdialCoreTests: 786 passed, 15 skipped, 0 failed.
  • MsdialCoreTestAppTests: 197 passed, 0 failed.

🤖 Generated with Claude Code

…ction parameter

AlignmentBaseParameter.AutomaticRtCorrection is MessagePack key 10, added after
projects with keys 0-9 were saved. MessagePack 1.x gives an absent key its type's
default rather than the member initialiser, so such a project loaded it as null
and the parameter export threw (AutomaticRtCorrection.get returned null); the
GUI's LC-MS alignment view reads it the same way.

The getter now hands out the defaults when the value is null, put in place once
and atomically, as LipidRtCheckParam already does. An older project therefore
exports its parameters and aligns with automatic RT correction off, as it was
saved. A stored value is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@htsugawa

Copy link
Copy Markdown
Contributor Author

MsdialGuiAppTests (Release, net48) on this branch: 197 passed, 0 failed.

🤖 Generated with Claude Code

@htsugawa
htsugawa merged commit 6d3dd6a into master Oct 18, 2026
1 check passed
@htsugawa
htsugawa deleted the fix/automatic-rt-correction-null-on-old-projects branch October 18, 2026 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant