From bdcfd1b30d730d77c1415e19ba423cb3fff98617 Mon Sep 17 00:00:00 2001 From: Artur Date: Mon, 9 Jan 2023 13:00:05 +0100 Subject: [PATCH] #3334 - re-target to .net6.0 and .net7.0 in place of netstandard2.0 --- src/Directory.Build.props | 2 + src/GitTools.Testing/GitTools.Testing.csproj | 1 - .../GitVersion.App.Tests.csproj | 2 - src/GitVersion.App/GitVersion.App.csproj | 1 - .../GitVersion.Core.Tests.csproj | 2 - .../CallerArgumentExpressionAttribute.cs | 25 --- .../Extensions/NullableAttributes.cs | 147 ------------------ src/GitVersion.Core/GitVersion.Core.csproj | 27 ++-- src/GitVersion.Core/Helpers/ProcessHelper.cs | 1 - .../GitVersion.LibGit2Sharp.csproj | 4 - .../GitVersion.MsBuild.Tests.csproj | 2 - .../GitVersion.MsBuild.csproj | 2 - src/GitVersion.MsBuild/nuget-files.props | 14 +- 13 files changed, 22 insertions(+), 208 deletions(-) delete mode 100644 src/GitVersion.Core/Extensions/CallerArgumentExpressionAttribute.cs delete mode 100644 src/GitVersion.Core/Extensions/NullableAttributes.cs diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 10aa09350b..4f2616d3e0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,5 +1,7 @@ + net6.0;net7.0 + $([System.DateTime]::Today.Year) GitTools and Contributors Copyright GitTools $(EndYear). diff --git a/src/GitTools.Testing/GitTools.Testing.csproj b/src/GitTools.Testing/GitTools.Testing.csproj index a19fdd5b88..3a6c88aa38 100644 --- a/src/GitTools.Testing/GitTools.Testing.csproj +++ b/src/GitTools.Testing/GitTools.Testing.csproj @@ -1,6 +1,5 @@  - netstandard2.0 false diff --git a/src/GitVersion.App.Tests/GitVersion.App.Tests.csproj b/src/GitVersion.App.Tests/GitVersion.App.Tests.csproj index 294d2c0b01..c66da8eeee 100644 --- a/src/GitVersion.App.Tests/GitVersion.App.Tests.csproj +++ b/src/GitVersion.App.Tests/GitVersion.App.Tests.csproj @@ -1,7 +1,5 @@ - net6.0;net7.0 - true diff --git a/src/GitVersion.App/GitVersion.App.csproj b/src/GitVersion.App/GitVersion.App.csproj index 6e1aa25731..3522236520 100644 --- a/src/GitVersion.App/GitVersion.App.csproj +++ b/src/GitVersion.App/GitVersion.App.csproj @@ -4,7 +4,6 @@ Exe GitVersion gitversion - net6.0;net7.0 AnyCPU MIT diff --git a/src/GitVersion.Core.Tests/GitVersion.Core.Tests.csproj b/src/GitVersion.Core.Tests/GitVersion.Core.Tests.csproj index 23d088dfbc..49b649f9eb 100644 --- a/src/GitVersion.Core.Tests/GitVersion.Core.Tests.csproj +++ b/src/GitVersion.Core.Tests/GitVersion.Core.Tests.csproj @@ -1,8 +1,6 @@ - net6.0;net7.0 - full false true diff --git a/src/GitVersion.Core/Extensions/CallerArgumentExpressionAttribute.cs b/src/GitVersion.Core/Extensions/CallerArgumentExpressionAttribute.cs deleted file mode 100644 index d5408867aa..0000000000 --- a/src/GitVersion.Core/Extensions/CallerArgumentExpressionAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace System.Runtime.CompilerServices; - -#if !NET6_0 - -/// -/// Allows capturing of the expressions passed to a method. -/// -[AttributeUsage(AttributeTargets.Parameter)] -public sealed class CallerArgumentExpressionAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The name of the targeted parameter. - public CallerArgumentExpressionAttribute(string parameterName) => this.ParameterName = parameterName; - - /// - /// Gets the target parameter name of the CallerArgumentExpression. - /// - /// - /// The name of the targeted parameter of the CallerArgumentExpression. - /// - public string ParameterName { get; } -} -#endif diff --git a/src/GitVersion.Core/Extensions/NullableAttributes.cs b/src/GitVersion.Core/Extensions/NullableAttributes.cs deleted file mode 100644 index 65c7bebbb1..0000000000 --- a/src/GitVersion.Core/Extensions/NullableAttributes.cs +++ /dev/null @@ -1,147 +0,0 @@ -// This was copied from https://github.com/dotnet/coreclr/blob/60f1e6265bd1039f023a82e0643b524d6aaf7845/src/System.Private.CoreLib/shared/System/Diagnostics/CodeAnalysis/NullableAttributes.cs -// and updated to have the scope of the attributes be internal. - -#pragma warning disable CA1019 // Define accessors for attribute arguments - -namespace System.Diagnostics.CodeAnalysis; -#if !NETCOREAPP - -/// Specifies that null is allowed as an input even if the corresponding type disallows it. -[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property)] -internal sealed class AllowNullAttribute : Attribute { } - -/// Specifies that null is disallowed as an input even if the corresponding type allows it. -[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property)] -internal sealed class DisallowNullAttribute : Attribute { } - -/// Specifies that an output may be null even if the corresponding type disallows it. -[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)] -internal sealed class MaybeNullAttribute : Attribute { } - -/// Specifies that an output will not be null even if the corresponding type allows it. -[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)] -internal sealed class NotNullAttribute : Attribute { } - -/// Specifies that when a method returns , the parameter may be null even if the corresponding type disallows it. -[AttributeUsage(AttributeTargets.Parameter)] -internal sealed class MaybeNullWhenAttribute : Attribute -{ - /// Initializes the attribute with the specified return value condition. - /// - /// The return value condition. If the method returns this value, the associated parameter may be null. - /// - public MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; - - /// Gets the return value condition. - public bool ReturnValue { get; } -} - -/// Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. -[AttributeUsage(AttributeTargets.Parameter)] -internal sealed class NotNullWhenAttribute : Attribute -{ - /// Initializes the attribute with the specified return value condition. - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - /// - public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; - - /// Gets the return value condition. - public bool ReturnValue { get; } -} - -/// Specifies that the output will be non-null if the named parameter is non-null. -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true)] -internal sealed class NotNullIfNotNullAttribute : Attribute -{ - /// Initializes the attribute with the associated parameter name. - /// - /// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. - /// - public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName; - - /// Gets the associated parameter name. - public string ParameterName { get; } -} - -/// Applied to a method that will never return under any circumstance. -[AttributeUsage(AttributeTargets.Method, Inherited = false)] -internal sealed class DoesNotReturnAttribute : Attribute { } - -/// Specifies that the method will not return if the associated Boolean parameter is passed the specified value. -[AttributeUsage(AttributeTargets.Parameter)] -internal sealed class DoesNotReturnIfAttribute : Attribute -{ - /// Initializes the attribute with the specified parameter value. - /// - /// The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to - /// the associated parameter matches this value. - /// - public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue; - - /// Gets the condition parameter value. - public bool ParameterValue { get; } -} - -#endif - -#if !NETCOREAPP || NETCOREAPP3_1 - -/// Specifies that the method or property will ensure that the listed field and property members have not-null values. -[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] -internal sealed class MemberNotNullAttribute : Attribute -{ - /// Initializes the attribute with a field or property member. - /// - /// The field or property member that is promised to be not-null. - /// - public MemberNotNullAttribute(string member) => Members = new[] { member }; - - /// Initializes the attribute with the list of field and property members. - /// - /// The list of field and property members that are promised to be not-null. - /// - public MemberNotNullAttribute(params string[] members) => Members = members; - - /// Gets field or property member names. - public string[] Members { get; } -} - -/// Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition. -[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] -internal sealed class MemberNotNullWhenAttribute : Attribute -{ - /// Initializes the attribute with the specified return value condition and a field or property member. - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - /// - /// - /// The field or property member that is promised to be not-null. - /// - public MemberNotNullWhenAttribute(bool returnValue, string member) - { - ReturnValue = returnValue; - Members = new[] { member }; - } - - /// Initializes the attribute with the specified return value condition and list of field and property members. - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - /// - /// - /// The list of field and property members that are promised to be not-null. - /// - public MemberNotNullWhenAttribute(bool returnValue, params string[] members) - { - ReturnValue = returnValue; - Members = members; - } - - /// Gets the return value condition. - public bool ReturnValue { get; } - - /// Gets field or property member names. - public string[] Members { get; } -} - -#endif diff --git a/src/GitVersion.Core/GitVersion.Core.csproj b/src/GitVersion.Core/GitVersion.Core.csproj index 809cf8db21..4d8e00a35d 100644 --- a/src/GitVersion.Core/GitVersion.Core.csproj +++ b/src/GitVersion.Core/GitVersion.Core.csproj @@ -1,7 +1,6 @@ - netstandard2.0 GitVersion bin\$(Configuration)\GitVersionCore.xml @@ -14,26 +13,26 @@ - - + + - - - - + + + + - - - - + + + + - - - + + + diff --git a/src/GitVersion.Core/Helpers/ProcessHelper.cs b/src/GitVersion.Core/Helpers/ProcessHelper.cs index cbac47cd03..68d5d2de5c 100644 --- a/src/GitVersion.Core/Helpers/ProcessHelper.cs +++ b/src/GitVersion.Core/Helpers/ProcessHelper.cs @@ -1,6 +1,5 @@ using System.ComponentModel; using System.Runtime.InteropServices; -using GitVersion.Extensions; namespace GitVersion.Helpers; diff --git a/src/GitVersion.LibGit2Sharp/GitVersion.LibGit2Sharp.csproj b/src/GitVersion.LibGit2Sharp/GitVersion.LibGit2Sharp.csproj index 7b0778d9c3..cf74339e6b 100644 --- a/src/GitVersion.LibGit2Sharp/GitVersion.LibGit2Sharp.csproj +++ b/src/GitVersion.LibGit2Sharp/GitVersion.LibGit2Sharp.csproj @@ -1,9 +1,5 @@ - - netstandard2.0 - - diff --git a/src/GitVersion.MsBuild.Tests/GitVersion.MsBuild.Tests.csproj b/src/GitVersion.MsBuild.Tests/GitVersion.MsBuild.Tests.csproj index 1636b1aaf6..2c5681be9b 100644 --- a/src/GitVersion.MsBuild.Tests/GitVersion.MsBuild.Tests.csproj +++ b/src/GitVersion.MsBuild.Tests/GitVersion.MsBuild.Tests.csproj @@ -1,8 +1,6 @@ - net6.0;net7.0 - true diff --git a/src/GitVersion.MsBuild/GitVersion.MsBuild.csproj b/src/GitVersion.MsBuild/GitVersion.MsBuild.csproj index 91fe0c2154..9e91390ac5 100644 --- a/src/GitVersion.MsBuild/GitVersion.MsBuild.csproj +++ b/src/GitVersion.MsBuild/GitVersion.MsBuild.csproj @@ -1,8 +1,6 @@ - netstandard2.0 - GitVersion.MsBuild GitVersionMsBuild 0.0.1-alpha-0001 diff --git a/src/GitVersion.MsBuild/nuget-files.props b/src/GitVersion.MsBuild/nuget-files.props index 5c53cb2806..1f72446084 100644 --- a/src/GitVersion.MsBuild/nuget-files.props +++ b/src/GitVersion.MsBuild/nuget-files.props @@ -7,13 +7,13 @@ tools/net7.0 - - - + + + - - - - + + + +