Skip to content

Commit

Permalink
Merge pull request #1742 from inosik/fix-version-normalization
Browse files Browse the repository at this point in the history
Fix version normalization
  • Loading branch information
matthid authored Dec 15, 2017
2 parents 0341a2e + 0df85c0 commit 15ebe63
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open System.Text.RegularExpressions

module internal Helper =
open Fake.Core
let internal assemblyVersionRegex = String.getRegEx @"([0-9]+.)+[0-9]+"
let internal assemblyVersionRegex = String.getRegEx @"([0-9]+\.)+[0-9]+"

// matches [assembly: name(value)] and captures "name" and "value" as named captures. Variations for C#, F#, C++ and VB
let regexAttrNameValueCs = @"^\s*\[\s*assembly:\s*(?<name>\w+?)\s*\((?<value>.*)\)\s*\]\s*$"
Expand Down
2 changes: 1 addition & 1 deletion src/app/FakeLib/AssemblyInfoFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let (|Fsproj|Csproj|Vbproj|Shproj|) (projFileName:string) =
| f when f.EndsWith("shproj") -> Shproj
| _ -> failwith (sprintf "Project file %s not supported. Unknown project type." projFileName)

let internal assemblyVersionRegex = getRegEx @"([0-9]+.)+[0-9]+"
let internal assemblyVersionRegex = getRegEx @"([0-9]+\.)+[0-9]+"

// matches [assembly: name(value)] and captures "name" and "value" as named captures. Variations for C#, F#, C++ and VB
let private regexAttrNameValueCs = @"^\s*\[\s*assembly:\s*(?<name>\w+?)\s*\((?<value>.*)\)\s*\]\s*$"
Expand Down
23 changes: 23 additions & 0 deletions src/test/Test.FAKECore/AssemblyInfoSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@ public class when_accessing_internals
() => AssemblyInfoFile.getDependencies(new List<AssemblyInfoFile.Attribute>());
}

public class when_using_version_attributes
{
private static string Input = "1.0.0+0e5da7a";

It normalizes_the_string_for_Version = () =>
{
var attribute = AssemblyInfoFile.Attribute.Version(Input);
attribute.Value.ShouldEqual("\"1.0.0\"");
};

It normalizes_the_string_for_FileVersion = () =>
{
var attribute = AssemblyInfoFile.Attribute.FileVersion(Input);
attribute.Value.ShouldEqual("\"1.0.0\"");
};

It leaves_string_as_is_for_InformationalVersion = () =>
{
var attribute = AssemblyInfoFile.Attribute.InformationalVersion(Input);
attribute.Value.ShouldEqual("\"1.0.0+0e5da7a\"");
};
}

public class when_using_fsharp_task_with_default_config
{
It should_use_system_namespace_and_emit_a_version_module = () =>
Expand Down

0 comments on commit 15ebe63

Please sign in to comment.