fix(code-quality): resolve CS0628 warnings - change protected to private in sealed classes. (#21193)

* fix(code-quality): resolve CS0628 warnings - change protected to private in sealed classes

Changed protected members to private in sealed classes across 26 files. Protected members in sealed classes serve no purpose since sealed classes cannot be inherited. This eliminates 57 CS0628 compiler warnings.

* fix: use public for NUnit SetUp methods per Copilot review

NUnit requires SetUp methods to be at least protected. Using public
avoids CS0628 while allowing NUnit to discover and execute the methods.

* Clean up

- Renames internal fields to clearer names and aligns with conventions
- Changes internal cache holder to use auto-properties for state ( fixes another build warning )
- Removes an unused exception type from the loader and cleans up unused usings
- Adds "Umbraco" to the list of known spellings in .vsCode settings file, amazed this wasn't already there :)

* Improvements to fix CodeScene Code Health Review issues.

- Introduces debug-only logging helpers and routes all log messages through them for consistency
- Centralizes retrieval of discoverable types and scanning logic to simplify paths
- Aligns logging of cached vs non-cached and slow paths with new helpers
- Documents data-holding structure used to store type lists for clarity

* Refactoring to make CodeScene happy, removing code duplication :)
This commit is contained in:
Chris Houston
2025-12-18 19:28:13 +01:00
committed by GitHub
parent ebb6590bad
commit 0d4f24300a
27 changed files with 186 additions and 233 deletions
+1
View File
@@ -3,6 +3,7 @@
"backoffice", "backoffice",
"pickable", "pickable",
"Pickable", "Pickable",
"Umbraco",
"unprovide", "unprovide",
"Unproviding" "Unproviding"
], ],
+90 -156
View File
@@ -1,9 +1,6 @@
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Collections; using Umbraco.Cms.Core.Collections;
using Umbraco.Cms.Core.Logging;
using Umbraco.Extensions; using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Composing; namespace Umbraco.Cms.Core.Composing;
@@ -20,13 +17,21 @@ namespace Umbraco.Cms.Core.Composing;
/// </remarks> /// </remarks>
public sealed class TypeLoader public sealed class TypeLoader
{ {
private readonly Lock _locko = new(); private readonly Lock _typesLock = new();
private readonly ILogger<TypeLoader> _logger; private readonly ILogger<TypeLoader> _logger;
private readonly Dictionary<CompositeTypeTypeKey, TypeList> _types = new(); private readonly Dictionary<CompositeTypeTypeKey, TypeList> _types = new();
private IEnumerable<Assembly>? _assemblies; private IEnumerable<Assembly>? _assemblies;
private bool IsDebugEnabled => _logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug);
/// <summary>
/// Initializes a new instance of the <see cref="TypeLoader"/> class.
/// </summary>
/// <param name="typeFinder">The type finder used to discover types.</param>
/// <param name="logger">The logger instance.</param>
/// <param name="assembliesToScan">Optional set of assemblies to scan.</param>
public TypeLoader( public TypeLoader(
ITypeFinder typeFinder, ITypeFinder typeFinder,
ILogger<TypeLoader> logger, ILogger<TypeLoader> logger,
@@ -105,10 +110,7 @@ public sealed class TypeLoader
/// <remarks>Caching is disabled when using specific assemblies.</remarks> /// <remarks>Caching is disabled when using specific assemblies.</remarks>
public IEnumerable<Type> GetTypes<T>(bool cache = true, IEnumerable<Assembly>? specificAssemblies = null) public IEnumerable<Type> GetTypes<T>(bool cache = true, IEnumerable<Assembly>? specificAssemblies = null)
{ {
if (_logger == null) EnsureInitialized();
{
throw new InvalidOperationException("Cannot get types from a test/blank type loader.");
}
// do not cache anything from specific assemblies // do not cache anything from specific assemblies
cache &= specificAssemblies == null; cache &= specificAssemblies == null;
@@ -116,14 +118,11 @@ public sealed class TypeLoader
// if not IDiscoverable, directly get types // if not IDiscoverable, directly get types
if (!typeof(IDiscoverable).IsAssignableFrom(typeof(T))) if (!typeof(IDiscoverable).IsAssignableFrom(typeof(T)))
{ {
// warn LogDebugIf(
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) true,
{ "Running a full, {CacheStatus}cached, scan for non-discoverable type {TypeName} (slow).",
_logger.LogDebug( CacheStatus(cache),
"Running a full, " + (cache ? string.Empty : "non-") +
"cached, scan for non-discoverable type {TypeName} (slow).",
typeof(T).FullName); typeof(T).FullName);
}
return GetTypesInternal( return GetTypesInternal(
typeof(T), typeof(T),
@@ -134,23 +133,12 @@ public sealed class TypeLoader
} }
// get IDiscoverable and always cache // get IDiscoverable and always cache
IEnumerable<Type> discovered = GetTypesInternal( IEnumerable<Type> discovered = GetDiscoverableTypes();
typeof(IDiscoverable),
null,
() => TypeFinder.FindClassesOfType<IDiscoverable>(AssembliesToScan),
"scanning assemblies",
true);
// warn LogDebugIf(
if (!cache) !cache,
{ "Running a non-cached, filter for discoverable type {TypeName} (slowish).",
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) typeof(T).FullName);
{
_logger.LogDebug(
"Running a non-cached, filter for discoverable type {TypeName} (slowish).",
typeof(T).FullName);
}
}
// filter the cached discovered types (and maybe cache the result) // filter the cached discovered types (and maybe cache the result)
return GetTypesInternal( return GetTypesInternal(
@@ -175,10 +163,7 @@ public sealed class TypeLoader
IEnumerable<Assembly>? specificAssemblies = null) IEnumerable<Assembly>? specificAssemblies = null)
where TAttribute : Attribute where TAttribute : Attribute
{ {
if (_logger == null) EnsureInitialized();
{
throw new InvalidOperationException("Cannot get types from a test/blank type loader.");
}
// do not cache anything from specific assemblies // do not cache anything from specific assemblies
cache &= specificAssemblies == null; cache &= specificAssemblies == null;
@@ -186,14 +171,12 @@ public sealed class TypeLoader
// if not IDiscoverable, directly get types // if not IDiscoverable, directly get types
if (!typeof(IDiscoverable).IsAssignableFrom(typeof(T))) if (!typeof(IDiscoverable).IsAssignableFrom(typeof(T)))
{ {
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) LogDebugIf(
{ true,
_logger.LogDebug( "Running a full, {CacheStatus}cached, scan for non-discoverable type {TypeName} / attribute {AttributeName} (slow).",
"Running a full, " + (cache ? string.Empty : "non-") + CacheStatus(cache),
"cached, scan for non-discoverable type {TypeName} / attribute {AttributeName} (slow).",
typeof(T).FullName, typeof(T).FullName,
typeof(TAttribute).FullName); typeof(TAttribute).FullName);
}
return GetTypesInternal( return GetTypesInternal(
typeof(T), typeof(T),
@@ -204,24 +187,13 @@ public sealed class TypeLoader
} }
// get IDiscoverable and always cache // get IDiscoverable and always cache
IEnumerable<Type> discovered = GetTypesInternal( IEnumerable<Type> discovered = GetDiscoverableTypes();
typeof(IDiscoverable),
null,
() => TypeFinder.FindClassesOfType<IDiscoverable>(AssembliesToScan),
"scanning assemblies",
true);
// warn LogDebugIf(
if (!cache) !cache,
{ "Running a non-cached, filter for discoverable type {TypeName} / attribute {AttributeName} (slowish).",
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) typeof(T).FullName,
{ typeof(TAttribute).FullName);
_logger.LogDebug(
"Running a non-cached, filter for discoverable type {TypeName} / attribute {AttributeName} (slowish).",
typeof(T).FullName,
typeof(TAttribute).FullName);
}
}
// filter the cached discovered types (and maybe cache the result) // filter the cached discovered types (and maybe cache the result)
return GetTypesInternal( return GetTypesInternal(
@@ -247,23 +219,15 @@ public sealed class TypeLoader
IEnumerable<Assembly>? specificAssemblies = null) IEnumerable<Assembly>? specificAssemblies = null)
where TAttribute : Attribute where TAttribute : Attribute
{ {
if (_logger == null) EnsureInitialized();
{
throw new InvalidOperationException("Cannot get types from a test/blank type loader.");
}
// do not cache anything from specific assemblies // do not cache anything from specific assemblies
cache &= specificAssemblies == null; cache &= specificAssemblies == null;
if (!cache) LogDebugIf(
{ !cache,
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) "Running a full, non-cached, scan for types / attribute {AttributeName} (slow).",
{ typeof(TAttribute).FullName);
_logger.LogDebug(
"Running a full, non-cached, scan for types / attribute {AttributeName} (slow).",
typeof(TAttribute).FullName);
}
}
return GetTypesInternal( return GetTypesInternal(
typeof(object), typeof(object),
@@ -280,6 +244,38 @@ public sealed class TypeLoader
return s; return s;
} }
private void EnsureInitialized()
{
if (_logger == null)
{
throw new InvalidOperationException("Cannot get types from a test/blank type loader.");
}
}
private IEnumerable<Type> GetDiscoverableTypes() =>
GetTypesInternal(
typeof(IDiscoverable),
null,
() => TypeFinder.FindClassesOfType<IDiscoverable>(AssembliesToScan),
"scanning assemblies",
true);
/// <summary>
/// Logs a debug message if the specified condition is true and debug logging is enabled.
/// </summary>
/// <param name="condition">The condition that must be true to log.</param>
/// <param name="message">The log message template.</param>
/// <param name="args">The message arguments.</param>
private void LogDebugIf(bool condition, string message, params object?[] args)
{
if (condition && IsDebugEnabled)
{
_logger.LogDebug(message, args);
}
}
private string CacheStatus(bool cache) => cache ? string.Empty : "non-";
private IEnumerable<Type> GetTypesInternal( private IEnumerable<Type> GetTypesInternal(
Type baseType, Type baseType,
Type? attributeType, Type? attributeType,
@@ -291,7 +287,7 @@ public sealed class TypeLoader
// lock at a time, and we don't have non-upgradeable readers, and quite probably the type // lock at a time, and we don't have non-upgradeable readers, and quite probably the type
// loader is mostly not going to be used in any kind of massively multi-threaded scenario - so, // loader is mostly not going to be used in any kind of massively multi-threaded scenario - so,
// a plain lock is enough // a plain lock is enough
lock (_locko) lock (_typesLock)
{ {
return GetTypesInternalLocked(baseType, attributeType, finder, action, cache); return GetTypesInternalLocked(baseType, attributeType, finder, action, cache);
} }
@@ -305,34 +301,21 @@ public sealed class TypeLoader
bool cache) bool cache)
{ {
// check if the TypeList already exists, if so return it, if not we'll create it // check if the TypeList already exists, if so return it, if not we'll create it
Type tobject = typeof(object); // CompositeTypeTypeKey does not support null values Type objectType = typeof(object); // CompositeTypeTypeKey does not support null values
var listKey = new CompositeTypeTypeKey(baseType ?? tobject, attributeType ?? tobject); var listKey = new CompositeTypeTypeKey(baseType ?? objectType, attributeType ?? objectType);
TypeList? typeList = null;
if (cache) // need to put some logging here to try to figure out why this is happening: http://issues.umbraco.org/issue/U4-3505
if (cache && _types.TryGetValue(listKey, out TypeList? cachedList))
{ {
_types.TryGetValue(listKey, out typeList); // else null LogDebugIf(true, "Getting {TypeName}: found a cached type list.", GetName(baseType, attributeType));
return cachedList.Types;
} }
// if caching and found, return // else proceed
if (typeList != null) var typeList = new TypeList(baseType, attributeType);
{
// need to put some logging here to try to figure out why this is happening: http://issues.umbraco.org/issue/U4-3505
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
{
_logger.LogDebug("Getting {TypeName}: found a cached type list.", GetName(baseType, attributeType));
}
return typeList.Types;
}
// else proceed,
typeList = new TypeList(baseType, attributeType);
// either we had to scan, or we could not get the types from the cache file - scan now // either we had to scan, or we could not get the types from the cache file - scan now
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) LogDebugIf(true, "Getting {TypeName}: " + action + ".", GetName(baseType, attributeType));
{
_logger.LogDebug("Getting {TypeName}: " + action + ".", GetName(baseType, attributeType));
}
foreach (Type t in finder()) foreach (Type t in finder())
{ {
@@ -343,17 +326,11 @@ public sealed class TypeLoader
if (cache) if (cache)
{ {
var added = _types.TryAdd(listKey, typeList); var added = _types.TryAdd(listKey, typeList);
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) LogDebugIf(true, "Got {TypeName}, caching ({CacheType}).", GetName(baseType, attributeType), added.ToString().ToLowerInvariant());
{
_logger.LogDebug("Got {TypeName}, caching ({CacheType}).", GetName(baseType, attributeType), added.ToString().ToLowerInvariant());
}
} }
else else
{ {
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) LogDebugIf(true, "Got {TypeName}.", GetName(baseType, attributeType));
{
_logger.LogDebug("Got {TypeName}.", GetName(baseType, attributeType));
}
} }
return typeList.Types; return typeList.Types;
@@ -371,14 +348,25 @@ public sealed class TypeLoader
{ {
private readonly HashSet<Type> _types = new(); private readonly HashSet<Type> _types = new();
/// <summary>
/// Initializes a new instance of the <see cref="TypeList"/> class.
/// </summary>
/// <param name="baseType">The base type to filter by.</param>
/// <param name="attributeType">The attribute type to filter by.</param>
public TypeList(Type? baseType, Type? attributeType) public TypeList(Type? baseType, Type? attributeType)
{ {
BaseType = baseType; BaseType = baseType;
AttributeType = attributeType; AttributeType = attributeType;
} }
/// <summary>
/// Gets the base type used for filtering.
/// </summary>
public Type? BaseType { get; } public Type? BaseType { get; }
/// <summary>
/// Gets the attribute type used for filtering.
/// </summary>
public Type? AttributeType { get; } public Type? AttributeType { get; }
/// <summary> /// <summary>
@@ -402,59 +390,5 @@ public sealed class TypeLoader
} }
} }
/// <summary>
/// Represents the error that occurs when a type was not found in the cache type list with the specified
/// TypeResolutionKind.
/// </summary>
/// <seealso cref="System.Exception" />
[Serializable]
internal sealed class CachedTypeNotFoundInFileException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="CachedTypeNotFoundInFileException" /> class.
/// </summary>
public CachedTypeNotFoundInFileException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="CachedTypeNotFoundInFileException" /> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public CachedTypeNotFoundInFileException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="CachedTypeNotFoundInFileException" /> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">
/// The exception that is the cause of the current exception, or a null reference (
/// <see langword="Nothing" /> in Visual Basic) if no inner exception is specified.
/// </param>
public CachedTypeNotFoundInFileException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="CachedTypeNotFoundInFileException" /> class.
/// </summary>
/// <param name="info">
/// The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object
/// data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual
/// information about the source or destination.
/// </param>
protected CachedTypeNotFoundInFileException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
#endregion #endregion
} }
+1 -1
View File
@@ -44,7 +44,7 @@ public class LogProfiler : IProfiler
private readonly Action<long> _callback; private readonly Action<long> _callback;
private readonly Stopwatch _stopwatch = Stopwatch.StartNew(); private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
protected internal LightDisposableTimer(Action<long> callback) internal LightDisposableTimer(Action<long> callback)
{ {
_callback = callback ?? throw new ArgumentNullException(nameof(callback)); _callback = callback ?? throw new ArgumentNullException(nameof(callback));
} }
@@ -4,18 +4,21 @@ using Umbraco.Extensions;
namespace Umbraco.Cms.Core.PublishedCache; namespace Umbraco.Cms.Core.PublishedCache;
/// <summary>
/// Represents a property of a published element with caching support for property value conversions.
/// </summary>
internal sealed class PublishedElementPropertyBase : PublishedPropertyBase internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
{ {
protected readonly IPublishedElement Element; private readonly IPublishedElement _element;
// define constant - determines whether to use cache when previewing // define constant - determines whether to use cache when previewing
// to store eg routes, property converted values, anything - caching // to store eg routes, property converted values, anything - caching
// means faster execution, but uses memory - not sure if we want it // means faster execution, but uses memory - not sure if we want it
// so making it configurable. // so making it configurable.
private readonly Lock _locko = new(); private readonly Lock _cacheLock = new();
private readonly object? _sourceValue; private readonly object? _sourceValue;
protected readonly bool IsMember; private readonly bool _isMember;
protected readonly bool IsPreviewing; private readonly bool _isPreviewing;
private readonly VariationContext _variationContext; private readonly VariationContext _variationContext;
private readonly ICacheManager? _cacheManager; private readonly ICacheManager? _cacheManager;
private CacheValues? _cacheValues; private CacheValues? _cacheValues;
@@ -24,6 +27,16 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
private object? _interValue; private object? _interValue;
private string? _valuesCacheKey; private string? _valuesCacheKey;
/// <summary>
/// Initializes a new instance of the <see cref="PublishedElementPropertyBase"/> class.
/// </summary>
/// <param name="propertyType">The published property type.</param>
/// <param name="element">The published element that owns this property.</param>
/// <param name="previewing">Whether this is a preview request.</param>
/// <param name="referenceCacheLevel">The reference cache level.</param>
/// <param name="variationContext">The variation context for culture and segment.</param>
/// <param name="cacheManager">The cache manager.</param>
/// <param name="sourceValue">The source value of the property.</param>
public PublishedElementPropertyBase( public PublishedElementPropertyBase(
IPublishedPropertyType propertyType, IPublishedPropertyType propertyType,
IPublishedElement element, IPublishedElement element,
@@ -35,11 +48,11 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
: base(propertyType, referenceCacheLevel) : base(propertyType, referenceCacheLevel)
{ {
_sourceValue = sourceValue; _sourceValue = sourceValue;
Element = element; _element = element;
IsPreviewing = previewing; _isPreviewing = previewing;
_variationContext = variationContext; _variationContext = variationContext;
_cacheManager = cacheManager; _cacheManager = cacheManager;
IsMember = propertyType.ContentType?.ItemType == PublishedItemType.Member; _isMember = propertyType.ContentType?.ItemType == PublishedItemType.Member;
} }
// used to cache the CacheValues of this property // used to cache the CacheValues of this property
@@ -47,9 +60,11 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
private string ValuesCacheKey => _valuesCacheKey ??= PropertyCacheValuesKey(); private string ValuesCacheKey => _valuesCacheKey ??= PropertyCacheValuesKey();
private string PropertyCacheValuesKey() => private string PropertyCacheValuesKey() =>
$"PublishedSnapshot.Property.CacheValues[{(IsPreviewing ? "D:" : "P:")}{Element.Key}:{Alias}:{_variationContext.Culture.IfNullOrWhiteSpace("inv")}+{_variationContext.Segment.IfNullOrWhiteSpace("inv")}]"; $"PublishedSnapshot.Property.CacheValues[{(_isPreviewing ? "D:" : "P:")}{_element.Key}:{Alias}:{_variationContext.Culture.IfNullOrWhiteSpace("inv")}+{_variationContext.Segment.IfNullOrWhiteSpace("inv")}]";
// ReSharper restore InconsistentlySynchronizedField // ReSharper restore InconsistentlySynchronizedField
/// <inheritdoc />
public override bool HasValue(string? culture = null, string? segment = null) public override bool HasValue(string? culture = null, string? segment = null)
{ {
var hasValue = PropertyType.IsValue(_sourceValue, PropertyValueLevel.Source); var hasValue = PropertyType.IsValue(_sourceValue, PropertyValueLevel.Source);
@@ -60,7 +75,7 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
GetCacheLevels(out PropertyCacheLevel cacheLevel, out PropertyCacheLevel referenceCacheLevel); GetCacheLevels(out PropertyCacheLevel cacheLevel, out PropertyCacheLevel referenceCacheLevel);
lock (_locko) lock (_cacheLock)
{ {
var value = GetInterValue(); var value = GetInterValue();
hasValue = PropertyType.IsValue(value, PropertyValueLevel.Inter); hasValue = PropertyType.IsValue(value, PropertyValueLevel.Inter);
@@ -73,7 +88,7 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
if (!cacheValues.ObjectInitialized) if (!cacheValues.ObjectInitialized)
{ {
cacheValues.ObjectValue = cacheValues.ObjectValue =
PropertyType.ConvertInterToObject(Element, referenceCacheLevel, value, IsPreviewing); PropertyType.ConvertInterToObject(_element, referenceCacheLevel, value, _isPreviewing);
cacheValues.ObjectInitialized = true; cacheValues.ObjectInitialized = true;
} }
@@ -82,6 +97,7 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
} }
} }
/// <inheritdoc />
public override object? GetSourceValue(string? culture = null, string? segment = null) => _sourceValue; public override object? GetSourceValue(string? culture = null, string? segment = null) => _sourceValue;
private void GetCacheLevels(out PropertyCacheLevel cacheLevel, out PropertyCacheLevel referenceCacheLevel) private void GetCacheLevels(out PropertyCacheLevel cacheLevel, out PropertyCacheLevel referenceCacheLevel)
@@ -151,16 +167,17 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
return _interValue; return _interValue;
} }
_interValue = PropertyType.ConvertSourceToInter(Element, _sourceValue, IsPreviewing); _interValue = PropertyType.ConvertSourceToInter(_element, _sourceValue, _isPreviewing);
_interInitialized = true; _interInitialized = true;
return _interValue; return _interValue;
} }
/// <inheritdoc />
public override object? GetValue(string? culture = null, string? segment = null) public override object? GetValue(string? culture = null, string? segment = null)
{ {
GetCacheLevels(out PropertyCacheLevel cacheLevel, out PropertyCacheLevel referenceCacheLevel); GetCacheLevels(out PropertyCacheLevel cacheLevel, out PropertyCacheLevel referenceCacheLevel);
lock (_locko) lock (_cacheLock)
{ {
CacheValues cacheValues = GetCacheValues(cacheLevel); CacheValues cacheValues = GetCacheValues(cacheLevel);
if (cacheValues.ObjectInitialized) if (cacheValues.ObjectInitialized)
@@ -169,12 +186,13 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
} }
cacheValues.ObjectValue = cacheValues.ObjectValue =
PropertyType.ConvertInterToObject(Element, referenceCacheLevel, GetInterValue(), IsPreviewing); PropertyType.ConvertInterToObject(_element, referenceCacheLevel, GetInterValue(), _isPreviewing);
cacheValues.ObjectInitialized = true; cacheValues.ObjectInitialized = true;
return cacheValues.ObjectValue; return cacheValues.ObjectValue;
} }
} }
/// <inheritdoc />
public override object? GetDeliveryApiValue(bool expanding, string? culture = null, string? segment = null) public override object? GetDeliveryApiValue(bool expanding, string? culture = null, string? segment = null)
{ {
PropertyCacheLevel cacheLevel, referenceCacheLevel; PropertyCacheLevel cacheLevel, referenceCacheLevel;
@@ -187,11 +205,11 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
GetDeliveryApiCacheLevels(out cacheLevel, out referenceCacheLevel); GetDeliveryApiCacheLevels(out cacheLevel, out referenceCacheLevel);
} }
lock (_locko) lock (_cacheLock)
{ {
CacheValues cacheValues = GetCacheValues(cacheLevel); CacheValues cacheValues = GetCacheValues(cacheLevel);
object? GetDeliveryApiObject() => PropertyType.ConvertInterToDeliveryApiObject(Element, referenceCacheLevel, GetInterValue(), IsPreviewing, expanding); object? GetDeliveryApiObject() => PropertyType.ConvertInterToDeliveryApiObject(_element, referenceCacheLevel, GetInterValue(), _isPreviewing, expanding);
return expanding return expanding
? GetDeliveryApiExpandedObject(cacheValues, GetDeliveryApiObject) ? GetDeliveryApiExpandedObject(cacheValues, GetDeliveryApiObject)
: GetDeliveryApiDefaultObject(cacheValues, GetDeliveryApiObject); : GetDeliveryApiDefaultObject(cacheValues, GetDeliveryApiObject);
@@ -220,15 +238,15 @@ internal sealed class PublishedElementPropertyBase : PublishedPropertyBase
return cacheValues.DeliveryApiExpandedObjectValue; return cacheValues.DeliveryApiExpandedObjectValue;
} }
protected class CacheValues private class CacheValues
{ {
public bool ObjectInitialized; public bool ObjectInitialized { get; set; }
public object? ObjectValue; public object? ObjectValue { get; set; }
public bool XPathInitialized; public bool XPathInitialized { get; set; }
public object? XPathValue; public object? XPathValue { get; set; }
public bool DeliveryApiDefaultObjectInitialized; public bool DeliveryApiDefaultObjectInitialized { get; set; }
public object? DeliveryApiDefaultObjectValue; public object? DeliveryApiDefaultObjectValue { get; set; }
public bool DeliveryApiExpandedObjectInitialized; public bool DeliveryApiExpandedObjectInitialized { get; set; }
public object? DeliveryApiExpandedObjectValue; public object? DeliveryApiExpandedObjectValue { get; set; }
} }
} }
@@ -25,7 +25,7 @@ namespace Umbraco.Cms.Core.Cache;
internal sealed class FullDataSetRepositoryCachePolicy<TEntity, TId> : RepositoryCachePolicyBase<TEntity, TId> internal sealed class FullDataSetRepositoryCachePolicy<TEntity, TId> : RepositoryCachePolicyBase<TEntity, TId>
where TEntity : class, IEntity where TEntity : class, IEntity
{ {
protected static readonly TId[] EmptyIds = new TId[0]; // const private static readonly TId[] EmptyIds = new TId[0]; // const
private readonly Func<TEntity, TId> _entityGetId; private readonly Func<TEntity, TId> _entityGetId;
private readonly bool _expires; private readonly bool _expires;
@@ -54,9 +54,9 @@ internal sealed class FullDataSetRepositoryCachePolicy<TEntity, TId> : Repositor
} }
} }
protected string GetEntityTypeCacheKey() => RepositoryCacheKeys.GetKey<TEntity>(); private string GetEntityTypeCacheKey() => RepositoryCacheKeys.GetKey<TEntity>();
protected void InsertEntities(TEntity[]? entities) private void InsertEntities(TEntity[]? entities)
{ {
if (entities is null) if (entities is null)
{ {
@@ -1,4 +1,4 @@
using NPoco; using NPoco;
using Umbraco.Cms.Core; using Umbraco.Cms.Core;
using Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations; using Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations;
using Umbraco.Extensions; using Umbraco.Extensions;
@@ -122,7 +122,7 @@ internal sealed class PropertyDataDto
PropertyTypeDto = PropertyTypeDto, PropertyTypeDto = PropertyTypeDto,
}; };
protected bool Equals(PropertyDataDto other) => Id == other.Id; private bool Equals(PropertyDataDto other) => Id == other.Id;
public override bool Equals(object? other) => public override bool Equals(object? other) =>
!ReferenceEquals(null, other) // other is not null !ReferenceEquals(null, other) // other is not null
@@ -160,7 +160,7 @@ internal sealed class ContentTypeRepository : ContentTypeRepositoryBase<IContent
: Enumerable.Empty<IContentType>(); : Enumerable.Empty<IContentType>();
} }
protected IEnumerable<int> PerformGetByQuery(IQuery<PropertyType> query) private IEnumerable<int> PerformGetByQuery(IQuery<PropertyType> query)
{ {
// used by DataTypeService to remove properties // used by DataTypeService to remove properties
// from content types if they have a deleted data type - see // from content types if they have a deleted data type - see
@@ -272,7 +272,7 @@ internal sealed class ContentTypeRepository : ContentTypeRepositoryBase<IContent
entity.ResetDirtyProperties(); entity.ResetDirtyProperties();
} }
protected void PersistTemplates(IContentType entity, bool clearAll) private void PersistTemplates(IContentType entity, bool clearAll)
{ {
// remove and insert, if required // remove and insert, if required
Sql<ISqlContext> sql = Sql() Sql<ISqlContext> sql = Sql()
@@ -55,7 +55,7 @@ internal sealed class DataTypeRepository : EntityRepositoryBase<int, IDataType>,
_dataTypeLogger = loggerFactory.CreateLogger<IDataType>(); _dataTypeLogger = loggerFactory.CreateLogger<IDataType>();
} }
protected Guid NodeObjectTypeId => Constants.ObjectTypes.DataType; private Guid NodeObjectTypeId => Constants.ObjectTypes.DataType;
public IDataType? Get(Guid key) => GetMany().FirstOrDefault(x => x.Key == key); public IDataType? Get(Guid key) => GetMany().FirstOrDefault(x => x.Key == key);
@@ -194,7 +194,7 @@ internal sealed class DomainRepository : EntityRepositoryBase<int, IDomain>, IDo
entity.ResetDirtyProperties(); entity.ResetDirtyProperties();
} }
protected int GetNewSortOrder(int? rootContentId, bool isWildcard) private int GetNewSortOrder(int? rootContentId, bool isWildcard)
=> isWildcard => isWildcard
? -1 ? -1
: Database.ExecuteScalar<int>( : Database.ExecuteScalar<int>(
@@ -624,7 +624,7 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
#region Sql #region Sql
protected Sql<ISqlContext> GetVariantInfos(IEnumerable<int> ids) => private Sql<ISqlContext> GetVariantInfos(IEnumerable<int> ids) =>
Sql() Sql()
.Select<NodeDto>(x => x.NodeId) .Select<NodeDto>(x => x.NodeId)
.AndSelect<LanguageDto>(x => x.IsoCode) .AndSelect<LanguageDto>(x => x.IsoCode)
@@ -659,7 +659,7 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
.OrderBy<LanguageDto>(x => x.Id); .OrderBy<LanguageDto>(x => x.Id);
// gets the full sql for a given object type and a given unique id // gets the full sql for a given object type and a given unique id
protected Sql<ISqlContext> GetFullSqlForEntityType(bool isContent, bool isMedia, bool isMember, Guid objectType, private Sql<ISqlContext> GetFullSqlForEntityType(bool isContent, bool isMedia, bool isMember, Guid objectType,
Guid uniqueId) Guid uniqueId)
{ {
Sql<ISqlContext> sql = GetBaseWhere(isContent, isMedia, isMember, false, objectType, uniqueId); Sql<ISqlContext> sql = GetBaseWhere(isContent, isMedia, isMember, false, objectType, uniqueId);
@@ -667,7 +667,7 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
} }
// gets the full sql for a given object type and a given node id // gets the full sql for a given object type and a given node id
protected Sql<ISqlContext> GetFullSqlForEntityType(bool isContent, bool isMedia, bool isMember, Guid objectType, private Sql<ISqlContext> GetFullSqlForEntityType(bool isContent, bool isMedia, bool isMember, Guid objectType,
int nodeId) int nodeId)
{ {
Sql<ISqlContext> sql = GetBaseWhere(isContent, isMedia, isMember, false, objectType, nodeId); Sql<ISqlContext> sql = GetBaseWhere(isContent, isMedia, isMember, false, objectType, nodeId);
@@ -675,14 +675,14 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
} }
// gets the full sql for a given object type, with a given filter // gets the full sql for a given object type, with a given filter
protected Sql<ISqlContext> GetFullSqlForEntityType(bool isContent, bool isMedia, bool isMember, Guid objectType, private Sql<ISqlContext> GetFullSqlForEntityType(bool isContent, bool isMedia, bool isMember, Guid objectType,
Action<Sql<ISqlContext>>? filter) Action<Sql<ISqlContext>>? filter)
{ {
Sql<ISqlContext> sql = GetBaseWhere(isContent, isMedia, isMember, false, filter, new[] { objectType }); Sql<ISqlContext> sql = GetBaseWhere(isContent, isMedia, isMember, false, filter, new[] { objectType });
return AddGroupBy(isContent, isMedia, isMember, sql, true); return AddGroupBy(isContent, isMedia, isMember, sql, true);
} }
protected Sql<ISqlContext> GetFullSqlForEntityType( private Sql<ISqlContext> GetFullSqlForEntityType(
bool isContent, bool isContent,
bool isMedia, bool isMedia,
bool isMember, bool isMember,
@@ -691,7 +691,7 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
Action<Sql<ISqlContext>>? filter) Action<Sql<ISqlContext>>? filter)
=> GetFullSqlForEntityType(isContent, isMedia, isMember, [objectType], ordering, filter); => GetFullSqlForEntityType(isContent, isMedia, isMember, [objectType], ordering, filter);
protected Sql<ISqlContext> GetFullSqlForEntityType( private Sql<ISqlContext> GetFullSqlForEntityType(
bool isContent, bool isContent,
bool isMedia, bool isMedia,
bool isMember, bool isMember,
@@ -706,12 +706,12 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
return sql; return sql;
} }
protected Sql<ISqlContext> GetBase(bool isContent, bool isMedia, bool isMember, Action<Sql<ISqlContext>>? filter, bool isCount = false) private Sql<ISqlContext> GetBase(bool isContent, bool isMedia, bool isMember, Action<Sql<ISqlContext>>? filter, bool isCount = false)
=> GetBase(isContent, isMedia, isMember, filter, [], isCount); => GetBase(isContent, isMedia, isMember, filter, [], isCount);
// gets the base SELECT + FROM [+ filter] sql // gets the base SELECT + FROM [+ filter] sql
// always from the 'current' content version // always from the 'current' content version
protected Sql<ISqlContext> GetBase(bool isContent, bool isMedia, bool isMember, Action<Sql<ISqlContext>>? filter, Guid[] objectTypes, bool isCount = false) private Sql<ISqlContext> GetBase(bool isContent, bool isMedia, bool isMember, Action<Sql<ISqlContext>>? filter, Guid[] objectTypes, bool isCount = false)
{ {
Sql<ISqlContext> sql = Sql(); Sql<ISqlContext> sql = Sql();
ISqlSyntaxProvider syntax = SqlContext.SqlSyntax; ISqlSyntaxProvider syntax = SqlContext.SqlSyntax;
@@ -810,7 +810,7 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
// gets the base SELECT + FROM [+ filter] + WHERE sql // gets the base SELECT + FROM [+ filter] + WHERE sql
// for a given object type, with a given filter // for a given object type, with a given filter
protected Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, private Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount,
Action<Sql<ISqlContext>>? filter, Guid[] objectTypes) Action<Sql<ISqlContext>>? filter, Guid[] objectTypes)
{ {
Sql<ISqlContext> sql = GetBase(isContent, isMedia, isMember, filter, objectTypes, isCount); Sql<ISqlContext> sql = GetBase(isContent, isMedia, isMember, filter, objectTypes, isCount);
@@ -824,7 +824,7 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
// gets the base SELECT + FROM + WHERE sql // gets the base SELECT + FROM + WHERE sql
// for a given node id // for a given node id
protected Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, int id) private Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, int id)
{ {
Sql<ISqlContext> sql = GetBase(isContent, isMedia, isMember, null, isCount) Sql<ISqlContext> sql = GetBase(isContent, isMedia, isMember, null, isCount)
.Where<NodeDto>(x => x.NodeId == id); .Where<NodeDto>(x => x.NodeId == id);
@@ -833,7 +833,7 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
// gets the base SELECT + FROM + WHERE sql // gets the base SELECT + FROM + WHERE sql
// for a given unique id // for a given unique id
protected Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, Guid uniqueId) private Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, Guid uniqueId)
{ {
Sql<ISqlContext> sql = GetBase(isContent, isMedia, isMember, null, isCount) Sql<ISqlContext> sql = GetBase(isContent, isMedia, isMember, null, isCount)
.Where<NodeDto>(x => x.UniqueId == uniqueId); .Where<NodeDto>(x => x.UniqueId == uniqueId);
@@ -842,21 +842,21 @@ internal sealed class EntityRepository : RepositoryBase, IEntityRepositoryExtend
// gets the base SELECT + FROM + WHERE sql // gets the base SELECT + FROM + WHERE sql
// for a given object type and node id // for a given object type and node id
protected Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, Guid objectType, private Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, Guid objectType,
int nodeId) => int nodeId) =>
GetBase(isContent, isMedia, isMember, null, isCount) GetBase(isContent, isMedia, isMember, null, isCount)
.Where<NodeDto>(x => x.NodeId == nodeId && x.NodeObjectType == objectType); .Where<NodeDto>(x => x.NodeId == nodeId && x.NodeObjectType == objectType);
// gets the base SELECT + FROM + WHERE sql // gets the base SELECT + FROM + WHERE sql
// for a given object type and unique id // for a given object type and unique id
protected Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, Guid objectType, private Sql<ISqlContext> GetBaseWhere(bool isContent, bool isMedia, bool isMember, bool isCount, Guid objectType,
Guid uniqueId) => Guid uniqueId) =>
GetBase(isContent, isMedia, isMember, null, isCount) GetBase(isContent, isMedia, isMember, null, isCount)
.Where<NodeDto>(x => x.UniqueId == uniqueId && x.NodeObjectType == objectType); .Where<NodeDto>(x => x.UniqueId == uniqueId && x.NodeObjectType == objectType);
// gets the GROUP BY / ORDER BY sql // gets the GROUP BY / ORDER BY sql
// required in order to count children // required in order to count children
protected Sql<ISqlContext> AddGroupBy(bool isContent, bool isMedia, bool isMember, Sql<ISqlContext> sql, private Sql<ISqlContext> AddGroupBy(bool isContent, bool isMedia, bool isMember, Sql<ISqlContext> sql,
bool defaultSort) bool defaultSort)
{ {
sql sql
@@ -139,7 +139,7 @@ internal sealed class LanguageRepository : EntityRepositoryBase<int, ILanguage>,
protected override IRepositoryCachePolicy<ILanguage, int> CreateCachePolicy() => protected override IRepositoryCachePolicy<ILanguage, int> CreateCachePolicy() =>
new FullDataSetRepositoryCachePolicy<ILanguage, int>(GlobalIsolatedCache, ScopeAccessor, RepositoryCacheVersionService, CacheSyncService, GetEntityId, /*expires:*/ false); new FullDataSetRepositoryCachePolicy<ILanguage, int>(GlobalIsolatedCache, ScopeAccessor, RepositoryCacheVersionService, CacheSyncService, GetEntityId, /*expires:*/ false);
protected ILanguage ConvertFromDto(LanguageDto dto) private ILanguage ConvertFromDto(LanguageDto dto)
{ {
lock (_codeIdMap) lock (_codeIdMap)
{ {
@@ -34,7 +34,7 @@ internal sealed class MemberGroupRepository : EntityRepositoryBase<int, IMemberG
cacheSyncService) => cacheSyncService) =>
_eventMessagesFactory = eventMessagesFactory; _eventMessagesFactory = eventMessagesFactory;
protected Guid NodeObjectTypeId => Constants.ObjectTypes.MemberGroup; private Guid NodeObjectTypeId => Constants.ObjectTypes.MemberGroup;
public IMemberGroup? Get(Guid uniqueId) public IMemberGroup? Get(Guid uniqueId)
{ {
@@ -123,7 +123,7 @@ internal sealed class MemberTypeRepository : ContentTypeRepositoryBase<IMemberTy
return sql; return sql;
} }
protected Sql<ISqlContext> GetSubquery() private Sql<ISqlContext> GetSubquery()
{ {
Sql<ISqlContext> sql = Sql() Sql<ISqlContext> sql = Sql()
.Select($"DISTINCT({QuoteTableName("umbracoNode")}.id)") .Select($"DISTINCT({QuoteTableName("umbracoNode")}.id)")
@@ -13,7 +13,7 @@ internal sealed class PartialViewRepository : FileRepository<string, IPartialVie
{ {
} }
protected PartialViewRepository(IFileSystem? fileSystem) private PartialViewRepository(IFileSystem? fileSystem)
: base(fileSystem) : base(fileSystem)
{ {
} }
@@ -401,7 +401,7 @@ internal sealed class TemplateRepository : EntityRepositoryBase<int, ITemplate>,
return list; return list;
} }
protected Guid NodeObjectTypeId => Constants.ObjectTypes.Template; private Guid NodeObjectTypeId => Constants.ObjectTypes.Template;
protected override void PersistNewItem(ITemplate entity) protected override void PersistNewItem(ITemplate entity)
{ {
@@ -48,7 +48,7 @@ internal sealed class PublishedRequestFilterAttribute : ResultFilterAttribute
/// <summary> /// <summary>
/// Gets the <see cref="UmbracoRouteValues" /> /// Gets the <see cref="UmbracoRouteValues" />
/// </summary> /// </summary>
protected static UmbracoRouteValues GetUmbracoRouteValues(ResultExecutingContext context) private static UmbracoRouteValues GetUmbracoRouteValues(ResultExecutingContext context)
{ {
UmbracoRouteValues? routeVals = context.HttpContext.Features.Get<UmbracoRouteValues>(); UmbracoRouteValues? routeVals = context.HttpContext.Features.Get<UmbracoRouteValues>();
if (routeVals == null) if (routeVals == null)
@@ -21,11 +21,11 @@ internal sealed class DocumentUrlServiceTests : UmbracoIntegrationTestWithConten
private const string SubSubPage2Key = "48AE405E-5142-4EBE-929F-55EB616F51F2"; private const string SubSubPage2Key = "48AE405E-5142-4EBE-929F-55EB616F51F2";
private const string SubSubPage3Key = "AACF2979-3F53-4184-B071-BA34D3338497"; private const string SubSubPage3Key = "AACF2979-3F53-4184-B071-BA34D3338497";
protected IDocumentUrlService DocumentUrlService => GetRequiredService<IDocumentUrlService>(); private IDocumentUrlService DocumentUrlService => GetRequiredService<IDocumentUrlService>();
protected ILanguageService LanguageService => GetRequiredService<ILanguageService>(); private ILanguageService LanguageService => GetRequiredService<ILanguageService>();
protected IDomainService DomainService => GetRequiredService<IDomainService>(); private IDomainService DomainService => GetRequiredService<IDomainService>();
protected override void CustomTestSetup(IUmbracoBuilder builder) protected override void CustomTestSetup(IUmbracoBuilder builder)
{ {
@@ -17,8 +17,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console)] [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console)]
internal sealed class DocumentUrlServiceTests_HideTopLevel_False : UmbracoIntegrationTestWithContent internal sealed class DocumentUrlServiceTests_HideTopLevel_False : UmbracoIntegrationTestWithContent
{ {
protected IDocumentUrlService DocumentUrlService => GetRequiredService<IDocumentUrlService>(); private IDocumentUrlService DocumentUrlService => GetRequiredService<IDocumentUrlService>();
protected ILanguageService LanguageService => GetRequiredService<ILanguageService>(); private ILanguageService LanguageService => GetRequiredService<ILanguageService>();
protected override void CustomTestSetup(IUmbracoBuilder builder) protected override void CustomTestSetup(IUmbracoBuilder builder)
{ {
@@ -37,11 +37,11 @@ internal sealed class DynamicRootServiceTests : UmbracoIntegrationTest
FurthestDescendantOrSelf, FurthestDescendantOrSelf,
} }
protected IContentTypeService ContentTypeService => GetRequiredService<IContentTypeService>(); private IContentTypeService ContentTypeService => GetRequiredService<IContentTypeService>();
protected IFileService FileService => GetRequiredService<IFileService>(); private IFileService FileService => GetRequiredService<IFileService>();
protected ContentService ContentService => (ContentService)GetRequiredService<IContentService>(); private ContentService ContentService => (ContentService)GetRequiredService<IContentService>();
private DynamicRootService DynamicRootService => (GetRequiredService<IDynamicRootService>() as DynamicRootService)!; private DynamicRootService DynamicRootService => (GetRequiredService<IDynamicRootService>() as DynamicRootService)!;
@@ -14,13 +14,13 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)] [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
internal sealed class MediaEditingServiceTests : UmbracoIntegrationTest internal sealed class MediaEditingServiceTests : UmbracoIntegrationTest
{ {
protected IMediaTypeService MediaTypeService => GetRequiredService<IMediaTypeService>(); private IMediaTypeService MediaTypeService => GetRequiredService<IMediaTypeService>();
protected IMediaEditingService MediaEditingService => GetRequiredService<IMediaEditingService>(); private IMediaEditingService MediaEditingService => GetRequiredService<IMediaEditingService>();
protected IMediaType ImageMediaType { get; set; } private IMediaType ImageMediaType { get; set; }
protected IMediaType ArticleMediaType { get; set; } private IMediaType ArticleMediaType { get; set; }
[SetUp] [SetUp]
public async Task Setup() public async Task Setup()
@@ -21,7 +21,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence;
internal sealed class LocksTests : UmbracoIntegrationTest internal sealed class LocksTests : UmbracoIntegrationTest
{ {
[SetUp] [SetUp]
protected void SetUp() public void SetUp()
{ {
// create a few lock objects // create a few lock objects
using (var scope = ScopeProvider.CreateScope()) using (var scope = ScopeProvider.CreateScope())
@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
internal sealed class NPocoFetchTests : UmbracoIntegrationTest internal sealed class NPocoFetchTests : UmbracoIntegrationTest
{ {
[SetUp] [SetUp]
protected void SeedDatabase() public void SeedDatabase()
{ {
using (var scope = ScopeProvider.CreateScope()) using (var scope = ScopeProvider.CreateScope())
{ {
@@ -342,7 +342,7 @@ internal sealed class ScriptRepositoryTest : UmbracoIntegrationTest
} }
} }
protected Stream CreateStream(string contents = null) private Stream CreateStream(string contents = null)
{ {
if (string.IsNullOrEmpty(contents)) if (string.IsNullOrEmpty(contents))
{ {
@@ -362,7 +362,7 @@ internal sealed class StylesheetRepositoryTest : UmbracoIntegrationTest
} }
} }
protected Stream CreateStream(string contents = null) private Stream CreateStream(string contents = null)
{ {
if (string.IsNullOrEmpty(contents)) if (string.IsNullOrEmpty(contents))
{ {
@@ -568,7 +568,7 @@ internal sealed class TemplateRepositoryTest : UmbracoIntegrationTest
} }
} }
protected Stream CreateStream(string contents = null) private Stream CreateStream(string contents = null)
{ {
if (string.IsNullOrEmpty(contents)) if (string.IsNullOrEmpty(contents))
{ {
@@ -28,15 +28,15 @@ internal sealed class ContentServicePerformanceTest : UmbracoIntegrationTest
[SetUp] [SetUp]
public void SetUpData() => CreateTestData(); public void SetUpData() => CreateTestData();
protected DocumentRepository DocumentRepository => (DocumentRepository)GetRequiredService<IDocumentRepository>(); private DocumentRepository DocumentRepository => (DocumentRepository)GetRequiredService<IDocumentRepository>();
protected IFileService FileService => GetRequiredService<IFileService>(); private IFileService FileService => GetRequiredService<IFileService>();
protected IContentTypeService ContentTypeService => GetRequiredService<IContentTypeService>(); private IContentTypeService ContentTypeService => GetRequiredService<IContentTypeService>();
protected IContentService ContentService => GetRequiredService<IContentService>(); private IContentService ContentService => GetRequiredService<IContentService>();
protected IContentType ContentType { get; set; } private IContentType ContentType { get; set; }
[Test] [Test]
public void Profiler() => Assert.IsInstanceOf<TestProfiler>(GetRequiredService<IProfiler>()); public void Profiler() => Assert.IsInstanceOf<TestProfiler>(GetRequiredService<IProfiler>());
@@ -32,7 +32,7 @@ internal sealed class EFCoreLockTests : UmbracoIntegrationTest
} }
[SetUp] [SetUp]
protected async Task SetUp() public async Task SetUp()
{ {
// create a few lock objects // create a few lock objects
using var scope = EFScopeProvider.CreateScope(); using var scope = EFScopeProvider.CreateScope();