v14: Align Deploy interfaces, remove obsolete methods and default interface implementations (#15965)
* Align FromArtifact return type with IDataType.ConfigurationData * Align Alias nullability with interface * Lazily initialize ArtifactDependency collection when not set * Remove ShouldSerializeChecksum (not used by STJ) * Remove obsolete methods and default interface implementations * Order dependencies once when setting collection * Update test to include artifact Checksum property
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Umbraco.Cms.Core.Deploy;
|
||||
public abstract class ArtifactBase<TUdi> : IArtifact
|
||||
where TUdi : Udi
|
||||
{
|
||||
private IEnumerable<ArtifactDependency> _dependencies;
|
||||
private IEnumerable<ArtifactDependency>? _dependencies;
|
||||
private readonly Lazy<string> _checksum;
|
||||
|
||||
/// <summary>
|
||||
@@ -20,7 +20,7 @@ public abstract class ArtifactBase<TUdi> : IArtifact
|
||||
Udi = udi ?? throw new ArgumentNullException(nameof(udi));
|
||||
Name = Udi.ToString();
|
||||
|
||||
_dependencies = dependencies ?? Enumerable.Empty<ArtifactDependency>();
|
||||
_dependencies = dependencies;
|
||||
_checksum = new Lazy<string>(GetChecksum);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public abstract class ArtifactBase<TUdi> : IArtifact
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ArtifactDependency> Dependencies
|
||||
{
|
||||
get => _dependencies;
|
||||
set => _dependencies = value.OrderBy(x => x.Udi);
|
||||
get => _dependencies ??= Array.Empty<ArtifactDependency>();
|
||||
set => _dependencies = value.OrderBy(x => x.Udi).ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -44,7 +44,7 @@ public abstract class ArtifactBase<TUdi> : IArtifact
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Alias { get; set; } = string.Empty;
|
||||
public string? Alias { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the checksum.
|
||||
@@ -53,17 +53,4 @@ public abstract class ArtifactBase<TUdi> : IArtifact
|
||||
/// The checksum.
|
||||
/// </returns>
|
||||
protected abstract string GetChecksum();
|
||||
|
||||
/// <summary>
|
||||
/// Prevents the <see cref="Checksum" /> property from being serialized.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Returns <c>false</c> to prevent the property from being serialized.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// Note that we can't use <see cref="NonSerializedAttribute" /> here as that works only on fields, not properties. And we want to avoid using [JsonIgnore]
|
||||
/// as that would require an external dependency in Umbraco.Cms.Core.
|
||||
/// So using this method of excluding properties from serialized data, documented here: https://www.newtonsoft.com/json/help/html/ConditionalProperties.htm
|
||||
/// </remarks>
|
||||
public bool ShouldSerializeChecksum() => false;
|
||||
}
|
||||
|
||||
@@ -39,5 +39,5 @@ public interface IDataTypeConfigurationConnector
|
||||
/// <returns>
|
||||
/// The data type configuration.
|
||||
/// </returns>
|
||||
object? FromArtifact(IDataType dataType, string? configuration, IContextCache contextCache);
|
||||
IDictionary<string, object> FromArtifact(IDataType dataType, string? configuration, IContextCache contextCache);
|
||||
}
|
||||
|
||||
@@ -53,9 +53,4 @@ public interface IDeployContext
|
||||
/// </returns>
|
||||
T? Item<T>(string key)
|
||||
where T : class;
|
||||
|
||||
///// <summary>
|
||||
///// Gets the global deployment cancellation token.
|
||||
///// </summary>
|
||||
// CancellationToken CancellationToken { get; }
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ArtifactBaseTests
|
||||
var serialized = JsonConvert.SerializeObject(artifact);
|
||||
|
||||
var expected =
|
||||
"{\"Udi\":\"umb://test/3382d5433b5749d08919bc9961422a1f\",\"Dependencies\":[],\"Name\":\"Test Name\",\"Alias\":\"testAlias\"}";
|
||||
"{\"Udi\":\"umb://test/3382d5433b5749d08919bc9961422a1f\",\"Dependencies\":[],\"Checksum\":\"test checksum value\",\"Name\":\"Test Name\",\"Alias\":\"testAlias\"}";
|
||||
Assert.AreEqual(expected, serialized);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user