Skip to content

Commit

Permalink
Change F# AssemblyInfo generation to always include a do() after the …
Browse files Browse the repository at this point in the history
…version attributes
  • Loading branch information
Numpsy committed Jan 16, 2024
1 parent 9ca060e commit e1cc3ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ private void GenerateAssemblyAttributes()
this.generator.DeclareAttribute(typeof(AssemblyCopyrightAttribute), this.AssemblyCopyright);
}
}

this.generator.EndAssemblyAttributes();
}

private List<KeyValuePair<string, (object Value, bool EmitIfEmpty /* Only applies to string values */)>> GetFieldsForThisAssembly()
Expand Down Expand Up @@ -658,6 +660,10 @@ internal virtual void StartAssemblyAttributes()
{
}

internal virtual void EndAssemblyAttributes()
{
}

internal abstract void DeclareAttribute(Type type, string arg);

internal abstract void StartThisAssemblyClass();
Expand Down Expand Up @@ -726,6 +732,11 @@ internal override void StartAssemblyAttributes()
this.CodeBuilder.AppendLine($"namespace {this.Namespace}");
}

internal override void EndAssemblyAttributes()
{
this.CodeBuilder.AppendLine("do()");
}

internal override void DeclareAttribute(Type type, string arg)
{
this.CodeBuilder.AppendLine($"[<assembly: {type.FullName}(\"{arg}\")>]");
Expand All @@ -738,7 +749,6 @@ internal override void EndThisAssemblyClass()

internal override void StartThisAssemblyClass()
{
this.CodeBuilder.AppendLine("do()");
this.CodeBuilder.AppendLine($"#if {CompilerDefinesAroundGeneratedCodeAttribute}");
this.CodeBuilder.AppendLine($"[<System.CodeDom.Compiler.GeneratedCode(\"{GeneratorName}\",\"{GeneratorVersion}\")>]");
this.CodeBuilder.AppendLine("#endif");
Expand Down
4 changes: 2 additions & 2 deletions test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ namespace AssemblyInfo
[<assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>]
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
do()
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>]
#endif
#if NET40_OR_GREATER || NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
Expand Down

0 comments on commit e1cc3ec

Please sign in to comment.