Skip to content

Commit

Permalink
Merge pull request #1373 from eiriktsarpalis/assemblyinfo-comment
Browse files Browse the repository at this point in the history
Add comment on top of auto-generated AssemblyInfo.fs files
  • Loading branch information
forki authored Sep 19, 2016
2 parents fd6a04e + 4ceb790 commit 84627c0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions src/app/FakeLib/AssemblyInfoFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,23 @@ let CreateFSharpAssemblyInfoWithConfig outputFileName attributes (config : Assem
let generateClass, useNamespace = config.GenerateClass, config.UseNamespace

let sourceLines =
let required =
[ sprintf "namespace %s" useNamespace ]
@ (getDependencies attributes |> List.map (sprintf "open %s"))
@ [ "" ]
@ (attributes
|> Seq.toList
|> List.map (fun (attr : Attribute) -> sprintf "[<assembly: %sAttribute(%s)>]" attr.Name attr.Value))
@ [ "do ()"; "" ]

let optional =
[ "module internal AssemblyVersionInformation ="
sprintf " let [<Literal>] Version = %s" (getAssemblyVersionInfo attributes)
sprintf " let [<Literal>] InformationalVersion = %s" (getAssemblyInformationalVersion attributes)
]

if generateClass then required @ optional
else required
[
yield "// Auto-Generated by FAKE; do not edit"
yield sprintf "namespace %s" useNamespace
yield! getDependencies attributes |> Seq.map (sprintf "open %s")
yield ""
yield!
attributes
|> Seq.map (fun (attr : Attribute) -> sprintf "[<assembly: %sAttribute(%s)>]" attr.Name attr.Value)
yield "do ()"; yield ""

if generateClass then
yield "module internal AssemblyVersionInformation ="
yield sprintf " let [<Literal>] Version = %s" (getAssemblyVersionInfo attributes)
yield sprintf " let [<Literal>] InformationalVersion = %s" (getAssemblyInformationalVersion attributes)
]

sourceLines |> writeToFile outputFileName
traceEndTask "AssemblyInfo" outputFileName

Expand Down
4 changes: 2 additions & 2 deletions src/test/Test.FAKECore/AssemblyInfoSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class when_using_fsharp_task_with_default_config
AssemblyInfoFile.Attribute.Version("1.0.0.0")
};
AssemblyInfoFile.CreateFSharpAssemblyInfo(infoFile, attributes);
const string expected = "namespace System\r\nopen System.Reflection\r\n\r\n[<assembly: AssemblyProductAttribute(\"TestLib\")>]\r\n[<assembly: AssemblyVersionAttribute(\"1.0.0.0\")>]\r\ndo ()\r\n\r\nmodule internal AssemblyVersionInformation =\r\n let [<Literal>] Version = \"1.0.0.0\"\r\n let [<Literal>] InformationalVersion = \"1.0.0.0\"\r\n";
const string expected = "// Auto-Generated by FAKE; do not edit\r\nnamespace System\r\nopen System.Reflection\r\n\r\n[<assembly: AssemblyProductAttribute(\"TestLib\")>]\r\n[<assembly: AssemblyVersionAttribute(\"1.0.0.0\")>]\r\ndo ()\r\n\r\nmodule internal AssemblyVersionInformation =\r\n let [<Literal>] Version = \"1.0.0.0\"\r\n let [<Literal>] InformationalVersion = \"1.0.0.0\"\r\n";

File.ReadAllText(infoFile)
.ShouldEqual(expected.Replace("\r\n", Environment.NewLine));
Expand Down Expand Up @@ -87,7 +87,7 @@ public class when_using_fsharp_task_with_custom_config
AssemblyInfoFile.Attribute.Version("1.0.0.0")
};
AssemblyInfoFile.CreateFSharpAssemblyInfoWithConfig(infoFile, attributes, customConfig);
const string expected = "namespace Custom\r\nopen System.Reflection\r\n\r\n[<assembly: AssemblyProductAttribute(\"TestLib\")>]\r\n[<assembly: AssemblyVersionAttribute(\"1.0.0.0\")>]\r\ndo ()\r\n\r\n";
const string expected = "// Auto-Generated by FAKE; do not edit\r\nnamespace Custom\r\nopen System.Reflection\r\n\r\n[<assembly: AssemblyProductAttribute(\"TestLib\")>]\r\n[<assembly: AssemblyVersionAttribute(\"1.0.0.0\")>]\r\ndo ()\r\n\r\n";
File.ReadAllText(infoFile)
.ShouldEqual(expected.Replace("\r\n", Environment.NewLine));
};
Expand Down

0 comments on commit 84627c0

Please sign in to comment.