diff --git a/README.ja.md b/README.ja.md index b76e74e..c46076b 100644 --- a/README.ja.md +++ b/README.ja.md @@ -460,6 +460,8 @@ nuspecファイルを使ってパッケージを生成する場合は、デフ ## 履歴 +* 3.2.60: + * ビルド時に`ThisAssembly`シンボルが参照できない場合があるのを修正。 * 3.2.50: * 同じコミットに複数のバージョンタグが含まれる場合に、最も大きいバージョン番号を使用するように改良。 * 3.2.40: diff --git a/README.md b/README.md index 4f90e87..2ce3433 100644 --- a/README.md +++ b/README.md @@ -439,6 +439,8 @@ When you are using a nuspec file to generate a NuGet package, there are addition ## History +* 3.2.60: + * Fixed the `ThisAssembly` symbol could not be referenced at build time. * 3.2.50: * Improved to use the highest version number when multiple version tags are included in the same commit. * 3.2.40: diff --git a/RelaxVersioner.Core/Analyzer.cs b/RelaxVersioner.Core/Analyzer.cs index ae59407..214d33e 100644 --- a/RelaxVersioner.Core/Analyzer.cs +++ b/RelaxVersioner.Core/Analyzer.cs @@ -92,7 +92,8 @@ private static async Task LookupVersionLabelAsync( // Detected mostly larger version tag. var candidates = commit.Tags. - Collect(tag => Version.TryParse(tag.Name, out var v) ? v : null!). + Select(tag => Version.TryParse(tag.Name, out var v) ? v : null!). + Where(v => v != null). OrderByDescending(v => v). ToArray(); if (candidates.Length >= 1) @@ -102,7 +103,6 @@ private static async Task LookupVersionLabelAsync( break; } - // Traverse next commits. var parents = await commit.GetParentCommitsAsync(ct); if (parents.Length == 0) { diff --git a/RelaxVersioner.Core/RelaxVersioner.Core.csproj b/RelaxVersioner.Core/RelaxVersioner.Core.csproj index 6721130..0076318 100644 --- a/RelaxVersioner.Core/RelaxVersioner.Core.csproj +++ b/RelaxVersioner.Core/RelaxVersioner.Core.csproj @@ -16,7 +16,7 @@ + Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" /> diff --git a/RelaxVersioner.Core/Utilities.cs b/RelaxVersioner.Core/Utilities.cs index 57776fa..53d2a72 100644 --- a/RelaxVersioner.Core/Utilities.cs +++ b/RelaxVersioner.Core/Utilities.cs @@ -7,8 +7,6 @@ // //////////////////////////////////////////////////////////////////////////////////////// -#nullable enable - using System; using System.Collections.Generic; using System.Diagnostics; @@ -43,12 +41,12 @@ public static Dictionary GetWriters() return typeof(Utilities).Assembly. GetTypes(). Where(type => type.IsSealed && type.IsClass && typeof(WriterBase).IsAssignableFrom(type)). - Select(type => (WriterBase)Activator.CreateInstance(type)!). + Select(type => (WriterBase)Activator.CreateInstance(type)). ToDictionary(writer => writer.Language, StringComparer.InvariantCultureIgnoreCase); } - private static async Task TraversePathToRootAsync( - string candidatePath, Func> action) + private static async Task TraversePathToRootAsync( + string candidatePath, Func> action) where T : class { var path = Path.GetFullPath(candidatePath). @@ -78,7 +76,7 @@ public static string GetDirectoryNameWithoutTrailingSeparator(string path) => public static string GetDirectoryNameWithTrailingSeparator(string path) => GetDirectoryNameWithoutTrailingSeparator(path) + Path.DirectorySeparatorChar; - public static async Task OpenRepositoryAsync( + public static async Task OpenRepositoryAsync( Logger logger, string candidatePath) { var repository = await TraversePathToRootAsync(candidatePath, async path => @@ -105,30 +103,15 @@ public static string GetDirectoryNameWithTrailingSeparator(string path) => return repository; } - public static IEnumerable Collect( - this IEnumerable enumerable, - Func selector) - where U : class - { - foreach (var item in enumerable) - { - if (selector(item) is { } value) - { - yield return value; - } - } - } - public static TValue GetValue( this Dictionary dictionary, TKey key, TValue defaultValue) - where TKey : notnull { Debug.Assert(dictionary != null); Debug.Assert(key != null); - if (dictionary!.TryGetValue(key!, out var value) == false) + if (dictionary.TryGetValue(key, out TValue value) == false) { value = defaultValue; } @@ -170,7 +153,7 @@ public static IEnumerable LoadRuleSets(string candidatePath) var rulePath = Path.Combine(path, "RelaxVersioner.rules"); if (File.Exists(rulePath)) { - XElement? element = null; + XElement element = null; try { element = XElement.Load(rulePath); @@ -227,15 +210,15 @@ public static IEnumerable AggregateRules(XElement wrules) return (from rule in wrules.Elements("Rule") let name = rule.Attribute("name") let key = rule.Attribute("key") - where !string.IsNullOrWhiteSpace(name?.Value) && !string.IsNullOrWhiteSpace(key?.Value) - select new Rule(name.Value.Trim(), key.Value.Trim(), rule.Value.Trim())); + where !string.IsNullOrWhiteSpace(name?.Value) + select new Rule(name.Value.Trim(), key?.Value.Trim(), rule.Value.Trim())); } public static XElement GetDefaultRuleSet() { var type = typeof(Utilities); using (var stream = type.Assembly.GetManifestResourceStream( - type, "DefaultRuleSet.rules")!) + type, "DefaultRuleSet.rules")) { return XElement.Load(stream); } diff --git a/RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj b/RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj index 58c0307..491d2e8 100644 --- a/RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj +++ b/RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj @@ -29,7 +29,7 @@ + Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" /> diff --git a/RelaxVersioner/RelaxVersioner.csproj b/RelaxVersioner/RelaxVersioner.csproj index 15c2bbd..beb7681 100644 --- a/RelaxVersioner/RelaxVersioner.csproj +++ b/RelaxVersioner/RelaxVersioner.csproj @@ -37,7 +37,7 @@ + Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" />