Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d92f04c
fix test
YukiMatsuzawa Jul 6, 2026
53f4a16
Add AdductIon fixed-byte round-trip tests
YukiMatsuzawa Jul 6, 2026
ebd5d0a
Add MoleculeProperty messagepack compatibility test
YukiMatsuzawa Jul 6, 2026
f51339a
Add LargeListMessagePack compatibility test
YukiMatsuzawa Jul 6, 2026
720a70c
Merge branch 'yukimatsuzawa-messagepack-moleculeproperty-tests' into …
YukiMatsuzawa Jul 6, 2026
69b79e6
Merge branch 'master' into improve/update-messagepack
YukiMatsuzawa Jul 6, 2026
8710c09
Update MessagePack package versions
YukiMatsuzawa Jul 7, 2026
d9fcc6e
Adapt MessagePack serializers to v3
YukiMatsuzawa Jul 7, 2026
a612576
Fix AnnotatedMSDecResult MessagePack formatter
YukiMatsuzawa Jul 7, 2026
b4e53dc
Checkpoint current MessagePack migration
YukiMatsuzawa Jul 7, 2026
b74804d
Commit staged AdductIon MessagePack fix
YukiMatsuzawa Jul 8, 2026
4b30e02
Commit CommonStandard MessagePack updates
YukiMatsuzawa Jul 8, 2026
25d6890
Commit CommonStandard test updates
YukiMatsuzawa Jul 8, 2026
9575673
Checkpoint ongoing MessagePack fixes
YukiMatsuzawa Jul 8, 2026
98ad6a4
Add deserialization test for LargeListMessagePack
YukiMatsuzawa Jul 8, 2026
391dffd
Merge branch 'improve/update-messagepack' into yukimatsuzawa-refactor…
YukiMatsuzawa Jul 8, 2026
8e249e9
Add LargeListMessagePack compatibility tests
YukiMatsuzawa Jul 9, 2026
a4f99d4
Merge branch 'yukimatsuzawa-messagepack-upgrade-tests' into improve/u…
YukiMatsuzawa Jul 9, 2026
9e61c2c
Restore LargeListMessagePack compatibility
YukiMatsuzawa Jul 9, 2026
6edd908
Merge improve/update-messagepack
YukiMatsuzawa Jul 9, 2026
b3179ef
Merge branch 'yukimatsuzawa-messagepack-compatibility-fix' into impro…
YukiMatsuzawa Jul 9, 2026
85693d3
Remove duplicate LargeListMessagePack tests
YukiMatsuzawa Jul 9, 2026
48025da
Add MessagePack compatibility fixtures
YukiMatsuzawa Jul 9, 2026
65bf03c
Merge branch 'copilot/yukimatsuzawa-messagepack-old-state-tests' into…
YukiMatsuzawa Jul 9, 2026
b07f428
Add legacy MessagePack load coverage
YukiMatsuzawa Jul 10, 2026
f20b893
Add MessagePack legacy byte fixtures
YukiMatsuzawa Jul 10, 2026
f8ef053
Add MessagePack compatibility fixtures
YukiMatsuzawa Jul 10, 2026
0c05925
Merge branch 'copilot/yukimatsuzawa-messagepack-old-state-tests' into…
YukiMatsuzawa Jul 10, 2026
95120df
Fix test
YukiMatsuzawa Jul 10, 2026
1b8c248
Add MessagePack compatibility fixtures for legacy bytes
YukiMatsuzawa Jul 13, 2026
4f9b342
Merge branch 'copilot/yukimatsuzawa-copilot-yukimatsuzawa-animated-en…
YukiMatsuzawa Jul 13, 2026
6f129d9
Expand MessagePack compatibility test coverage
YukiMatsuzawa Jul 13, 2026
1d6718b
Delete the commented-out legacy declaration
YukiMatsuzawa Jul 13, 2026
5cb0293
Update LargeListMessagePack
YukiMatsuzawa Jul 13, 2026
57927d1
Fix IMoleculeProperty serializer
YukiMatsuzawa Jul 13, 2026
7e04793
Fix AdductIon deserializer
YukiMatsuzawa Jul 13, 2026
3fc52f7
Potential fix for pull request finding
YukiMatsuzawa Jul 13, 2026
e17708c
Potential fix for pull request finding
YukiMatsuzawa Jul 13, 2026
05f2205
Potential fix for pull request finding
YukiMatsuzawa Jul 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Common/CommonStandard/CommonStandard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

<ItemGroup>
<PackageReference Include="Accord.Statistics" Version="3.8.0" />
<PackageReference Include="MessagePack" Version="1.7.3.7" />
<PackageReference Include="MessagePackAnalyzer" Version="1.6.0" />
<PackageReference Include="MessagePack" Version="3.1.7" />
<PackageReference Include="MessagePackAnalyzer" Version="3.1.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using System;

namespace CompMs.Common.Interfaces {
[Union(0, typeof(BaseChromatogramPeakFeature))]
//[Union(0, typeof(BaseChromatogramPeakFeature))]
[MessagePackFormatter(typeof(ChromatogramPeakFeatureInterfaceFormatter))]
public interface IChromatogramPeakFeature {

// basic property
Expand Down Expand Up @@ -40,37 +41,36 @@ public static bool IsOverlaped(this IChromatogramPeakFeature self, IChromatogram
}
}

public class ChromatogramPeakFeatureInterfaceFormatter : IMessagePackFormatter<IChromatogramPeakFeature>
public class ChromatogramPeakFeatureInterfaceFormatter : IMessagePackFormatter<IChromatogramPeakFeature?>
{
public IChromatogramPeakFeature Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize) {
return formatterResolver.GetFormatterWithVerify<BaseChromatogramPeakFeature>().Deserialize(bytes, offset, formatterResolver, out readSize);
public IChromatogramPeakFeature Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) {
return options.Resolver.GetFormatterWithVerify<BaseChromatogramPeakFeature>().Deserialize(ref reader, options);
}

public int Serialize(ref byte[] bytes, int offset, IChromatogramPeakFeature value, IFormatterResolver formatterResolver) {
public void Serialize(ref MessagePackWriter writer, IChromatogramPeakFeature value, MessagePackSerializerOptions options) {
if (value == null) {
return MessagePackBinary.WriteNil(ref bytes, offset);
writer.WriteNil();
return;
}
if (value is BaseChromatogramPeakFeature bp) {
return formatterResolver.GetFormatterWithVerify<BaseChromatogramPeakFeature>().Serialize(ref bytes, offset, bp, formatterResolver);
}
else {
var currentOffset = offset;
currentOffset += MessagePackBinary.WriteArrayHeader(ref bytes, currentOffset, 12);
currentOffset += MessagePackBinary.WriteInt32(ref bytes, currentOffset, value.ChromScanIdLeft);
currentOffset += MessagePackBinary.WriteInt32(ref bytes, currentOffset, value.ChromScanIdTop);
currentOffset += MessagePackBinary.WriteInt32(ref bytes, currentOffset, value.ChromScanIdRight);
var chromFormatter = formatterResolver.GetFormatterWithVerify<ChromXs>();
currentOffset += chromFormatter.Serialize(ref bytes, currentOffset, value.ChromXsLeft, formatterResolver);
currentOffset += chromFormatter.Serialize(ref bytes, currentOffset, value.ChromXsTop, formatterResolver);
currentOffset += chromFormatter.Serialize(ref bytes, currentOffset, value.ChromXsRight, formatterResolver);
currentOffset += MessagePackBinary.WriteDouble(ref bytes, currentOffset, value.PeakHeightLeft);
currentOffset += MessagePackBinary.WriteDouble(ref bytes, currentOffset, value.PeakHeightTop);
currentOffset += MessagePackBinary.WriteDouble(ref bytes, currentOffset, value.PeakHeightRight);
currentOffset += MessagePackBinary.WriteDouble(ref bytes, currentOffset, value.PeakAreaAboveZero);
currentOffset += MessagePackBinary.WriteDouble(ref bytes, currentOffset, value.PeakAreaAboveBaseline);
currentOffset += MessagePackBinary.WriteDouble(ref bytes, currentOffset, value.Mass);
return currentOffset - offset;
options.Resolver.GetFormatterWithVerify<BaseChromatogramPeakFeature>().Serialize(ref writer, bp, options);
return;
}

writer.WriteArrayHeader(12);
writer.Write(value.ChromScanIdLeft);
writer.Write(value.ChromScanIdTop);
writer.Write(value.ChromScanIdRight);
var chromFormatter = options.Resolver.GetFormatterWithVerify<ChromXs>();
chromFormatter.Serialize(ref writer, value.ChromXsLeft, options);
chromFormatter.Serialize(ref writer, value.ChromXsTop, options);
chromFormatter.Serialize(ref writer, value.ChromXsRight, options);
writer.Write(value.PeakHeightLeft);
writer.Write(value.PeakHeightTop);
writer.Write(value.PeakHeightRight);
writer.Write(value.PeakAreaAboveZero);
writer.Write(value.PeakAreaAboveBaseline);
writer.Write(value.Mass);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,36 @@ public static IMoleculeProperty AsPutative(this IMoleculeProperty molecule) {

public static readonly IMessagePackFormatter<IMoleculeProperty> Formatter = new MoleculePropertyFormatter();

class MoleculePropertyFormatter : IMessagePackFormatter<IMoleculeProperty>
internal class MoleculePropertyFormatter : IMessagePackFormatter<IMoleculeProperty?>
{
public IMoleculeProperty Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize) {
var currentOffset = offset;
var contentSize = MessagePackBinary.ReadArrayHeader(bytes, currentOffset, out var readTmp);
currentOffset += readTmp;
var name = MessagePackBinary.ReadString(bytes, currentOffset, out readTmp);
currentOffset += readTmp;
var formula = formatterResolver.GetFormatterWithVerify<Formula>().Deserialize(bytes, currentOffset, formatterResolver, out readTmp);
currentOffset += readTmp;
var ontology = MessagePackBinary.ReadString(bytes, currentOffset, out readTmp);
currentOffset += readTmp;
var smiles = MessagePackBinary.ReadString(bytes, currentOffset, out readTmp);
currentOffset += readTmp;
var inchikey = MessagePackBinary.ReadString(bytes, currentOffset, out readTmp);
currentOffset += readTmp;
readSize = currentOffset - offset;
public IMoleculeProperty? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) {
if (reader.TryReadNil()) {
return null;
}
var count = reader.ReadArrayHeader();
if (count != 5) {
throw new MessagePackSerializationException($"Unexpected array length for {nameof(IMoleculeProperty)}: {count}.");
}
var name = reader.ReadString();
var formula = options.Resolver.GetFormatterWithVerify<Formula>().Deserialize(ref reader, options);
var ontology = reader.ReadString();
var smiles = reader.ReadString();
var inchikey = reader.ReadString();
return new MoleculeProperty(name, formula, ontology, smiles, inchikey);
}

public int Serialize(ref byte[] bytes, int offset, IMoleculeProperty value, IFormatterResolver formatterResolver) {
var currentOffset = offset;
currentOffset += MessagePackBinary.WriteArrayHeader(ref bytes, currentOffset, 5);
currentOffset += MessagePackBinary.WriteString(ref bytes, currentOffset, value?.Name);
currentOffset += formatterResolver.GetFormatterWithVerify<Formula>().Serialize(ref bytes, currentOffset, value?.Formula, formatterResolver);
currentOffset += MessagePackBinary.WriteString(ref bytes, currentOffset, value?.Ontology);
currentOffset += MessagePackBinary.WriteString(ref bytes, currentOffset, value?.SMILES);
currentOffset += MessagePackBinary.WriteString(ref bytes, currentOffset, value?.InChIKey);
return currentOffset - offset;
public void Serialize(ref MessagePackWriter writer, IMoleculeProperty value, MessagePackSerializerOptions options) {
if (value is null)
{
writer.WriteNil();
return;
}
writer.WriteArrayHeader(5);
writer.Write(value?.Name);
options.Resolver.GetFormatterWithVerify<Formula>().Serialize(ref writer, value?.Formula, options);
writer.Write(value?.Ontology);
writer.Write(value?.SMILES);
writer.Write(value?.InChIKey);
}
}
}
Expand Down
60 changes: 38 additions & 22 deletions src/Common/CommonStandard/DataObj/Property/AdductIon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using CompMs.Common.Parser;
using MessagePack;
using MessagePack.Formatters;
using MessagePack.Resolvers;
using System;
using System.Collections.Concurrent;

Expand Down Expand Up @@ -167,37 +166,54 @@ public AdductIon GetOrAdd(string adduct) {
}
}

class AdductIonFormatter : IMessagePackFormatter<AdductIon>
internal class AdductIonFormatter : IMessagePackFormatter<AdductIon?>
{
AdductIon IMessagePackFormatter<AdductIon>.Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize) {
readSize = MessagePackBinary.ReadNextBlock(bytes, offset);
if (MessagePackBinary.IsNil(bytes, offset)) {
public AdductIon Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) {
if (reader.TryReadNil()) {
return Default;
}
var count = MessagePackBinary.ReadArrayHeader(bytes, offset, out var tmp);
var count = reader.ReadArrayHeader();
if (count < 3) {
for (int i = 0; i < count; i++) {
reader.Skip();
}
return Default;
}
Comment thread
YukiMatsuzawa marked this conversation as resolved.
tmp += MessagePackBinary.ReadNext(bytes, offset + tmp);
tmp += MessagePackBinary.ReadNext(bytes, offset + tmp);
var name = MessagePackBinary.ReadString(bytes, offset + tmp, out var read);
tmp += read;
reader.Skip();
reader.Skip();
var name = reader.ReadString();
var adduct = GetAdductIon(name);
tmp += MessagePackBinary.ReadNext(bytes, offset + tmp);
tmp += MessagePackBinary.ReadNext(bytes, offset + tmp);
tmp += MessagePackBinary.ReadNext(bytes, offset + tmp);
adduct.M1Intensity = MessagePackBinary.ReadDouble(bytes, offset + tmp, out read);
tmp += read;
adduct.M2Intensity = MessagePackBinary.ReadDouble(bytes, offset + tmp, out read);
tmp += read;
tmp += MessagePackBinary.ReadNext(bytes, offset + tmp);
adduct.IsIncluded |= MessagePackBinary.ReadBoolean(bytes, offset + tmp, out _);
reader.Skip();
reader.Skip();
reader.Skip();
adduct.M1Intensity = reader.ReadDouble();
adduct.M2Intensity = reader.ReadDouble();
reader.Skip();
adduct.IsIncluded |= reader.ReadBoolean();
return adduct;
}

int IMessagePackFormatter<AdductIon>.Serialize(ref byte[] bytes, int offset, AdductIon value, IFormatterResolver formatterResolver) {
var formatter = DynamicObjectResolver.Instance.GetFormatterWithVerify<AdductIon>();
return formatter.Serialize(ref bytes, offset, value, formatterResolver);
public void Serialize(ref MessagePackWriter writer, AdductIon value, MessagePackSerializerOptions options) {
//var formatter = DynamicObjectResolver.Instance.GetFormatterWithVerify<AdductIon>();
//formatter.Serialize(ref writer, value, options);
if (value is null)
{
writer.WriteNil();
return;
}

writer.WriteArrayHeader(10);

writer.Write(value.AdductIonAccurateMass); // Key 0
writer.Write(value.AdductIonXmer); // Key 1
writer.Write(value.AdductIonName); // Key 2
writer.Write(value.ChargeNumber); // Key 3
writer.Write((int)value.IonMode); // Key 4
writer.Write(value.FormatCheck); // Key 5
writer.Write(value.M1Intensity); // Key 6
writer.Write(value.M2Intensity); // Key 7
writer.Write(value.IsRadical); // Key 8
writer.Write(value.IsIncluded); // Key 9
}
}
}
Expand Down
Loading
Loading