Previous versions of content

In v8 in content saving event I am doing the following:

 var versionId = sender.GetVersionIds(contentItem.Id, 2); //get top versions so current and previous

                if (versionId.Count() == 2)
                {
                    var versionNew = sender.GetVersion(versionId.First());
                    var versionOld = sender.GetVersion(versionId.Last());

                    var currentXml = versionNew.ToXml(_xmlSerializer).GetOuterXml();
                    var previousXml = versionOld.ToXml(_xmlSerializer).GetOuterXml();

                    var diff = new XmlDiff(currentXml, previousXml);

                    diff.CompareDocuments(new XmlDiffOptions()
                    {
                        TwoWayMatch = true
                    });
                
                

                    var diffList = diff.DiffNodeList;

                    if (diffList.Any())
                    {

So I have content and I add image to it then save or sometimes save and publish. I would expect the xml diff to pick up differences. It sometimes works and sometimes doesnt.

Debugging when i look at xml strings there is no difference. The 2 version ids are different but it seems as though the content is the same.

Save will create a version but does publish create a version as well? Looking at info tab when you publish there is entry for it so does that mean its creating a version?

Anyone any ideas?


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/99835-previous-versions-of-content