Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix version normalization #1742

Merged
merged 2 commits into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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