dslVersion - 如何增加但仍然支持旧版本?

发布于 2024-10-04 18:03:15 字数 420 浏览 2 评论 0原文

技术:Visual Studio 2010、Visual Studio 可视化和可视化建模 SDK

我们有一个商业 Visual Studio 2010 DSL,当我们发布新版本时,我们希望增加版本号。我打开 DslDefinition.dsl 并根据需要更新版本号,然后执行“转换所有模板”以使更改得到反映。 DslPackage“source.extension.vsixmanifest”得到很好的更新并显示新的版本号。

然而问题是,当有人使用更新版本 1.0.0.1 打开从版本 1.0.0.0 创建的模型时,他们无法打开该模型,原因似乎是 *.diagram 文件中的“dslVersion”是设置为 1.0.0.0 已过时,我可以通过手动更新 dslVersion 来修复,但似乎无法设置支持的版本范围。

有什么办法解决这个问题吗?

Tech: Visual Studio 2010, Visual Studio Visualization & Modeling SDK

We have a commercial Visual Studio 2010 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 dslVersion but there seems to be no way to set a supported version range.

Is there any fix for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜宝宝 2024-10-11 18:03:15

我通过覆盖“*SerializationHelper”类中的“CheckVersion”方法解决了这个问题。我的实现如下。

     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("2.5.0.0");
            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);
                }
            }
        }
    }

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("2.5.0.0");
            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);
                }
            }
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文