locked
dslVersion beyond version 1.0.0.0 RRS feed

  • Question

  • We have a commercial DSL, when we release a new version we want to increment the version number. I open the DslDefinition.dsl and update the version number as required and then do a Transform all templates so that the changes get reflected. The DslPackage 'source.extension.vsixmanifest' gets updated fine and shows the new version number.

    The issue is however is that when someone opens a model created from version 1.0.0.0 with the updated version 1.0.0.1 then they can't open the model, the reason seems to be that the 'dslVersion' in the *.diagram file is set to 1.0.0.0 which has been outdated, I can fix by manually updating the version but there seems to be no way to set a supported version range.

    Is there any fix for this?

     


    Lightning Tools::BCS Meta Man
    Monday, November 29, 2010 10:15 AM

Answers

  • I have solved this issue by overriding the 'CheckVersion' method which sits in the '*SerializationHelper' class. My implementation is below.

        
     partial class ProductSerializationHelper
        {
            protected override void CheckVersion(Microsoft.VisualStudio.Modeling.SerializationContext serializationContext, System.Xml.XmlReader reader)
            {
                #region Check Parameters
                global::System.Diagnostics.Debug.Assert(serializationContext != null);
                if (serializationContext == null)
                    throw new global::System.ArgumentNullException("serializationContext");
                global::System.Diagnostics.Debug.Assert(reader != null);
                if (reader == null)
                    throw new global::System.ArgumentNullException("reader");
                #endregion
    
                global::System.Version expectedVersion = new global::System.Version("1.0.0.1");
                string dslVersionStr = reader.GetAttribute("dslVersion");
                if (dslVersionStr != null)
                {
                    try
                    {
                        global::System.Version actualVersion = new global::System.Version(dslVersionStr);
    
    // #### THIS IS WHERE I CHANGED FROM '!=' to '>'
                        if (actualVersion > expectedVersion)
                        {
                            ProductSerializationBehaviorSerializationMessages.VersionMismatch(serializationContext, reader, expectedVersion, actualVersion);
                        }
                    }
                    catch (global::System.ArgumentException)
                    {
                        ProductSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
                    }
                    catch (global::System.FormatException)
                    {
                        ProductSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
                    }
                    catch (global::System.OverflowException)
                    {
                        ProductSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
                    }
                }
            }
        }
    


    Lightning Tools::BCS Meta Man
    Monday, November 29, 2010 11:06 AM