Repository: lucenenet Updated Branches: refs/heads/api-work f88cf9a52 -> 91a7ae1e5
Revert "Added LuceneInformationalVersionAttribute to work around issues with reading AssemblyInformationalVersionAttribute on .NET Core." This reverts commit f88cf9a528d09c3af476a4b6880991c1ab5889ae. Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/91a7ae1e Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/91a7ae1e Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/91a7ae1e Branch: refs/heads/api-work Commit: 91a7ae1e559fa8ee5ca13b2a48cb5e372563ab16 Parents: f88cf9a Author: Shad Storhaug <[email protected]> Authored: Tue Apr 11 21:13:24 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Tue Apr 11 21:13:24 2017 +0700 ---------------------------------------------------------------------- runbuild.ps1 | 4 +-- src/CommonAssemblyInfo.cs | 2 -- src/Lucene.Net/Lucene.Net.csproj | 1 - .../LuceneInformationalVersionAttribute.cs | 19 ------------- src/Lucene.Net/Util/Constants.cs | 29 +++++++++++++++++--- 5 files changed, 26 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/91a7ae1e/runbuild.ps1 ---------------------------------------------------------------------- diff --git a/runbuild.ps1 b/runbuild.ps1 index ed610ae..bb8a5e3 100644 --- a/runbuild.ps1 +++ b/runbuild.ps1 @@ -159,8 +159,7 @@ param( $AssemblyVersion = $Matches[0] $AssemblyVersion = "$AssemblyVersion.0.0" - $asmInfo = "using Lucene.Net.Support; -using System; + $asmInfo = "using System; using System.Reflection; [assembly: AssemblyProduct(""$product"")] @@ -170,7 +169,6 @@ using System.Reflection; [assembly: AssemblyVersion(""$AssemblyVersion"")] [assembly: AssemblyFileVersion(""$version"")] [assembly: AssemblyInformationalVersion(""$packageVersion"")] -[assembly: LuceneInformationalVersion(""$packageVersion"")] " $dir = [System.IO.Path]::GetDirectoryName($file) Ensure-Directory-Exists $dir http://git-wip-us.apache.org/repos/asf/lucenenet/blob/91a7ae1e/src/CommonAssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs index 8d38f2f..a66e328 100644 --- a/src/CommonAssemblyInfo.cs +++ b/src/CommonAssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using Lucene.Net.Support; // IMPORTANT: This file is overwritten by the build.ps1 script during release. // If you need to change this information, be sure to change the script as well. @@ -25,4 +24,3 @@ using Lucene.Net.Support; [assembly: AssemblyVersion("4.0.0")] [assembly: AssemblyFileVersion("4.8.0")] [assembly: AssemblyInformationalVersion("4.8.0")] -[assembly: LuceneInformationalVersion("4.8.0")] http://git-wip-us.apache.org/repos/asf/lucenenet/blob/91a7ae1e/src/Lucene.Net/Lucene.Net.csproj ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj index affaf2d..d28a1a8 100644 --- a/src/Lucene.Net/Lucene.Net.csproj +++ b/src/Lucene.Net/Lucene.Net.csproj @@ -659,7 +659,6 @@ <Compile Include="Support\LinkedHashMap.cs" /> <Compile Include="Support\ListExtensions.cs" /> <Compile Include="Support\LongBuffer.cs" /> - <Compile Include="Support\LuceneInformationalVersionAttribute.cs" /> <Compile Include="Support\LurchTable.cs" /> <Compile Include="Support\MathExtension.cs" /> <Compile Include="Support\MemoryMappedFileByteBuffer.cs" /> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/91a7ae1e/src/Lucene.Net/Support/LuceneInformationalVersionAttribute.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Support/LuceneInformationalVersionAttribute.cs b/src/Lucene.Net/Support/LuceneInformationalVersionAttribute.cs deleted file mode 100644 index 5429544..0000000 --- a/src/Lucene.Net/Support/LuceneInformationalVersionAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace Lucene.Net.Support -{ - /// <summary> - /// Attribute for assigning and reading InformationalVersion, since <see cref="System.Reflection.AssemblyInformationalVersionAttribute"/> - /// is optimized away during compilation and cannot be read from .NET Core. - /// </summary> - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] - public class LuceneInformationalVersionAttribute : Attribute - { - public LuceneInformationalVersionAttribute(string version) - { - this.Version = version; - } - - public string Version { get; private set; } - } -} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/91a7ae1e/src/Lucene.Net/Util/Constants.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Util/Constants.cs b/src/Lucene.Net/Util/Constants.cs index 1147483..4be1dcf 100644 --- a/src/Lucene.Net/Util/Constants.cs +++ b/src/Lucene.Net/Util/Constants.cs @@ -1,4 +1,3 @@ -using Lucene.Net.Support; using System; using System.Linq; using System.Reflection; @@ -114,9 +113,31 @@ namespace Lucene.Net.Util try { - // LUCENENET NOTE: Added custom LuceneInformationalVersionAttribute to work around - // issues with reading the AssemblyInformationalVersion in .NET core. - LUCENE_VERSION = typeof(Constants).GetTypeInfo().Assembly.GetCustomAttribute<LuceneInformationalVersionAttribute>().Version; + // 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. {
