From e1cc3ec65706cdcc8e9d0239099c5a1a3c95de55 Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Tue, 16 Jan 2024 22:04:03 +0000 Subject: [PATCH] Change F# AssemblyInfo generation to always include a do() after the version attributes --- .../AssemblyVersionInfo.cs | 12 +++++++++++- .../Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs b/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs index 6ff17c7b5..8745d89a6 100644 --- a/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs +++ b/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs @@ -397,6 +397,8 @@ private void GenerateAssemblyAttributes() this.generator.DeclareAttribute(typeof(AssemblyCopyrightAttribute), this.AssemblyCopyright); } } + + this.generator.EndAssemblyAttributes(); } private List> GetFieldsForThisAssembly() @@ -658,6 +660,10 @@ internal virtual void StartAssemblyAttributes() { } + internal virtual void EndAssemblyAttributes() + { + } + internal abstract void DeclareAttribute(Type type, string arg); internal abstract void StartThisAssemblyClass(); @@ -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($"[]"); @@ -738,7 +749,6 @@ internal override void EndThisAssemblyClass() internal override void StartThisAssemblyClass() { - this.CodeBuilder.AppendLine("do()"); this.CodeBuilder.AppendLine($"#if {CompilerDefinesAroundGeneratedCodeAttribute}"); this.CodeBuilder.AppendLine($"[]"); this.CodeBuilder.AppendLine("#endif"); diff --git a/test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs b/test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs index 43641569e..b42d39500 100644 --- a/test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs +++ b/test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs @@ -66,8 +66,8 @@ namespace AssemblyInfo [] [] [] -{(thisAssemblyClass.GetValueOrDefault(true) ? $@"do() -#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP +do() +{(thisAssemblyClass.GetValueOrDefault(true) ? $@"#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP [] #endif #if NET40_OR_GREATER || NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER