Skip to content

Commit 3801102

Browse files
committed
GitTools#3334 - fix nullable warnings
1 parent 6de89f0 commit 3801102

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/GitVersion.Core/Core/MergeCommitFinder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public IEnumerable<BranchCommit> FindMergeCommitsFor(IBranch branch)
2424
{
2525
branch = branch.NotNull();
2626

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

3333
var branchMergeBases = FindMergeBases(branch)

src/GitVersion.Core/Extensions/DictionaryExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dict,
66
{
77
if (dict is null) throw new ArgumentNullException(nameof(dict));
88
if (getValue is null) throw new ArgumentNullException(nameof(getValue));
9-
if (!dict.TryGetValue(key, out TValue value))
9+
10+
if (!dict.TryGetValue(key, out var value))
1011
{
1112
value = getValue();
1213
dict.Add(key, value);

src/GitVersion.Core/Extensions/ObjectExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public static void Deconstruct<TKey, TValue>(
1616
value = kvp.Value;
1717
}
1818

19-
public static IEnumerable<KeyValuePair<string, string>> GetProperties(this object obj)
19+
public static Dictionary<string, string> GetProperties(this object obj)
2020
{
2121
var type = typeof(string);
2222
return obj.GetType().GetProperties()
2323
.Where(p => p.PropertyType == type && !p.GetIndexParameters().Any() && !p.GetCustomAttributes(typeof(ReflectionIgnoreAttribute), false).Any())
24-
.Select(p => new KeyValuePair<string, string>(p.Name, (string)p.GetValue(obj, null)));
24+
.ToDictionary(p => p.Name, p => Convert.ToString(p.GetValue(obj, null))!);
2525
}
2626
}

0 commit comments

Comments
 (0)