简体   繁体   English

为什么.NET中的System.Version定义为Major.Minor.Build.Revision?

[英]Why is System.Version in .NET defined as Major.Minor.Build.Revision?

Why is System.Version in .NET defined as Major.Minor.Build.Revision? 为什么.NET中的System.Version定义为Major.Minor.Build.Revision? Almost everyone (including me) seems to agree that revision belongs in third place, and "build" or whatever you'd like to call it belongs last. 几乎每个人(包括我)似乎都同意修改属于第三位,而“构建”或任何你想称之为属于最后的版本。

Does Microsoft even use the numbers in this haphazard way, eg 3.5.3858.2, or are the names themselves just backwards? 微软是否以这种随意的方式使用这些数字,例如3.5.3858.2,或者这些名称本身只是倒退? For example if you were to write your own Version class with the order Major.Minor.Build.Revision, would it be proper to swap the last two components when converting to a System.Version, or do you ignore it and just pretend the names are backwards? 例如,如果您使用订单Major.Minor.Build.Revision编写自己的Version类,在转换为System.Version时交换最后两个组件是否合适,或者忽略它并只是假装名称倒退了吗?

I think the confusion comes what most consider a "revision" and what Microsoft does : 我认为最混淆的是大多数人认为是“修订版”以及微软所做的事情

  • Build: A difference in build number represents a recompilation of the same source. 构建:构建号的差异表示对同一源的重新编译。 This would be appropriate because of processor, platform, or compiler changes. 由于处理器,平台或编译器的更改,这是合适的。

  • Revision: Assemblies with the same name, major, and minor version numbers but different revisions are intended to be fully interchangeable. 版本:具有相同名称,主要版本号和次要版本号但不同版本的程序集应完全可互换。 This would be appropriate to fix a security hole in a previously released assembly. 这适用于修复先前发布的组件中的安全漏洞。

The security fix angle, probably much more common for them, seems to be a decent reason to have it in last place, as the "most-minor" change. 对于他们而言,安全修复角度可能更为常见,似乎是将其置于最后位置的一个正当理由,作为“最轻微”的变化。

I realize I'm coming to the party a bit late, but I wanted to share my twopence on why the order of build and revision are "wrong." 我意识到我来晚会的时间有点晚了,但我想分享一下为什么构建和修改的顺序“错误”。 It's not so much that they're in the wrong order, but that they're not in any order. 并不是说他们的顺序错误 ,而是他们没有任何顺序。

The version of an assembly, when it comes down to it, is Major.Minor. 当它归结为它时,程序集的版本是Major.Minor。 From the aforementioned link , Microsoft says, "Subsequent versions of an assembly that differ only by build or revision numbers are considered to be Hotfix updates of the prior version ." 微软表示,从前面提到的链接 “只有构建版本或版本号不同的程序集的后续版本被认为是以前版本的修补程序更新。” [My emphasis] [我的重点]

The Build represents a recompilation of the same source. Build表示对同一源的重新编译。 The Revision represents a code change, but one that is fully interchangable with other revisions of the same [Major.Minor] version. 版本代表一个代码更改,但可以与同一[Major.Minor]版本的其他修订完全互换。 But neither takes precedence over the other. 但两者都不优先于另一个。

So, in summary, don't think of it as: 因此,总而言之,不要将其视为:

+ Major
|
+-+ Minor
  |
  +-+ Build
    |
    +-+ Revision

But instead: 但反而:

+ Major
|
+-+ Minor
  |
  +-+ Build
  |
  +-+ Revision

Does Microsoft even use the numbers in this haphazard way, eg 3.5.3858.2 微软是否以这种随意的方式使用这些数字,例如3.5.3858.2

If you let it default, eg by specifying [assembly: AssemblyVersion("1.1.*")] , then the third number increments each day, and the fourth number is the number of seconds since midnight, divided by two (to disambiguate if there's more than one builds in a single day). 如果你让它默认,例如通过指定[assembly: AssemblyVersion("1.1.*")] ,那么第三个数字每天递增,第四个数字是自午夜以来的秒数除以2(消除歧义,如果有的话)一天内不止一次构建)。

Almost everyone (including me) seems to agree that revision belongs in third place, and "build" or whatever you'd like to call it belongs last. 几乎每个人(包括我)似乎都同意修改属于第三位,而“构建”或任何你想称之为属于最后的版本。

Microsoft seem to be using "build" as a synonym of "day": perhaps that's related to the idea of "daily builds"; 微软似乎正在使用“构建”作为“日”的同义词:也许这与“每日构建”的概念有关; and a "revision" is then therefore another version of the (daily) build. 因此,“修订版”是(每日)构建的另一个版本。

Late answer, but I feel the other answers could be expanded on a bit. 迟到的答案,但我觉得其他答案可以稍微扩展一下。

The terms "build" and "revision" is just Microsoft terminology. 术语“构建”和“修订”只是Microsoft术语。 The System.Version class does not care in any way how you assign them. System.Version类并不关心如何分配它们。

As for switching the order of parts to match your own terminology i would say that you should basically ignore the words entirely and instead consider what the System.Version really defines: 至于切换部件的顺序以匹配您自己的术语,我会说你基本上应该完全忽略这些单词,而是考虑System.Version 真正定义的内容:

  • A string format that it can parse and generate: 它可以解析并生成的字符串格式:

     major.minor[.build[.revision]] 

    This means that if you are used to having you own version formatted as xyzw, then you should instantiate the Version class this way: 这意味着如果您习惯拥有格式为xyzw的版本,那么您应该以这种方式实例化Version类:

     new Version(x, y, z, w) 

    Any other parameter order will not match what Parse() and ToString() would do. 任何其他参数顺序都不会与Parse()和ToString()相匹配。 If you switch z and w, then ToString() would output xywz which would be confusing for everyone if you expect xyzw 如果你切换z和w,那么ToString()会输出xywz,如果你期望xyzw,这会让每个人都感到困惑

  • A version comparison and sort order , whereby versions are sorted first by major, then by minor, then build, then revision, as most of us would expect. 版本比较和排序顺序 ,其中版本首先按主要排序,然后按次要排序,然后按版本排序,然后按照我们大多数人的预期进行修订。 That is, 1.2.5 is later than 1.2.3.7. 也就是说,1.2.5晚于1.2.3.7。

    So if you style your version string as 1.2.6.4 and want that to be considered newer than 1.2.5.8, then do not switch the order of the parts in the Version constructor. 因此,如果您将版本字符串设置为1.2.6.4并希望将其视为比1.2.5.8更新,则不要在Version构造函数中切换部件的顺序。

In short - while the words major/minor/build/revision might give a clue as to which number should be increased considering the amount of changes, the terminology have very little impact on how the class is actually used. 简而言之 - 虽然主要/次要/构建/修订这两个词可能会给出一个关于在考虑到变化量时应该增加哪个数字的线索,但术语对于如何实际使用该类几乎没有影响。 Formatting and sorting is what matters. 格式化和排序是重要的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CS1607:为'文件版本'指定的版本在.NET中不是正常的'major.minor.build.revision'格式 - CS1607: The version specified for the 'file version' is not in the normal 'major.minor.build.revision' format in .NET 为什么警告CS1607“为'产品版本'指定的版本不是正常的'major.minor.build.revision'格式”生成的? - Why is warning CS1607 “The version specified for the 'product version' is not in the normal 'major.minor.build.revision' format” generated? CS1607:程序集生成 - 为“文件版本”指定的版本“1.4.0.85725”不是正常的“major.minor.build.revision”格式 - CS1607: Assembly generation — The version '1.4.0.85725' specified for the 'file version' is not in the normal 'major.minor.build.revision' format major.minor.build.revision版本风格vs year.month.day.whatever版本风格 - major.minor.build.revision versioning style vs year.month.day.whatever versioning style .NET程序集和版本元素顺序-使用major.minor.revision.build查找问题 - .NET Assemblies and Version Element Order - Looking for trouble using major.minor.revision.build 指定的版本字符串不符合要求的格式——major[.minor[.build[.revision]]] - The specified version string does not conform to the required format - major[.minor[.build[.revision]]] 为什么“ System.Version”是引用类型(类)而不是值类型(结构)? - Why is the 'System.Version' a reference type (class) and not a value type (struct)? 无法将类型'System.Version'隐式转换为'System.Net.HttpVersion' - Cannot implicitly convert type 'System.Version' to 'System.Net.HttpVersion' 使用System.Version进行通用版本控制 - Using System.Version for general purpose versioning sql server中System.Version的数据类型 - Datatype for System.Version in sql server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM