diff --git a/src/GitVersion.Core/Polyfills/StringSyntaxAttribute.cs b/src/GitVersion.Core/Polyfills/StringSyntaxAttribute.cs
deleted file mode 100644
index f3faee9ed6..0000000000
--- a/src/GitVersion.Core/Polyfills/StringSyntaxAttribute.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-#if !NET7_0_OR_GREATER
-
-// The namespace is important
-namespace System.Diagnostics.CodeAnalysis;
-
-/// Fake version of the StringSyntaxAttribute, which was introduced in .NET 7
-[SuppressMessage("ApiDesign", "RS0016:Add public types and members to the declared API")]
-[SuppressMessage("Style", "IDE0060:Remove unused parameter")]
-[AttributeUsage(AttributeTargets.All)]
-public sealed class StringSyntaxAttribute : Attribute
-{
- /// The syntax identifier for strings containing composite formats.
- public const string CompositeFormat = nameof(CompositeFormat);
-
- /// The syntax identifier for strings containing regular expressions.
- public const string Regex = nameof(Regex);
-
- /// The syntax identifier for strings containing date information.
- public const string DateTimeFormat = nameof(DateTimeFormat);
-
- ///
- /// Initializes a new instance of the class.
- ///
- public StringSyntaxAttribute(string syntax)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public StringSyntaxAttribute(string syntax, params object?[] arguments)
- {
- }
-}
-#endif
diff --git a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
index 9c6b2b9a43..1289bd4dc8 100644
--- a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
+++ b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
@@ -8,22 +8,6 @@
//
//------------------------------------------------------------------------------
-#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
-namespace System.Diagnostics.CodeAnalysis
-{
- [global::System.AttributeUsage(
- global::System.AttributeTargets.Assembly |
- global::System.AttributeTargets.Class |
- global::System.AttributeTargets.Struct |
- global::System.AttributeTargets.Constructor |
- global::System.AttributeTargets.Method |
- global::System.AttributeTargets.Property |
- global::System.AttributeTargets.Event,
- Inherited = false, AllowMultiple = false)]
- internal sealed class ExcludeFromCodeCoverageAttribute : global::System.Attribute { }
-}
-#endif
-
[global::System.Runtime.CompilerServices.CompilerGenerated]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
static class GitVersionInformation
diff --git a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt
index 14109e5d29..8cb6fbe737 100644
--- a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt
+++ b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt
@@ -8,22 +8,6 @@
//
//------------------------------------------------------------------------------
-#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
-namespace System.Diagnostics.CodeAnalysis
-{
- [global::System.AttributeUsage(
- global::System.AttributeTargets.Assembly |
- global::System.AttributeTargets.Class |
- global::System.AttributeTargets.Struct |
- global::System.AttributeTargets.Constructor |
- global::System.AttributeTargets.Method |
- global::System.AttributeTargets.Property |
- global::System.AttributeTargets.Event,
- Inherited = false, AllowMultiple = false)]
- internal sealed class ExcludeFromCodeCoverageAttribute : global::System.Attribute { }
-}
-#endif
-
namespace My.Custom.Namespace
{
[global::System.Runtime.CompilerServices.CompilerGenerated]
diff --git a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
index 52f2f04d87..f653c20b31 100644
--- a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
+++ b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
@@ -8,22 +8,6 @@
//
//------------------------------------------------------------------------------
-#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
-namespace System.Diagnostics.CodeAnalysis
-
-[]
-[]
-type ExcludeFromCodeCoverageAttribute() = inherit global.System.Attribute()
-#endif
-
namespace global
[]
diff --git a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt
new file mode 100644
index 0000000000..c73ca5fba9
--- /dev/null
+++ b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt
@@ -0,0 +1,41 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// GitVersion
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace My.Custom.Namespace
+
+[]
+[]
+[]
+type GitVersionInformation =
+ static member AssemblySemFileVer = "1.2.3.0"
+ static member AssemblySemVer = "1.2.3.0"
+ static member BranchName = "feature1"
+ static member BuildMetaData = "5"
+ static member CommitDate = "2014-03-06"
+ static member CommitsSinceVersionSource = "5"
+ static member EscapedBranchName = "feature1"
+ static member FullBuildMetaData = "5.Branch.feature1.Sha.commitSha"
+ static member FullSemVer = "1.2.3-unstable.4+5"
+ static member InformationalVersion = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha"
+ static member Major = "1"
+ static member MajorMinorPatch = "1.2.3"
+ static member Minor = "2"
+ static member Patch = "3"
+ static member PreReleaseLabel = "unstable"
+ static member PreReleaseLabelWithDash = "-unstable"
+ static member PreReleaseNumber = "4"
+ static member PreReleaseTag = "unstable.4"
+ static member PreReleaseTagWithDash = "-unstable.4"
+ static member SemVer = "1.2.3-unstable.4"
+ static member Sha = "commitSha"
+ static member ShortSha = "commitShortSha"
+ static member UncommittedChanges = "0"
+ static member VersionSourceSha = "versionSourceSha"
+ static member WeightedPreReleaseNumber = "4"
diff --git a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
index 200b58a1e2..91cb09fa24 100644
--- a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
+++ b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt
@@ -8,22 +8,6 @@
'
'------------------------------------------------------------------------------
-#If NET20 OrElse NET35 OrElse NETCOREAPP1_0 OrElse NETCOREAPP1_1 OrElse NETSTANDARD1_0 OrElse NETSTANDARD1_1 OrElse NETSTANDARD1_2 OrElse NETSTANDARD1_3 OrElse NETSTANDARD1_4 OrElse NETSTANDARD1_5 OrElse NETSTANDARD1_6 Then
-Namespace Global.System.Diagnostics.CodeAnalysis
-
- Friend NotInheritable Class ExcludeFromCodeCoverageAttribute
- Inherits Global.System.Attribute
- End Class
-End Namespace
-#End If
-
Namespace Global
diff --git a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt
new file mode 100644
index 0000000000..153d3275fa
--- /dev/null
+++ b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt
@@ -0,0 +1,45 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' GitVersion
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Namespace My.Custom.Namespace
+
+
+
+ NotInheritable Class GitVersionInformation
+ Private Sub New()
+ End Sub
+ Public Shared AssemblySemFileVer As String = "1.2.3.0"
+ Public Shared AssemblySemVer As String = "1.2.3.0"
+ Public Shared BranchName As String = "feature1"
+ Public Shared BuildMetaData As String = "5"
+ Public Shared CommitDate As String = "2014-03-06"
+ Public Shared CommitsSinceVersionSource As String = "5"
+ Public Shared EscapedBranchName As String = "feature1"
+ Public Shared FullBuildMetaData As String = "5.Branch.feature1.Sha.commitSha"
+ Public Shared FullSemVer As String = "1.2.3-unstable.4+5"
+ Public Shared InformationalVersion As String = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha"
+ Public Shared Major As String = "1"
+ Public Shared MajorMinorPatch As String = "1.2.3"
+ Public Shared Minor As String = "2"
+ Public Shared Patch As String = "3"
+ Public Shared PreReleaseLabel As String = "unstable"
+ Public Shared PreReleaseLabelWithDash As String = "-unstable"
+ Public Shared PreReleaseNumber As String = "4"
+ Public Shared PreReleaseTag As String = "unstable.4"
+ Public Shared PreReleaseTagWithDash As String = "-unstable.4"
+ Public Shared SemVer As String = "1.2.3-unstable.4"
+ Public Shared Sha As String = "commitSha"
+ Public Shared ShortSha As String = "commitShortSha"
+ Public Shared UncommittedChanges As String = "0"
+ Public Shared VersionSourceSha As String = "versionSourceSha"
+ Public Shared WeightedPreReleaseNumber As String = "4"
+ End Class
+
+End Namespace
diff --git a/src/GitVersion.Output.Tests/Output/GitVersionInfoGeneratorTests.cs b/src/GitVersion.Output.Tests/Output/GitVersionInfoGeneratorTests.cs
index 2fa8cb6a09..56ac52df1b 100644
--- a/src/GitVersion.Output.Tests/Output/GitVersionInfoGeneratorTests.cs
+++ b/src/GitVersion.Output.Tests/Output/GitVersionInfoGeneratorTests.cs
@@ -53,10 +53,11 @@ public void ShouldCreateFile(string fileExtension)
///
/// Regression test for issue #4196 (https://github.com/GitTools/GitVersion/issues/4196)
///
- [TestCase]
- public void ShouldProperlyOutputNamespaceDeclaration()
+ [TestCase("cs")]
+ [TestCase("fs")]
+ [TestCase("vb")]
+ public void ShouldProperlyOutputNamespaceDeclaration(string fileExtension)
{
- const string fileExtension = "cs";
const string targetNamespace = "My.Custom.Namespace";
var directory = PathHelper.Combine(PathHelper.GetTempPath(), "GitVersionInfoGeneratorTests", Guid.NewGuid().ToString());
diff --git a/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.cs b/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.cs
index 12deef9fa3..46527b8ca3 100644
--- a/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.cs
+++ b/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.cs
@@ -7,22 +7,6 @@
// the code is regenerated.
//
//------------------------------------------------------------------------------
-
-#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
-namespace System.Diagnostics.CodeAnalysis
-{{
- [global::System.AttributeUsage(
- global::System.AttributeTargets.Assembly |
- global::System.AttributeTargets.Class |
- global::System.AttributeTargets.Struct |
- global::System.AttributeTargets.Constructor |
- global::System.AttributeTargets.Method |
- global::System.AttributeTargets.Property |
- global::System.AttributeTargets.Event,
- Inherited = false, AllowMultiple = false)]
- internal sealed class ExcludeFromCodeCoverageAttribute : global::System.Attribute {{ }}
-}}
-#endif
{1}{2}
{4}[global::System.Runtime.CompilerServices.CompilerGenerated]
{4}[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
diff --git a/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.fs b/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.fs
index 0862986636..5fff544676 100644
--- a/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.fs
+++ b/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.fs
@@ -8,22 +8,6 @@
//
//------------------------------------------------------------------------------
-#if NET20 || NET35 || NETCOREAPP1_0 || NETCOREAPP1_1 || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
-namespace System.Diagnostics.CodeAnalysis
-
-[]
-[]
-type ExcludeFromCodeCoverageAttribute() = inherit global.System.Attribute()
-#endif
-
namespace {1}
[]
diff --git a/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.vb b/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.vb
index b7f3b7b923..48105ab7ce 100644
--- a/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.vb
+++ b/src/GitVersion.Output/GitVersionInfo/Templates/GitVersionInformation.vb
@@ -8,22 +8,6 @@
'
'------------------------------------------------------------------------------
-#If NET20 OrElse NET35 OrElse NETCOREAPP1_0 OrElse NETCOREAPP1_1 OrElse NETSTANDARD1_0 OrElse NETSTANDARD1_1 OrElse NETSTANDARD1_2 OrElse NETSTANDARD1_3 OrElse NETSTANDARD1_4 OrElse NETSTANDARD1_5 OrElse NETSTANDARD1_6 Then
-Namespace Global.System.Diagnostics.CodeAnalysis
-
- Friend NotInheritable Class ExcludeFromCodeCoverageAttribute
- Inherits Global.System.Attribute
- End Class
-End Namespace
-#End If
-
Namespace {1}
diff --git a/src/GitVersion.Testing/Helpers/StringBuilderExtensions.cs b/src/GitVersion.Testing/Helpers/StringBuilderExtensions.cs
index a17c0d4e1a..2893be4336 100644
--- a/src/GitVersion.Testing/Helpers/StringBuilderExtensions.cs
+++ b/src/GitVersion.Testing/Helpers/StringBuilderExtensions.cs
@@ -1,15 +1,11 @@
-#if NET7_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
-#endif
namespace GitVersion.Testing.Internal;
internal static class StringBuilderExtensions
{
public static void AppendLineFormat(this StringBuilder stringBuilder,
-#if NET7_0_OR_GREATER
[StringSyntax(StringSyntaxAttribute.CompositeFormat)]
-#endif
string format,
params object?[] args)
{