Skip to content
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
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