Skip to content

Commit d2003e5

Browse files
committed
Merge pull request #882 from asbjornu/feature/assembly-info-update-fixes
AssemblyInfo update fixes
2 parents 06a293c + 28a0b8a commit d2003e5

File tree

32 files changed

+459
-394
lines changed

32 files changed

+459
-394
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ script:
1212
- xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed
1313
- mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --where "cat != NoMono" --noresult
1414

15-
# To run a clean build with Mono, executing just one test, do:
16-
# xbuild ./src/GitVersion.sln /t:Clean /verbosity:quiet && xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:quiet && mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --noresult --where "test =~ /TheNameOfTheTest/"
15+
#
16+
# To run a clean build with Mono, executing just one test, do:
17+
# xbuild ./src/GitVersion.sln /t:Clean /verbosity:quiet && xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:quiet && mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --noresult --where "test =~ /TheNameOfTheTest/"
18+
#
19+
# To run a clean build with Mono, executing all tests, do:
20+
# xbuild ./src/GitVersion.sln /t:Clean /verbosity:quiet && xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:quiet && mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --noresult --where "cat != NoMono" --noresult
21+
#

src/GitVersionCore.Tests/GitVersionCore.Tests.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@
176176
</ItemGroup>
177177
<ItemGroup>
178178
<Content Include="FodyWeavers.xml" />
179-
<Content Include="JsonVersionBuilderTests.Json.approved.txt" />
180-
<Content Include="VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt" />
181-
<Content Include="VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreReleaseWithPadding.approved.txt" />
182-
<Content Include="VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt" />
183-
<Content Include="VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt" />
184-
<Content Include="VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt" />
185-
<Content Include="VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt" />
179+
<Content Include="Approved\JsonVersionBuilderTests.Json.approved.txt" />
180+
<Content Include="Approved\VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt" />
181+
<Content Include="Approved\VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreReleaseWithPadding.approved.txt" />
182+
<Content Include="Approved\VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt" />
183+
<Content Include="Approved\VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt" />
184+
<Content Include="Approved\VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt" />
185+
<Content Include="Approved\VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt" />
186186
</ItemGroup>
187187
<ItemGroup>
188188
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />

src/GitVersionCore.Tests/JsonVersionBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public void Json()
2525

2626
var variables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
2727
var json = JsonOutputFormatter.ToJson(variables);
28-
json.ShouldMatchApproved();
28+
json.ShouldMatchApproved(c => c.SubFolder("Approved"));
2929
}
3030
}

src/GitVersionCore.Tests/VariableProviderTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void ProvidesVariablesInContinuousDeliveryModeForPreRelease()
2929

3030
var vars = VariableProvider.GetVariablesFor(semVer, config, false);
3131

32-
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
32+
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved(c => c.SubFolder("Approved"));
3333
}
3434

3535
[Test]
@@ -54,7 +54,7 @@ public void ProvidesVariablesInContinuousDeliveryModeForPreReleaseWithPadding()
5454

5555
var vars = VariableProvider.GetVariablesFor(semVer, config, false);
5656

57-
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
57+
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved(c => c.SubFolder("Approved"));
5858
}
5959

6060
[Test]
@@ -78,7 +78,7 @@ public void ProvidesVariablesInContinuousDeploymentModeForPreRelease()
7878

7979
var vars = VariableProvider.GetVariablesFor(semVer, config, false);
8080

81-
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
81+
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved(c => c.SubFolder("Approved"));
8282
}
8383

8484
[Test]
@@ -101,7 +101,7 @@ public void ProvidesVariablesInContinuousDeliveryModeForStable()
101101

102102
var vars = VariableProvider.GetVariablesFor(semVer, config, false);
103103

104-
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
104+
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved(c => c.SubFolder("Approved"));
105105
}
106106

107107
[Test]
@@ -124,7 +124,7 @@ public void ProvidesVariablesInContinuousDeploymentModeForStable()
124124

125125
var vars = VariableProvider.GetVariablesFor(semVer, config, false);
126126

127-
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
127+
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved(c => c.SubFolder("Approved"));
128128
}
129129

130130
[Test]
@@ -150,6 +150,6 @@ public void ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommi
150150

151151
var vars = VariableProvider.GetVariablesFor(semVer, config, true);
152152

153-
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
153+
JsonOutputFormatter.ToJson(vars).ShouldMatchApproved(c => c.SubFolder("Approved"));
154154
}
155155
}

src/GitVersionCore/VersionAssemblyInfoResources/AssemblyVersionInfoTemplates.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55
using System.IO;
66
using System.Linq;
77
using GitVersionCore.Extensions;
8+
using JetBrains.Annotations;
89

910
public class AssemblyVersionInfoTemplates
1011
{
1112
static readonly IDictionary<string, FileInfo> assemblyInfoSourceList;
13+
static readonly IDictionary<string, string> assemblyInfoAddFormats;
1214

1315
static AssemblyVersionInfoTemplates()
1416
{
1517
assemblyInfoSourceList = GetEmbeddedVersionAssemblyFiles().ToDictionary(k => k.Extension, v => v);
18+
// TODO: It would be nice to do something a bit more clever here, like reusing the VersionAssemblyInfo.* templates somehow. @asbjornu
19+
assemblyInfoAddFormats = new Dictionary<string, string>
20+
{
21+
{".cs", "[assembly: {0}]"},
22+
{".vb", "<assembly: {0}>"},
23+
{".fs", "[<assembly: {0}>]"}
24+
};
1625
}
1726

1827
public static string GetAssemblyInfoTemplateFor(string assemblyInfoFile)
@@ -29,6 +38,26 @@ public static string GetAssemblyInfoTemplateFor(string assemblyInfoFile)
2938
return null;
3039
}
3140

41+
public static string GetAssemblyInfoAddFormatFor([NotNull] string fileExtension)
42+
{
43+
if (fileExtension == null)
44+
throw new ArgumentNullException("fileExtension");
45+
46+
string assemblyInfoAddFormat;
47+
if (!assemblyInfoAddFormats.TryGetValue(fileExtension, out assemblyInfoAddFormat))
48+
throw new NotSupportedException(string.Format("Unknown file extension '{0}'.", fileExtension));
49+
50+
return assemblyInfoAddFormat;
51+
}
52+
53+
public static bool IsSupported([NotNull] string fileExtension)
54+
{
55+
if (fileExtension == null)
56+
throw new ArgumentNullException("fileExtension");
57+
58+
return assemblyInfoAddFormats.Keys.Contains(fileExtension, StringComparer.OrdinalIgnoreCase);
59+
}
60+
3261
private static IEnumerable<FileInfo> GetEmbeddedVersionAssemblyFiles()
3362
{
3463
var enclosingNamespace = typeof(AssemblyVersionInfoTemplates).Namespace;
@@ -43,4 +72,4 @@ private static IEnumerable<FileInfo> GetEmbeddedVersionAssemblyFiles()
4372
}
4473
}
4574
}
46-
}
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[assembly: AssemblyVersion("2.3.1.0")]
2+
[assembly: AssemblyFileVersion("2.3.1.0")]
3+
[assembly: AssemblyInformationalVersion("2.3.1+3.Branch.foo.Sha.hash")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[<assembly: AssemblyVersion("2.3.1.0")>]
2+
[<assembly: AssemblyFileVersion("2.3.1.0")>]
3+
[<assembly: AssemblyInformationalVersion("2.3.1+3.Branch.foo.Sha.hash")>]
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This code was generated by GitVersion.
3+
// This code was generated by GitVersion.
44
//
55
// You can modify this code as we will not overwrite it when re-executing GitVersion
66
// </auto-generated>
77
//------------------------------------------------------------------------------
88

9-
using System.Reflection;
9+
open System.Reflection
1010

11-
[assembly: AssemblyFileVersion("1.0.0.0")]
12-
[assembly: AssemblyVersion("1.0.0.0")]
13-
[assembly: AssemblyInformationalVersion("1.0.0")]
11+
[<assembly: AssemblyFileVersion("1.0.0.0")>]
12+
[<assembly: AssemblyVersion("1.0.0.0")>]
13+
[<assembly: AssemblyInformationalVersion("1.0.0")>]
14+
()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by GitVersion.
4+
//
5+
// You can modify this code as we will not overwrite it when re-executing GitVersion
6+
// </auto-generated>
7+
//------------------------------------------------------------------------------
8+
9+
open System.Reflection
10+
11+
[<assembly: AssemblyFileVersion("1.0.0.0")>]
12+
[<assembly: AssemblyVersion("1.0.0.0")>]
13+
[<assembly: AssemblyInformationalVersion("1.0.0")>]
14+
()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by GitVersion.
4+
//
5+
// You can modify this code as we will not overwrite it when re-executing GitVersion
6+
// </auto-generated>
7+
//------------------------------------------------------------------------------
8+
9+
open System.Reflection
10+
11+
[<assembly: AssemblyFileVersion("1.0.0.0")>]
12+
[<assembly: AssemblyVersion("1.0.0.0")>]
13+
[<assembly: AssemblyInformationalVersion("1.0.0")>]
14+
()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Assembly: AssemblyVersion("2.3.1.0")>
2+
<Assembly: AssemblyFileVersion("2.3.1.0")>
3+
<assembly: AssemblyInformationalVersion("2.3.1+3.Branch.foo.Sha.hash")>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
''------------------------------------------------------------------------------
2+
'' <auto-generated>
3+
'' This code was generated by GitVersion.
4+
''
5+
'' You can modify this code as we will not overwrite it when re-executing GitVersion
6+
'' </auto-generated>
7+
''------------------------------------------------------------------------------
8+
9+
Imports System.Reflection
10+
11+
<assembly: AssemblyFileVersion("1.0.0.0")>
12+
<assembly: AssemblyVersion("1.0.0.0")>
13+
<assembly: AssemblyInformationalVersion("1.0.0")>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
''------------------------------------------------------------------------------
2+
'' <auto-generated>
3+
'' This code was generated by GitVersion.
4+
''
5+
'' You can modify this code as we will not overwrite it when re-executing GitVersion
6+
'' </auto-generated>
7+
''------------------------------------------------------------------------------
8+
9+
Imports System.Reflection
10+
11+
<assembly: AssemblyFileVersion("1.0.0.0")>
12+
<assembly: AssemblyVersion("1.0.0.0")>
13+
<assembly: AssemblyInformationalVersion("1.0.0")>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
''------------------------------------------------------------------------------
2+
'' <auto-generated>
3+
'' This code was generated by GitVersion.
4+
''
5+
'' You can modify this code as we will not overwrite it when re-executing GitVersion
6+
'' </auto-generated>
7+
''------------------------------------------------------------------------------
8+
9+
Imports System.Reflection
10+
11+
<assembly: AssemblyFileVersion("1.0.0.0")>
12+
<assembly: AssemblyVersion("1.0.0.0")>
13+
<assembly: AssemblyInformationalVersion("1.0.0")>

0 commit comments

Comments
 (0)