lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [04/15] lucenenet git commit: Lucene.Net.Util.Constants: Fixed LUCENE_VERSION to use the FileVersion instead of the AssemblyVersion, since we want this version to be logged as the latest release instead of the latest major release.
Date Sat, 08 Apr 2017 21:37:54 GMT
Lucene.Net.Util.Constants: Fixed LUCENE_VERSION to use the FileVersion instead of the AssemblyVersion,
since we want this version to be logged as the latest release instead of the latest major
release.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/39a0bc7c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/39a0bc7c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/39a0bc7c

Branch: refs/heads/api-work
Commit: 39a0bc7c1d2e1d3c219c8834240f773283e672b8
Parents: 16cd6e3
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Apr 9 02:10:24 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Apr 9 02:10:24 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Util/Constants.cs | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/39a0bc7c/src/Lucene.Net/Util/Constants.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Util/Constants.cs b/src/Lucene.Net/Util/Constants.cs
index 284a647..4be1dcf 100644
--- a/src/Lucene.Net/Util/Constants.cs
+++ b/src/Lucene.Net/Util/Constants.cs
@@ -1,8 +1,10 @@
-using Lucene.Net.Support;
 using System;
+using System.Linq;
 using System.Reflection;
 #if NETSTANDARD
 using System.Runtime.InteropServices;
+#else
+using System.Diagnostics;
 #endif
 using System.Text.RegularExpressions;
 
@@ -111,7 +113,31 @@ namespace Lucene.Net.Util
 
             try
             {
-                LUCENE_VERSION = typeof(Constants).GetTypeInfo().Assembly.GetName().Version.ToString();
+                // LUCENENET NOTE: Use the AssemblyFileVersion, since our AssemblyVersion
should 
+                // remain at the major version (4.0.0.0). We only increment AssemblyVersion

+                // during a major release because strong-naming means 
+                // incrementing this version makes it binary incompatible.
+                string versionString;
+#if NETSTANDARD
+                versionString = typeof(Constants).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
+#else
+                versionString = FileVersionInfo.GetVersionInfo(typeof(Constants).GetTypeInfo().Assembly.Location).FileVersion;
+#endif
+                // LUCENENET NOTE: Convert to a 4-segment version number (in case it isn't)
+                switch (versionString.Count(x => x == '.'))
+                {
+                    case 2:
+                        versionString += ".0";
+                        break;
+                    case 1:
+                        versionString += ".0.0";
+                        break;
+                    case 0:
+                        versionString += ".0.0.0";
+                        break;
+                }
+
+                LUCENE_VERSION = versionString;
             }
             catch (System.Security.SecurityException) //Ignore in medium trust.
             {


Mime
View raw message