Skip to content

Commit 0f833ed

Browse files
arturcicBi0T1N
authored andcommitted
FileHelper => AssemblyInfoFileHelper
1 parent 0c142fe commit 0f833ed

File tree

7 files changed

+48
-49
lines changed

7 files changed

+48
-49
lines changed

src/GitVersion.MsBuild.Tests/FileHelperTests.cs renamed to src/GitVersion.MsBuild.Tests/AssemblyInfoFileHelperTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace GitVersion.MsBuild.Tests;
22

33
[TestFixture]
4-
public class FileHelperTests
4+
public class AssemblyInfoFileHelperTests
55
{
66
[Test]
77
[TestCase("C#", "cs")]
@@ -12,11 +12,11 @@ public void GetFileExtensionShouldReturnCorrectExtension(string language, string
1212
{
1313
if (expectedExtension != null)
1414
{
15-
Assert.That(FileHelper.GetFileExtension(language), Is.EqualTo(expectedExtension));
15+
Assert.That(AssemblyInfoFileHelper.GetFileExtension(language), Is.EqualTo(expectedExtension));
1616
}
1717
else
1818
{
19-
Assert.That((TestDelegate)(() => FileHelper.GetFileExtension(language)), Throws.ArgumentException.With.Message.EqualTo($"Unknown language detected: '{language}'"));
19+
Assert.That((TestDelegate)(() => AssemblyInfoFileHelper.GetFileExtension(language)), Throws.ArgumentException.With.Message.EqualTo($"Unknown language detected: '{language}'"));
2020
}
2121
}
2222

@@ -35,10 +35,10 @@ public void GetFileWriteInfoShouldCreateConstantNamedFileWhenIntermediateOutputP
3535
[Test]
3636
public void GetFileWriteInfoShouldCreateRandomNamedFileWhenNoIntermediateOutputPath()
3737
{
38-
var fileInfo = FileHelper.GetFileWriteInfo(null, "C#", "MyProject.csproj", "GeneratedVersionInformation");
38+
var fileInfo = AssemblyInfoFileHelper.GetFileWriteInfo(null, "C#", "MyProject.csproj", "GeneratedVersionInformation");
3939
Assert.Multiple(() =>
4040
{
41-
Assert.That(fileInfo.WorkingDirectory, Is.EqualTo(FileHelper.TempPath));
41+
Assert.That(fileInfo.WorkingDirectory, Is.EqualTo(AssemblyInfoFileHelper.TempPath));
4242
Assert.That(fileInfo.FileName, Does.StartWith("GeneratedVersionInformation_MyProject_").And.EndsWith(".g.cs"));
4343
Assert.That(fileInfo.FileExtension, Is.EqualTo("cs"));
4444
});

src/GitVersion.MsBuild.Tests/Helpers/MsBuildExeFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class MsBuildExeFixture
2222

2323
public MsBuildExeFixture(RepositoryFixtureBase fixture, string workingDirectory = "", string language = "C#")
2424
{
25-
var projectExtension = FileHelper.GetProjectExtension(language);
25+
var projectExtension = AssemblyInfoFileHelper.GetProjectExtension(language);
2626
this.fixture = fixture;
2727
this.ProjectPath = PathHelper.Combine(workingDirectory, $"app.{projectExtension}");
2828

src/GitVersion.MsBuild.Tests/InvalidFileCheckerTests.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void VerifyIgnoreNonAssemblyInfoFile()
3939
""");
4040
}
4141

42-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "SomeOtherFile.cs" }], this.projectFile);
42+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "SomeOtherFile.cs" }], this.projectFile);
4343
}
4444

4545
[Test]
@@ -57,7 +57,7 @@ public void VerifyAttributeFoundCSharp([Values("AssemblyVersion", "AssemblyFileV
5757
""", attribute);
5858
}
5959

60-
var ex = Assert.Throws<WarningException>(() => FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile), attribute);
60+
var ex = Assert.Throws<WarningException>(() => AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile), attribute);
6161
ex.ShouldNotBeNull();
6262
Assert.That(ex.Message, Is.EqualTo("File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.cs"));
6363
}
@@ -78,7 +78,7 @@ public void VerifyUnformattedAttributeFoundCSharp([Values("AssemblyVersion", "As
7878
""", attribute);
7979
}
8080

81-
var ex = Assert.Throws<WarningException>(() => FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile), attribute);
81+
var ex = Assert.Throws<WarningException>(() => AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile), attribute);
8282
ex.ShouldNotBeNull();
8383
Assert.That(ex.Message, Is.EqualTo("File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.cs"));
8484
}
@@ -98,7 +98,7 @@ public void VerifyCommentWorksCSharp([Values("AssemblyVersion", "AssemblyFileVer
9898
""", attribute);
9999
}
100100

101-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile);
101+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile);
102102
}
103103

104104
[Test]
@@ -115,7 +115,7 @@ public void VerifyCommentWithNoNewLineAtEndWorksCSharp([Values("AssemblyVersion"
115115
""", attribute);
116116
}
117117

118-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile);
118+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile);
119119
}
120120

121121
[Test]
@@ -136,7 +136,7 @@ public class Temp
136136
""", attribute);
137137
}
138138

139-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile);
139+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile);
140140
}
141141

142142
[Test]
@@ -156,7 +156,7 @@ public class {0}
156156
""", attribute);
157157
}
158158

159-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile);
159+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.cs" }], this.projectFile);
160160
}
161161

162162
[Test]
@@ -174,7 +174,7 @@ Imports System.Reflection
174174
""", attribute);
175175
}
176176

177-
var ex = Assert.Throws<WarningException>(() => FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile), attribute);
177+
var ex = Assert.Throws<WarningException>(() => AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile), attribute);
178178
ex.ShouldNotBeNull();
179179
Assert.That(ex.Message, Is.EqualTo("File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.vb"));
180180
}
@@ -195,7 +195,7 @@ Imports System.Reflection
195195
""", attribute);
196196
}
197197

198-
var ex = Assert.Throws<WarningException>(() => FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile), attribute);
198+
var ex = Assert.Throws<WarningException>(() => AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile), attribute);
199199
ex.ShouldNotBeNull();
200200
Assert.That(ex.Message, Is.EqualTo("File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.vb"));
201201
}
@@ -215,7 +215,7 @@ Imports System.Reflection
215215
""", attribute);
216216
}
217217

218-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile);
218+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile);
219219
}
220220

221221
[Test]
@@ -232,7 +232,7 @@ Imports System.Reflection
232232
""", attribute);
233233
}
234234

235-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile);
235+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile);
236236
}
237237

238238
[Test]
@@ -252,7 +252,7 @@ End Class
252252
""", attribute);
253253
}
254254

255-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile);
255+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile);
256256
}
257257

258258
[Test]
@@ -271,7 +271,7 @@ End Class
271271
""", attribute);
272272
}
273273

274-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile);
274+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.vb" }], this.projectFile);
275275
}
276276

277277
[Test]
@@ -289,7 +289,7 @@ open System.Reflection
289289
""", attribute);
290290
}
291291

292-
var ex = Assert.Throws<WarningException>(() => FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile), attribute);
292+
var ex = Assert.Throws<WarningException>(() => AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile), attribute);
293293
ex.ShouldNotBeNull();
294294
Assert.That(ex.Message, Is.EqualTo("File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.fs"));
295295
}
@@ -310,7 +310,7 @@ open System.Reflection
310310
""", attribute);
311311
}
312312

313-
var ex = Assert.Throws<WarningException>(() => FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile), attribute);
313+
var ex = Assert.Throws<WarningException>(() => AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile), attribute);
314314
ex.ShouldNotBeNull();
315315
Assert.That(ex.Message, Is.EqualTo("File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.fs"));
316316
}
@@ -330,7 +330,7 @@ open System.Reflection
330330
""", attribute);
331331
}
332332

333-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile);
333+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile);
334334
}
335335

336336
[Test]
@@ -347,7 +347,7 @@ open System.Reflection
347347
""", attribute);
348348
}
349349

350-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile);
350+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile);
351351
}
352352

353353
[Test]
@@ -366,7 +366,7 @@ type Temp() =
366366
""", attribute);
367367
}
368368

369-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile);
369+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile);
370370
}
371371

372372
[Test]
@@ -384,6 +384,6 @@ open System.Reflection
384384
""", attribute);
385385
}
386386

387-
FileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile);
387+
AssemblyInfoFileHelper.CheckForInvalidFiles([new MockTaskItem { ItemSpec = "AssemblyInfo.fs" }], this.projectFile);
388388
}
389389
}

src/GitVersion.MsBuild.Tests/Tasks/GenerateGitVersionInformationTest.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class GenerateGitVersionInformationTest : TestTaskBase
2121
[TestCaseSource(nameof(Languages))]
2222
public void GenerateGitVersionInformationTaskShouldCreateFile(string language)
2323
{
24-
var extension = FileHelper.GetFileExtension(language);
24+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
2525
var task = new GenerateGitVersionInformation { Language = language };
2626

2727
using var result = ExecuteMsBuildTask(task);
@@ -42,7 +42,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFile(string language)
4242
[TestCaseSource(nameof(Languages))]
4343
public void GenerateGitVersionInformationTaskShouldCreateFileInBuildServer(string language)
4444
{
45-
var extension = FileHelper.GetFileExtension(language);
45+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
4646
var task = new GenerateGitVersionInformation { Language = language };
4747

4848
using var result = ExecuteMsBuildTaskInAzurePipeline(task);
@@ -65,7 +65,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuild(
6565
{
6666
const string taskName = nameof(GenerateGitVersionInformation);
6767
const string outputProperty = nameof(GenerateGitVersionInformation.GitVersionInformationFilePath);
68-
var extension = FileHelper.GetFileExtension(language);
68+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
6969

7070
using var result = ExecuteMsBuildExe(project =>
7171
AddGenerateGitVersionInformationTask(project, taskName, taskName, outputProperty, language), language);
@@ -92,7 +92,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuildI
9292
{
9393
const string taskName = nameof(GenerateGitVersionInformation);
9494
const string outputProperty = nameof(GenerateGitVersionInformation.GitVersionInformationFilePath);
95-
var extension = FileHelper.GetFileExtension(language);
95+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
9696

9797
using var result = ExecuteMsBuildExeInAzurePipeline(project =>
9898
AddGenerateGitVersionInformationTask(project, taskName, taskName, outputProperty, language), language);
@@ -117,7 +117,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuildI
117117
[TestCaseSource(nameof(Languages))]
118118
public void GenerateGitVersionInformationTaskShouldCreateFileWhenIntermediateOutputPathDoesNotExist(string language)
119119
{
120-
var extension = FileHelper.GetFileExtension(language);
120+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
121121
var task = new GenerateGitVersionInformation { Language = language, IntermediateOutputPath = Guid.NewGuid().ToString("N") };
122122

123123
using var result = ExecuteMsBuildTask(task);
@@ -139,7 +139,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenIntermediateOut
139139
[TestCaseSource(nameof(Languages))]
140140
public void GenerateGitVersionInformationTaskShouldCreateFileInBuildServerWhenIntermediateOutputPathDoesNotExist(string language)
141141
{
142-
var extension = FileHelper.GetFileExtension(language);
142+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
143143
var task = new GenerateGitVersionInformation { Language = language, IntermediateOutputPath = Guid.NewGuid().ToString("N") };
144144

145145
using var result = ExecuteMsBuildTaskInAzurePipeline(task);
@@ -165,7 +165,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuildA
165165
const string outputProperty = nameof(GenerateGitVersionInformation.GitVersionInformationFilePath);
166166
var randDir = Guid.NewGuid().ToString("N");
167167

168-
var extension = FileHelper.GetFileExtension(language);
168+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
169169
using var result = ExecuteMsBuildExe(project =>
170170
{
171171
var intermediateOutputPath = PathHelper.Combine("$(MSBuildProjectDirectory)", randDir);
@@ -196,7 +196,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuildA
196196
const string outputProperty = nameof(GenerateGitVersionInformation.GitVersionInformationFilePath);
197197
var randDir = Guid.NewGuid().ToString("N");
198198

199-
var extension = FileHelper.GetFileExtension(language);
199+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
200200
using var result = ExecuteMsBuildExeInAzurePipeline(project =>
201201
{
202202
var intermediateOutputPath = PathHelper.Combine("$(MSBuildProjectDirectory)", randDir);
@@ -227,7 +227,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuildA
227227
const string outputProperty = nameof(GenerateGitVersionInformation.GitVersionInformationFilePath);
228228
var randDir = Guid.NewGuid().ToString("N");
229229

230-
var extension = FileHelper.GetFileExtension(language);
230+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
231231
using var result = ExecuteMsBuildExe(project =>
232232
{
233233
var intermediateOutputPath = PathHelper.Combine("$(MSBuildProjectDirectory)", randDir);
@@ -260,7 +260,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuildA
260260
const string outputProperty = nameof(GenerateGitVersionInformation.GitVersionInformationFilePath);
261261
var randDir = Guid.NewGuid().ToString("N");
262262

263-
var extension = FileHelper.GetFileExtension(language);
263+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
264264
using var result = ExecuteMsBuildExeInAzurePipeline(project =>
265265
{
266266
var intermediateOutputPath = PathHelper.Combine("$(MSBuildProjectDirectory)", randDir);
@@ -288,7 +288,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuildA
288288
[TestCaseSource(nameof(Languages))]
289289
public void GenerateGitVersionInformationTaskShouldCreateFileWithUseProjectNamespaceSetAndRootNamespaceUnSet(string language)
290290
{
291-
var extension = FileHelper.GetFileExtension(language);
291+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
292292
var task = new GenerateGitVersionInformation
293293
{
294294
Language = language,
@@ -314,7 +314,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWithUseProjectNames
314314
[TestCaseSource(nameof(Languages))]
315315
public void GenerateGitVersionInformationTaskShouldCreateFileWithUseProjectNamespaceSetAndRootNamespaceIsSet(string language)
316316
{
317-
var extension = FileHelper.GetFileExtension(language);
317+
var extension = AssemblyInfoFileHelper.GetFileExtension(language);
318318
var task = new GenerateGitVersionInformation
319319
{
320320
Language = language,

0 commit comments

Comments
 (0)