Skip to content

Commit

Permalink
respect informationalAttribute pure version
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Apr 13, 2020
1 parent 4adcadb commit b3aa25e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>5.2.0</Version>
<Version>5.2.1</Version>
<LangVersion>latest</LangVersion>
<NoWarn>NU5118</NoWarn>
</PropertyGroup>
Expand Down
15 changes: 11 additions & 4 deletions Obsolete.Fody/VersionReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using Mono.Cecil;

static class VersionReader
public static class VersionReader
{
public static SemanticVersion Read(AssemblyDefinition assembly)
{
Expand All @@ -12,12 +12,19 @@ public static SemanticVersion Read(AssemblyDefinition assembly)
{
var value = (string)informationalAttribute.ConstructorArguments.Single().Value;
var indexOf = value.IndexOf(x => x != '.' && !char.IsNumber(x));
if (indexOf != -1)
if (indexOf == -1)
{
if (SemanticVersion.TryParse(value, out var informationalVersion))
{
return informationalVersion;
}
}
else
{
var substring = value.Substring(0, indexOf);
if (SemanticVersion.TryParse(substring, out var versionFromInformational))
if (SemanticVersion.TryParse(substring, out var informationalVersion))
{
return versionFromInformational;
return informationalVersion;
}
}
}
Expand Down

0 comments on commit b3aa25e

Please sign in to comment.