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

Add comment on top of auto-generated AssemblyInfo.fs files #1373

Merged
merged 2 commits into from
Sep 19, 2016
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
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