Add nullability to nucache & lucene projects

This commit is contained in:
Nikolaj Geisle
2022-03-30 13:34:56 +02:00
parent b52c4e50cf
commit 05a08bef63
105 changed files with 736 additions and 619 deletions

View File

@@ -14,7 +14,7 @@ namespace Umbraco.Cms.Infrastructure.PublishedCache.Snap
public GenRef GetGenRef()
{
// not thread-safe but always invoked from within a lock
var genRef = (GenRef)WeakGenRef.Target;
var genRef = (GenRef?)WeakGenRef.Target;
if (genRef == null)
WeakGenRef.Target = genRef = new GenRef(this);
return genRef;

View File

@@ -7,9 +7,9 @@
/// </summary>
/// <typeparam name="TValue"></typeparam>
internal class LinkedNode<TValue>
where TValue : class
where TValue : class?
{
public LinkedNode(TValue value, long gen, LinkedNode<TValue> next = null)
public LinkedNode(TValue? value, long gen, LinkedNode<TValue>? next = null)
{
Value = value; // This is allowed to be null, we actually explicitly set this to null in ClearLocked
Gen = gen;
@@ -20,7 +20,7 @@
// reading & writing references is thread-safe on all .NET platforms
// mark as volatile to ensure we always read the correct value
public volatile TValue Value;
public volatile LinkedNode<TValue> Next;
public volatile TValue? Value;
public volatile LinkedNode<TValue>? Next;
}
}