Skip to content

Commit

Permalink
GitTools#3334 - fix nullable warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Feb 17, 2023
1 parent 6de89f0 commit 3801102
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/GitVersion.Core/Core/MergeCommitFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
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))!);
}
}

0 comments on commit 3801102

Please sign in to comment.