Skip to content

Commit f5af64d

Browse files
committed
Merge pull request #710 from sponge-b0b/assemblyinfo-namespace-conflict
Added global:: prefix in AssemblyInfoBuilder to avoid namespace conflicts.
2 parents e8681ce + d9ca134 commit f5af64d

14 files changed

+95
-12
lines changed

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchTag.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchTag_NugetAssemblyInfo.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch_NugetAssemblyInfo.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor_NugetAssemblyInfo.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor_NugetAssemblyInfoWithMultipleVariables.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major_NugetAssemblyInfo.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "2";

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using System.Reflection;
1818
namespace Fake
1919
{
2020

21-
[System.Runtime.CompilerServices.CompilerGenerated]
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
2222
static class GitVersionInformation
2323
{
2424
public static string Major = "1";
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
// GitVersion
5+
//
6+
// Changes to this file may cause incorrect behavior and will be lost if
7+
// the code is regenerated.
8+
// </auto-generated>
9+
//------------------------------------------------------------------------------
10+
11+
using System;
12+
using System.Reflection;
13+
14+
[assembly: AssemblyVersion("1.2.3.0")]
15+
[assembly: AssemblyFileVersion("1.2.3.0")]
16+
[assembly: AssemblyInformationalVersion("1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha")]
17+
18+
namespace Fake.System
19+
{
20+
21+
[global::System.Runtime.CompilerServices.CompilerGenerated]
22+
static class GitVersionInformation
23+
{
24+
public static string Major = "1";
25+
public static string Minor = "2";
26+
public static string Patch = "3";
27+
public static string PreReleaseTag = "unstable.4";
28+
public static string PreReleaseTagWithDash = "-unstable.4";
29+
public static string BuildMetaData = "5";
30+
public static string BuildMetaDataPadded = "0005";
31+
public static string FullBuildMetaData = "5.Branch.feature1.Sha.commitSha";
32+
public static string MajorMinorPatch = "1.2.3";
33+
public static string SemVer = "1.2.3-unstable.4";
34+
public static string LegacySemVer = "1.2.3-unstable4";
35+
public static string LegacySemVerPadded = "1.2.3-unstable0004";
36+
public static string AssemblySemVer = "1.2.3.0";
37+
public static string FullSemVer = "1.2.3-unstable.4+5";
38+
public static string InformationalVersion = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha";
39+
public static string BranchName = "feature1";
40+
public static string Sha = "commitSha";
41+
public static string NuGetVersionV2 = "1.2.3-unstable0004";
42+
public static string NuGetVersion = "1.2.3-unstable0004";
43+
public static string CommitsSinceVersionSource = "5";
44+
public static string CommitsSinceVersionSourcePadded = "0005";
45+
public static string CommitDate = "2014-03-06";
46+
}
47+
48+
}

src/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void VerifyCreatedCode()
4141
using (var stream = new MemoryStream())
4242
{
4343
var emitResult = compilation.Emit(stream);
44-
44+
4545
Assert.IsTrue(emitResult.Success, string.Join(Environment.NewLine, emitResult.Diagnostics.Select(x => x.Descriptor)));
4646

4747
stream.Seek(0, SeekOrigin.Begin);
@@ -50,6 +50,35 @@ public void VerifyCreatedCode()
5050
}
5151
}
5252

53+
[Test]
54+
public void VerifyCreatedCode_NoNamespaceConflict()
55+
{
56+
var semanticVersion = new SemanticVersion
57+
{
58+
Major = 1,
59+
Minor = 2,
60+
Patch = 3,
61+
PreReleaseTag = "unstable4",
62+
BuildMetaData = new SemanticVersionBuildMetaData(5,
63+
"feature1", "commitSha", DateTimeOffset.Parse("2014-03-06 23:59:59Z"))
64+
};
65+
var assemblyInfoBuilder = new AssemblyInfoBuilder();
66+
67+
var config = new TestEffectiveConfiguration();
68+
69+
var versionVariables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
70+
var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText(versionVariables, "Fake.System");
71+
Approvals.Verify(assemblyInfoText);
72+
73+
var compilation = CSharpCompilation.Create("Fake.System.dll")
74+
.WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
75+
.AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location))
76+
.AddSyntaxTrees(CSharpSyntaxTree.ParseText(assemblyInfoText));
77+
78+
var emitResult = compilation.Emit(new MemoryStream());
79+
Assert.IsTrue(emitResult.Success, string.Join(Environment.NewLine, emitResult.Diagnostics.Select(x => x.Descriptor)));
80+
}
81+
5382
[Test]
5483
[MethodImpl(MethodImplOptions.NoInlining)]
5584
public void VerifyAssemblyVersion_Major()

src/GitVersionTask.Tests/GitVersionTask.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@
143143
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt" />
144144
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch.approved.txt" />
145145
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchTag.approved.txt" />
146+
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchTag_NugetAssemblyInfo.approved.txt" />
147+
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch_NugetAssemblyInfo.approved.txt" />
148+
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor_NugetAssemblyInfo.approved.txt" />
149+
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor_NugetAssemblyInfoWithMultipleVariables.approved.txt" />
150+
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major_NugetAssemblyInfo.approved.txt" />
151+
<Content Include="AssemblyInfoBuilderTests.VerifyCreatedCode_NoNamespaceConflict.approved.txt" />
146152
<Content Include="AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt" />
147153
<Content Include="FodyWeavers.xml" />
148154
</ItemGroup>

src/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public string GetAssemblyInfoText(VersionVariables vars, string rootNamespace)
3030
namespace {4}
3131
{{
3232
33-
[System.Runtime.CompilerServices.CompilerGenerated]
33+
[global::System.Runtime.CompilerServices.CompilerGenerated]
3434
static class GitVersionInformation
3535
{{
3636
{3}

0 commit comments

Comments
 (0)