[Bug] Exception thrown by LINQPad while using Util.Dif
Dear developers,
I'm facing a bug that, I think, is coming from the internal implementation of the diffing system of LINQPad. I could craft an MWE to demonstrate the issue:
Recipe[] oldManifest = [ new Recipe("libnetplan1", "1.1-r0.0"), new Recipe("libnfnetlink0", "1.0.2-r0.0"), new Recipe("libnftnl11", "1.2.7-r0.0"), new Recipe("libnghttp2-14", "1.63.0-r0.0"), new Recipe("libnl-3-200", "1:3.10.0-r0.0"), new Recipe("libnl-3-doc", "1:3.10.0-r0.0"), new Recipe("libnl-genl-3-200", "1:3.10.0-r0.0"), new Recipe("libnsl3", "2.0.1-r0.0"), new Recipe("libnss-mdns", "0.15.1-r0.0"), new Recipe("libnss-myhostname2", "1:256.5-r0.0"), new Recipe("libnss-systemd2", "1:256.5-r0.0"), new Recipe("libogg-doc", "1.3.5-r0.0"), new Recipe("libogg0", "1.3.5-r0.0"), new Recipe("libpam", "1.6.1-r0.0"), ]; Recipe[] newManifest = [ new Recipe("libnetplan1", "1.1.2-r0.0"), new Recipe("libnfnetlink0", "1.0.2-r0.0"), new Recipe("libnftnl11", "1.2.8-r0.0"), new Recipe("libnghttp2-14", "1.65.0-r0.0"), new Recipe("libnl-3-200", "1:3.11.0-r0.0"), new Recipe("libnl-3-doc", "1:3.11.0-r0.0"), new Recipe("libnl-genl-3-200", "1:3.11.0-r0.0"), new Recipe("libnss-myhostname2", "1:257.4-r0.0"), new Recipe("libnss-systemd2", "1:257.4-r0.0"), new Recipe("libogg-doc", "1.3.5-r0.0"), new Recipe("libogg0", "1.3.5-r0.0"), new Recipe("libpam", "1.7.0-r0.0"), ]; // It seems the dump command for the diff is bugged on LINQPad 8.106.5 and throws Util.Dif(oldManifest, newManifest).Dump(); record Recipe(string Name, string Version);// {private string Version;};
In this particular MWE, I have the feeling the bug occurs when the logic tries to diff the property "string Version" (certainly an ill edge case not handled by the implementation under a specific condition that this MWE meets). To prove this, uncomment the part {private string Version;};
to turn the property into a private field so that it won't be part of the diff. This change prevents the Dif method from raising an exception.
Here is the exception I get:
Hoping this will help to get it fixed
Cheers
Comments
I realised I forgot to mention my environment, if this is relevant:
After installing LINQPad v8.8.9 with a host runtime v8.0.3 on Windows 11 (x86-64), I can also reproduce this issue (does not seem to be bound to the macOS version).
Ran the same code and could reproduce on the latest beta on Win10.
Seems to be an issue with diffing as collections. I think there's special logic to try to detect if objects are moved if I remember from previous discussions. Running a diff of the individual records is fine. Changing to regular classes instead of records makes no difference.
Thanks - I'll get a fix into the next build.