Skip to content

#3334 - re-target to .net6.0 and .net7.0 in place of netstandard2.0 #3335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>

<EndYear>$([System.DateTime]::Today.Year)</EndYear>
<Authors>GitTools and Contributors</Authors>
<Copyright>Copyright GitTools $(EndYear).</Copyright>
Expand Down
1 change: 0 additions & 1 deletion src/GitTools.Testing/GitTools.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/GitVersion.App.Tests/GitVersion.App.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>

<IsTestProject>true</IsTestProject>
</PropertyGroup>

Expand Down
1 change: 0 additions & 1 deletion src/GitVersion.App/GitVersion.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<OutputType>Exe</OutputType>
<RootNamespace>GitVersion</RootNamespace>
<AssemblyName>gitversion</AssemblyName>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<PlatformTarget>AnyCPU</PlatformTarget>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/GitVersion.Core.Tests/GitVersion.Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>

<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public void ConfigNextVersionTest(string nextVersion, string expectedVersion)
var branchMock = GitToolsTestingExtensions.CreateMockBranch("main", GitToolsTestingExtensions.CreateMockCommit());
var branchConfiguration = context.Configuration.GetBranchConfiguration(branchMock);
var effectiveConfiguration = new EffectiveConfiguration(context.Configuration, branchConfiguration);

strategy.ShouldNotBeNull();
return strategy.GetBaseVersions(new(branchMock, effectiveConfiguration)).SingleOrDefault();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public void ShouldNotAllowIncrementOfVersion()
var context = contextBuilder.ServicesProvider.GetRequiredService<Lazy<GitVersionContext>>().Value;
var branchConfiguration = context.Configuration.GetBranchConfiguration(mockBranch);
var effectiveConfiguration = new EffectiveConfiguration(context.Configuration, branchConfiguration);

strategy.ShouldNotBeNull();
var baseVersion = strategy.GetBaseVersions(new(mockBranch, effectiveConfiguration)).Single();

baseVersion.ShouldIncrement.ShouldBe(false);
Expand Down Expand Up @@ -173,6 +175,8 @@ private static void AssertMergeMessage(string message, string? expectedVersion,
var context = contextBuilder.ServicesProvider.GetRequiredService<Lazy<GitVersionContext>>().Value;
var branchConfiguration = context.Configuration.GetBranchConfiguration(mockBranch);
var effectiveConfiguration = new EffectiveConfiguration(context.Configuration, branchConfiguration);

strategy.ShouldNotBeNull();
var baseVersion = strategy.GetBaseVersions(new(mockBranch, effectiveConfiguration)).SingleOrDefault();

if (expectedVersion == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public void CanTakeVersionFromNameOfReleaseBranch(string branchName, string expe
var configuration = GitFlowConfigurationBuilder.New.Build();
var branchConfiguration = configuration.GetBranchConfiguration(branchName);
var effectiveConfiguration = new EffectiveConfiguration(configuration, branchConfiguration);

strategy.ShouldNotBeNull();
var baseVersion = strategy.GetBaseVersions(new(gitRepository.FindBranch(branchName)!, effectiveConfiguration)).Single();

baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
Expand All @@ -45,6 +47,8 @@ public void ShouldNotTakeVersionFromNameOfNonReleaseBranch(string branchName)
var configuration = GitFlowConfigurationBuilder.New.Build();
var branchConfiguration = configuration.GetBranchConfiguration(branchName);
var effectiveConfiguration = new EffectiveConfiguration(configuration, branchConfiguration);

strategy.ShouldNotBeNull();
var baseVersions = strategy.GetBaseVersions(new(gitRepository.FindBranch(branchName)!, effectiveConfiguration));

baseVersions.ShouldBeEmpty();
Expand All @@ -67,6 +71,9 @@ public void CanTakeVersionFromNameOfConfiguredReleaseBranch(string branchName, s
var configuration = GitFlowConfigurationBuilder.New.Build();
var branchConfiguration = configuration.GetBranchConfiguration(branchName);
var effectiveConfiguration = new EffectiveConfiguration(configuration, branchConfiguration);

strategy.ShouldNotBeNull();

var baseVersion = strategy.GetBaseVersions(new(gitRepository.FindBranch(branchName)!, effectiveConfiguration)).Single();

baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
Expand All @@ -90,6 +97,9 @@ public void CanTakeVersionFromNameOfRemoteReleaseBranch(string branchName, strin
var configuration = GitFlowConfigurationBuilder.New.Build();
var branchConfiguration = configuration.GetBranchConfiguration(branchName);
var effectiveConfiguration = new EffectiveConfiguration(configuration, branchConfiguration);

strategy.ShouldNotBeNull();

var baseVersion = strategy.GetBaseVersions(new(gitRepository.FindBranch(branchName)!, effectiveConfiguration)).Single();

baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
Expand Down
5 changes: 4 additions & 1 deletion src/GitVersion.Core/Core/GitVersionModule.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using GitVersion.Extensions;
using Microsoft.Extensions.DependencyInjection;

namespace GitVersion;
Expand All @@ -6,8 +7,10 @@ public abstract class GitVersionModule : IGitVersionModule
{
public abstract void RegisterTypes(IServiceCollection services);

protected static IEnumerable<Type> FindAllDerivedTypes<T>(Assembly assembly)
protected static IEnumerable<Type> FindAllDerivedTypes<T>(Assembly? assembly)
{
assembly.NotNull();

var derivedType = typeof(T);
return assembly.GetTypes().Where(t => t != derivedType && derivedType.IsAssignableFrom(t));
}
Expand Down
8 changes: 4 additions & 4 deletions src/GitVersion.Core/Core/MergeCommitFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal class MergeCommitFinder
{
private readonly IEnumerable<IBranch> excludedBranches;
private readonly ILog log;
private readonly Dictionary<IBranch?, List<BranchCommit>> mergeBaseCommitsCache = new();
private readonly Dictionary<IBranch, List<BranchCommit>> mergeBaseCommitsCache = new();
private readonly RepositoryStore repositoryStore;
private readonly GitVersionConfiguration configuration;

Expand All @@ -24,10 +24,10 @@ public IEnumerable<BranchCommit> FindMergeCommitsFor(IBranch branch)
{
branch = branch.NotNull();

if (this.mergeBaseCommitsCache.ContainsKey(branch))
if (this.mergeBaseCommitsCache.TryGetValue(branch, out var mergeCommitsFor))
{
this.log.Debug($"Cache hit for getting merge commits for branch {branch?.Name.Canonical}.");
return this.mergeBaseCommitsCache[branch];
this.log.Debug($"Cache hit for getting merge commits for branch {branch.Name.Canonical}.");
return mergeCommitsFor;
}

var branchMergeBases = FindMergeBases(branch)
Expand Down

This file was deleted.

8 changes: 2 additions & 6 deletions src/GitVersion.Core/Extensions/CommonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public static string NotNullOrEmpty([NotNull] this string? value, [CallerArgumen
throw new ArgumentException("The parameter is null or empty.", name);
}

#pragma warning disable CS8777 // Parameter must have a non-null value when exiting.
return value!;
#pragma warning restore CS8777 // Parameter must have a non-null value when exiting.
return value;
}

public static string NotNullOrWhitespace([NotNull] this string? value, [CallerArgumentExpression("value")] string name = "")
Expand All @@ -27,8 +25,6 @@ public static string NotNullOrWhitespace([NotNull] this string? value, [CallerAr
throw new ArgumentException("The parameter is null or empty or contains only white space.", name);
}

#pragma warning disable CS8777 // Parameter must have a non-null value when exiting.
return value!;
#pragma warning restore CS8777 // Parameter must have a non-null value when exiting.
return value;
}
}
3 changes: 2 additions & 1 deletion src/GitVersion.Core/Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dict,
{
if (dict is null) throw new ArgumentNullException(nameof(dict));
if (getValue is null) throw new ArgumentNullException(nameof(getValue));
if (!dict.TryGetValue(key, out TValue value))

if (!dict.TryGetValue(key, out var value))
{
value = getValue();
dict.Add(key, value);
Expand Down
147 changes: 0 additions & 147 deletions src/GitVersion.Core/Extensions/NullableAttributes.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/GitVersion.Core/Extensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public static void Deconstruct<TKey, TValue>(
value = kvp.Value;
}

public static IEnumerable<KeyValuePair<string, string>> GetProperties(this object obj)
public static Dictionary<string, string> GetProperties(this object obj)
{
var type = typeof(string);
return obj.GetType().GetProperties()
.Where(p => p.PropertyType == type && !p.GetIndexParameters().Any() && !p.GetCustomAttributes(typeof(ReflectionIgnoreAttribute), false).Any())
.Select(p => new KeyValuePair<string, string>(p.Name, (string)p.GetValue(obj, null)));
.ToDictionary(p => p.Name, p => Convert.ToString(p.GetValue(obj, null))!);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public static IServiceCollection AddModule(this IServiceCollection serviceCollec
}

public static TService GetServiceForType<TService, TType>(this IServiceProvider serviceProvider) =>
serviceProvider.GetServices<TService>().SingleOrDefault(t => t?.GetType() == typeof(TType));
serviceProvider.GetServices<TService>().Single(t => t?.GetType() == typeof(TType));
}
4 changes: 2 additions & 2 deletions src/GitVersion.Core/Git/ReferenceName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public static ReferenceName Parse(string canonicalName)
public bool IsPullRequest { get; }

public bool Equals(ReferenceName? other) => equalityHelper.Equals(this, other);
public int CompareTo(ReferenceName other) => comparerHelper.Compare(this, other);
public override bool Equals(object obj) => Equals((obj as ReferenceName));
public int CompareTo(ReferenceName? other) => comparerHelper.Compare(this, other);
public override bool Equals(object? obj) => Equals((obj as ReferenceName));
public override int GetHashCode() => equalityHelper.GetHashCode(this);
public override string ToString() => Friendly;

Expand Down
Loading