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

Allow custom fields to be added to the generated ThisAssembly class #565

Merged
merged 1 commit into from Mar 18, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 56 additions & 9 deletions src/NerdBank.GitVersioning.Tests/AssemblyInfoTest.cs
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Utilities;
using Nerdbank.GitVersioning.Tasks;
using Xunit;

Expand All @@ -18,6 +19,25 @@ public void FSharpGenerator(bool? thisAssemblyClass)
info.AssemblyCompany = "company";
info.AssemblyFileVersion = "1.3.1.0";
info.AssemblyVersion = "1.3.0.0";
info.AdditionalThisAssemblyFields =
new TaskItem[]
{
new TaskItem(
"CustomString1",
new Dictionary<string,string>() { { "String", "abc" } } ),
new TaskItem(
"CustomString2",
new Dictionary<string,string>() { { "String", "" } } ),
new TaskItem(
"CustomString3",
new Dictionary<string,string>() { { "String", "" }, { "EmitIfEmpty", "true" } } ),
new TaskItem(
"CustomBool",
new Dictionary<string,string>() { { "Boolean", "true" } } ),
new TaskItem(
"CustomTicks",
new Dictionary<string,string>() { { "Ticks", "637509805729817056" } } ),
};
info.CodeLanguage = "f#";

if (thisAssemblyClass.HasValue)
Expand Down Expand Up @@ -49,11 +69,15 @@ namespace AssemblyInfo
[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
#endif
type internal ThisAssembly() =
static member internal AssemblyVersion = ""1.3.0.0""
static member internal AssemblyFileVersion = ""1.3.1.0""
static member internal AssemblyCompany = ""company""
static member internal IsPublicRelease = false
static member internal AssemblyFileVersion = ""1.3.1.0""
static member internal AssemblyVersion = ""1.3.0.0""
static member internal CustomBool = true
static member internal CustomString1 = ""abc""
static member internal CustomString3 = """"
static member internal CustomTicks = new System.DateTime(637509805729817056L, System.DateTimeKind.Utc)
static member internal IsPrerelease = false
static member internal IsPublicRelease = false
static member internal RootNamespace = """"
do()
" : "")}";
Expand All @@ -72,6 +96,25 @@ public void CSharpGenerator(bool? thisAssemblyClass)
info.AssemblyFileVersion = "1.3.1.0";
info.AssemblyVersion = "1.3.0.0";
info.CodeLanguage = "c#";
info.AdditionalThisAssemblyFields =
new TaskItem[]
{
new TaskItem(
"CustomString1",
new Dictionary<string,string>() { { "String", "abc" } } ),
new TaskItem(
"CustomString2",
new Dictionary<string,string>() { { "String", "" } } ),
new TaskItem(
"CustomString3",
new Dictionary<string,string>() { { "String", "" }, { "EmitIfEmpty", "true" } } ),
new TaskItem(
"CustomBool",
new Dictionary<string,string>() { { "Boolean", "true" } } ),
new TaskItem(
"CustomTicks",
new Dictionary<string,string>() { { "Ticks", "637509805729817056" } } ),
};

if (thisAssemblyClass.HasValue)
{
Expand Down Expand Up @@ -100,11 +143,15 @@ public void CSharpGenerator(bool? thisAssemblyClass)
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
#endif
internal static partial class ThisAssembly {{
internal const string AssemblyVersion = ""1.3.0.0"";
internal const string AssemblyFileVersion = ""1.3.1.0"";
internal const string AssemblyCompany = ""company"";
internal const bool IsPublicRelease = false;
internal const string AssemblyFileVersion = ""1.3.1.0"";
internal const string AssemblyVersion = ""1.3.0.0"";
internal const bool CustomBool = true;
internal const string CustomString1 = ""abc"";
internal const string CustomString3 = """";
internal static readonly System.DateTime CustomTicks = new System.DateTime(637509805729817056L, System.DateTimeKind.Utc);
internal const bool IsPrerelease = false;
internal const bool IsPublicRelease = false;
internal const string RootNamespace = """";
}}
" : "")}";
Expand Down Expand Up @@ -154,11 +201,11 @@ public void VisualBasicGenerator(bool? thisAssemblyClass)
#Else
Partial Friend NotInheritable Class ThisAssembly
#End If
Friend Const AssemblyVersion As String = ""1.3.0.0""
Friend Const AssemblyFileVersion As String = ""1.3.1.0""
Friend Const AssemblyCompany As String = ""company""
Friend Const IsPublicRelease As Boolean = False
Friend Const AssemblyFileVersion As String = ""1.3.1.0""
Friend Const AssemblyVersion As String = ""1.3.0.0""
Friend Const IsPrerelease As Boolean = False
Friend Const IsPublicRelease As Boolean = False
Friend Const RootNamespace As String = """"
End Class
" : "")}";
Expand Down