[Mono-dev] ToolStripManager.RevertMerge
David Curylo
curylod at asme.org
Tue Feb 24 21:37:35 UTC 2015
It sounds like a bug if it’s specified to have different behavior. The Windows Forms code isn’t as actively maintained as other parts of mono. It sounds like you have a failing test and know what to fix…all the makings for a PR on Github. I’m not familiar with that particular WinForms code, but if you need assistance, I would be happy to help you craft a pull request to fix it.
On Feb 24, 2015, at 1:02 PM, Chad Dettmering <chad.dettmering at gmail.com> wrote:
> Hello Mono Devs! This is my first time posting to this mailing list so forgive me if I step on any toes.
>
> I was running an application called Chummer5 link: https://code.google.com/p/chummer5/ with Mono. The application kept crashing on the method Windows.Systems.Forms.ToolStripManager.RevertMerge.
>
> Being the curious software dev that I am, I decided to download the Mono and Chummer5 source code to figure out the problem. I might add the application runs fine on a Windows machine using the official .NET runtime.
>
> After poking around I came to this line of code in Chummer5
>
> // Merge the ToolStrips.
> ToolStripManager.RevertMerge("toolStrip");
> ToolStripManager.Merge(toolStrip, "toolStrip");
>
> which leads to an ArgumentNullException in Mono. The argument is not null of course but this method calls the base RevertMerge method which takes (ToolStrip, ToolStrip) as it's parameters, and uses the FindToolStrip method to find the ToolStrip based on the name. Now this implementation will always cause the RevertMerge parameter to be null if a Merge has not been called with the same name.
>
> Digging into the Mono source I came to this line of code inside the RevertMerge method implementation
>
> if (sourceToolStrip == null)
> throw new ArgumentNullException ("sourceToolStrip");
>
> So Mono is throwing an Exception explicitly in this case and will throw an Exception everytime RevertMerge is called before Merge using the same
>
> I thought this was odd so I went to the msdn documentation here: https://msdn.microsoft.com/en-us/library/b4e35dwy%28v=vs.110%29.aspx
>
> According to the documentation this method shouldn't throw any Exceptions, instead it should return false if the RevertMerge failed. Also looking at the example on the page it shows this as a valid way to use the method
>
> // Undo previous merge, if any.
> ToolStripManager.RevertMerge(cmsBase, cmsItemsToMerge);
>
> which implies that sending null is valid.
>
> Given all of this information is this a "bug" in Mono? Someone wrote that Exception explicitly so the code is working as intended but it breaks compatibility on the application I'm running.
>
> Any more info on this topic would be great! Nice to meet everyone! :)
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20150224/2ee8e720/attachment-0001.html>
More information about the Mono-devel-list
mailing list