diff --git a/src/Umbraco.Core/CompatibilitySuppressions.xml b/src/Umbraco.Core/CompatibilitySuppressions.xml index 3c3c61eba5..8ebf513b60 100644 --- a/src/Umbraco.Core/CompatibilitySuppressions.xml +++ b/src/Umbraco.Core/CompatibilitySuppressions.xml @@ -533,6 +533,13 @@ lib/net7.0/Umbraco.Core.dll true + + CP0002 + M:Umbraco.Cms.Core.Models.PublishedContent.PublishedDataType.get_Configuration + lib/net7.0/Umbraco.Core.dll + lib/net7.0/Umbraco.Core.dll + true + CP0002 M:Umbraco.Cms.Core.Models.RelationType.#ctor(System.String,System.String,System.Boolean,System.Nullable{System.Guid},System.Nullable{System.Guid},System.Boolean) @@ -680,6 +687,20 @@ lib/net7.0/Umbraco.Core.dll true + + CP0002 + M:Umbraco.Cms.Core.PropertyEditors.DataValueEditor.get_Configuration + lib/net7.0/Umbraco.Core.dll + lib/net7.0/Umbraco.Core.dll + true + + + CP0002 + M:Umbraco.Cms.Core.PropertyEditors.DataValueEditor.set_Configuration(System.Object) + lib/net7.0/Umbraco.Core.dll + lib/net7.0/Umbraco.Core.dll + true + CP0002 M:Umbraco.Cms.Core.PropertyEditors.IConfigurationEditor.FromConfigurationEditor(System.Collections.Generic.IDictionary{System.String,System.Object},System.Object) @@ -1464,4 +1485,4 @@ lib/net7.0/Umbraco.Core.dll true - \ No newline at end of file + diff --git a/src/Umbraco.Core/Models/Mapping/ContentPropertyDisplayMapper.cs b/src/Umbraco.Core/Models/Mapping/ContentPropertyDisplayMapper.cs index 0a182968f9..a090caa848 100644 --- a/src/Umbraco.Core/Models/Mapping/ContentPropertyDisplayMapper.cs +++ b/src/Umbraco.Core/Models/Mapping/ContentPropertyDisplayMapper.cs @@ -36,9 +36,7 @@ internal class ContentPropertyDisplayMapper : ContentPropertyBasicMapper - /// Gets the data type configuration. + /// Gets the data type configuration object. /// - public object? Configuration => _lazyConfiguration?.Value; + /// + public object? ConfigurationObject => _lazyConfiguration?.Value; /// /// Gets the configuration object. @@ -51,7 +52,7 @@ public class PublishedDataType public T? ConfigurationAs() where T : class { - switch (Configuration) + switch (ConfigurationObject) { case null: return null; @@ -60,6 +61,6 @@ public class PublishedDataType } throw new InvalidCastException( - $"Cannot cast dataType configuration, of type {Configuration.GetType().Name}, to {typeof(T).Name}."); + $"Cannot cast dataType configuration, of type {ConfigurationObject.GetType().Name}, to {typeof(T).Name}."); } } diff --git a/src/Umbraco.Core/PropertyEditors/DataEditor.cs b/src/Umbraco.Core/PropertyEditors/DataEditor.cs index 3009e8af62..c1d0495464 100644 --- a/src/Umbraco.Core/PropertyEditors/DataEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DataEditor.cs @@ -149,7 +149,7 @@ public class DataEditor : IDataEditor /// simple enough for now. /// /// - public virtual IDataValueEditor GetValueEditor(object? configuration) + public virtual IDataValueEditor GetValueEditor(object? configurationObject) { // if an explicit value editor has been set (by the manifest parser) // then return it, and ignore the configuration, which is going to be @@ -160,9 +160,9 @@ public class DataEditor : IDataEditor } IDataValueEditor editor = CreateValueEditor(); - if (configuration is not null) + if (configurationObject is not null) { - ((DataValueEditor)editor).Configuration = configuration; // TODO: casting is bad + ((DataValueEditor)editor).ConfigurationObject = configurationObject; // TODO: casting is bad } return editor; diff --git a/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs index 3be0f4f122..5f8b33c257 100644 --- a/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs @@ -77,7 +77,8 @@ public class DataValueEditor : IDataValueEditor /// /// Gets or sets the value editor configuration. /// - public virtual object? Configuration { get; set; } + /// + public virtual object? ConfigurationObject { get; set; } public bool SupportsReadOnly { get; set; } @@ -120,7 +121,7 @@ public class DataValueEditor : IDataValueEditor public IEnumerable Validate(object? value, bool required, string? format) { List? results = null; - var r = Validators.SelectMany(v => v.Validate(value, ValueType, Configuration)).ToList(); + var r = Validators.SelectMany(v => v.Validate(value, ValueType, ConfigurationObject)).ToList(); if (r.Any()) { results = r; diff --git a/src/Umbraco.Core/PropertyEditors/IDataEditor.cs b/src/Umbraco.Core/PropertyEditors/IDataEditor.cs index 0569f8ab9a..3c05169735 100644 --- a/src/Umbraco.Core/PropertyEditors/IDataEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/IDataEditor.cs @@ -63,7 +63,7 @@ public interface IDataEditor : IDiscoverable /// /// Gets a configured value editor. /// - IDataValueEditor GetValueEditor(object? configuration); + IDataValueEditor GetValueEditor(object? configurationObject); /// /// Gets an editor to edit the value editor configuration. diff --git a/src/Umbraco.Core/PropertyEditors/MissingPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/MissingPropertyEditor.cs index c256c7b483..560795dfb5 100644 --- a/src/Umbraco.Core/PropertyEditors/MissingPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/MissingPropertyEditor.cs @@ -28,5 +28,5 @@ public class MissingPropertyEditor : IDataEditor public IDataValueEditor GetValueEditor() => throw new NotImplementedException(); - public IDataValueEditor GetValueEditor(object? configuration) => throw new NotImplementedException(); + public IDataValueEditor GetValueEditor(object? configurationObject) => throw new NotImplementedException(); } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs index 81f163745a..dc82051928 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs @@ -21,7 +21,7 @@ public class LabelValueConverter : PropertyValueConverterBase public override Type GetPropertyValueType(IPublishedPropertyType propertyType) { LabelConfiguration? valueType = - ConfigurationEditor.ConfigurationAs(propertyType.DataType.Configuration); + ConfigurationEditor.ConfigurationAs(propertyType.DataType.ConfigurationObject); switch (valueType?.ValueType) { case ValueTypes.DateTime: @@ -46,7 +46,7 @@ public class LabelValueConverter : PropertyValueConverterBase public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object? source, bool preview) { LabelConfiguration? valueType = - ConfigurationEditor.ConfigurationAs(propertyType.DataType.Configuration); + ConfigurationEditor.ConfigurationAs(propertyType.DataType.ConfigurationObject); switch (valueType?.ValueType) { case ValueTypes.DateTime: diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs index 1d6792f185..c4715d5aad 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs @@ -78,7 +78,7 @@ public class MediaPickerValueConverter : PropertyValueConverterBase, IDeliveryAp private bool IsMultipleDataType(PublishedDataType dataType) { MediaPickerConfiguration? config = - ConfigurationEditor.ConfigurationAs(dataType.Configuration); + ConfigurationEditor.ConfigurationAs(dataType.ConfigurationObject); return config?.Multiple ?? false; } diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs index 0ad1f44cba..6141a2eadf 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs @@ -311,7 +311,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement continue; // not implementing IDataValueTags, continue } - object? configuration = DataTypeService.GetDataType(property.PropertyType.DataTypeId)?.ConfigurationObject; + object? configurationObject = DataTypeService.GetDataType(property.PropertyType.DataTypeId)?.ConfigurationObject; if (property.PropertyType.VariesByCulture()) { @@ -319,14 +319,14 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement foreach (IPropertyValue pvalue in property.Values) { var languageId = LanguageRepository.GetIdByIsoCode(pvalue.Culture); - tags.AddRange(tagsProvider.GetTags(pvalue.EditedValue, configuration, languageId)); + tags.AddRange(tagsProvider.GetTags(pvalue.EditedValue, configurationObject, languageId)); } tagRepo.Assign(entity.Id, property.PropertyTypeId, tags); } else { - IEnumerable tags = tagsProvider.GetTags(property.GetValue(), configuration, null); + IEnumerable tags = tagsProvider.GetTags(property.GetValue(), configurationObject, null); tagRepo.Assign(entity.Id, property.PropertyTypeId, tags); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs index a996703fd7..1771ca9068 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs @@ -105,9 +105,9 @@ internal abstract class BlockEditorPropertyValueEditor : DataVa continue; } - object? configuration = _dataTypeService.GetDataType(prop.Value.PropertyType.DataTypeKey)?.ConfigurationObject; + object? configurationObject = _dataTypeService.GetDataType(prop.Value.PropertyType.DataTypeKey)?.ConfigurationObject; - result.AddRange(tagsProvider.GetTags(prop.Value.Value, configuration, languageId)); + result.AddRange(tagsProvider.GetTags(prop.Value.Value, configurationObject, languageId)); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs index 96cc288b77..530e69ff05 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs @@ -116,9 +116,9 @@ public class NestedContentPropertyEditor : DataEditor } /// - public override object? Configuration + public override object? ConfigurationObject { - get => base.Configuration; + get => base.ConfigurationObject; set { if (value == null) @@ -133,7 +133,7 @@ public class NestedContentPropertyEditor : DataEditor nameof(value)); } - base.Configuration = value; + base.ConfigurationObject = value; HideLabel = configuration.HideLabel.TryConvertTo().Result; } @@ -190,9 +190,9 @@ public class NestedContentPropertyEditor : DataEditor continue; } - object? configuration = _dataTypeService.GetDataType(prop.Value.PropertyType.DataTypeKey)?.ConfigurationObject; + object? configurationObject = _dataTypeService.GetDataType(prop.Value.PropertyType.DataTypeKey)?.ConfigurationObject; - result.AddRange(tagsProvider.GetTags(prop.Value.Value, configuration, languageId)); + result.AddRange(tagsProvider.GetTags(prop.Value.Value, configurationObject, languageId)); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs index 3e0bf324a6..fee03896f9 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs @@ -193,9 +193,9 @@ public class RichTextPropertyEditor : DataEditor } /// - public override object? Configuration + public override object? ConfigurationObject { - get => base.Configuration; + get => base.ConfigurationObject; set { if (value == null) @@ -210,7 +210,7 @@ public class RichTextPropertyEditor : DataEditor nameof(value)); } - base.Configuration = value; + base.ConfigurationObject = value; HideLabel = configuration.HideLabel; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/BlockListPropertyValueConverter.cs b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/BlockListPropertyValueConverter.cs index d67197897c..71e3f671b1 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/BlockListPropertyValueConverter.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/BlockListPropertyValueConverter.cs @@ -63,7 +63,7 @@ public class BlockListPropertyValueConverter : BlockPropertyValueConverterBase(propertyType.DataType.Configuration)?.Blocks.FirstOrDefault(); + ConfigurationEditor.ConfigurationAs(propertyType.DataType.ConfigurationObject)?.Blocks.FirstOrDefault(); ModelType? contentElementType = block?.ContentElementTypeKey is Guid contentElementTypeKey && _contentTypeService.Get(contentElementTypeKey) is IContentType contentType ? ModelType.For(contentType.Alias) : null; ModelType? settingsElementType = block?.SettingsElementTypeKey is Guid settingsElementTypeKey && _contentTypeService.Get(settingsElementTypeKey) is IContentType settingsType ? ModelType.For(settingsType.Alias) : null; @@ -87,7 +87,7 @@ public class BlockListPropertyValueConverter : BlockPropertyValueConverterBase(dataType.Configuration); + ConfigurationEditor.ConfigurationAs(dataType.ConfigurationObject); return (config?.UseSingleBlockMode ?? false) && config?.Blocks.Length == 1 && config?.ValidationLimit?.Min == 1 && config?.ValidationLimit?.Max == 1; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs index 015f28b8eb..69c1331c24 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs @@ -57,7 +57,7 @@ public class ColorPickerValueConverter : PropertyValueConverterBase } private bool UseLabel(IPublishedPropertyType propertyType) => ConfigurationEditor - .ConfigurationAs(propertyType.DataType.Configuration)?.UseLabel ?? false; + .ConfigurationAs(propertyType.DataType.ConfigurationObject)?.UseLabel ?? false; public class PickedColor { diff --git a/tests/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs b/tests/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs index 7be75d36f5..e6e99c8ca7 100644 --- a/tests/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs +++ b/tests/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs @@ -59,7 +59,7 @@ public class DataValueEditorBuilder : ChildBuilderBase(), Mock.Of()) { - Configuration = configuration, + ConfigurationObject = configuration, View = view, HideLabel = hideLabel, ValueType = valueType diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/ValueEditorCacheTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/ValueEditorCacheTests.cs index 5bf72b8500..784520cce4 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/ValueEditorCacheTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/ValueEditorCacheTests.cs @@ -124,7 +124,7 @@ public class ValueEditorCacheTests return Mock.Of(); } - public IDataValueEditor GetValueEditor(object configuration) => GetValueEditor(); + public IDataValueEditor GetValueEditor(object configurationObject) => GetValueEditor(); public IDictionary DefaultConfiguration { get; } diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs index d88a9689ab..c425e26254 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs @@ -78,10 +78,10 @@ public class DataValueEditorReuseTests // no matter what, a property editor should never reuse its data value editor when created *with* configuration var dataValueEditor1 = textboxPropertyEditor.GetValueEditor("config"); Assert.NotNull(dataValueEditor1); - Assert.AreEqual("config", ((DataValueEditor)dataValueEditor1).Configuration); + Assert.AreEqual("config", ((DataValueEditor)dataValueEditor1).ConfigurationObject); var dataValueEditor2 = textboxPropertyEditor.GetValueEditor("config"); Assert.NotNull(dataValueEditor2); - Assert.AreEqual("config", ((DataValueEditor)dataValueEditor2).Configuration); + Assert.AreEqual("config", ((DataValueEditor)dataValueEditor2).ConfigurationObject); Assert.AreNotSame(dataValueEditor1, dataValueEditor2); _dataValueEditorFactoryMock.Verify( m => m.Create(It.IsAny()), @@ -122,10 +122,10 @@ public class DataValueEditorReuseTests // no matter what, a property editor should never reuse its data value editor when created *with* configuration var dataValueEditor1 = blockListPropertyEditor.GetValueEditor("config"); Assert.NotNull(dataValueEditor1); - Assert.AreEqual("config", ((DataValueEditor)dataValueEditor1).Configuration); + Assert.AreEqual("config", ((DataValueEditor)dataValueEditor1).ConfigurationObject); var dataValueEditor2 = blockListPropertyEditor.GetValueEditor("config"); Assert.NotNull(dataValueEditor2); - Assert.AreEqual("config", ((DataValueEditor)dataValueEditor2).Configuration); + Assert.AreEqual("config", ((DataValueEditor)dataValueEditor2).ConfigurationObject); Assert.AreNotSame(dataValueEditor1, dataValueEditor2); _dataValueEditorFactoryMock.Verify( m => m.Create(It.IsAny()), diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs index b037a6db65..eaf8661041 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs @@ -77,7 +77,7 @@ public class MultiValuePropertyEditorTests prop.SetValue("Value 1,Value 2,Value 3"); var valueEditor = dataType.Editor.GetValueEditor(); - ((DataValueEditor)valueEditor).Configuration = dataType.ConfigurationObject; + ((DataValueEditor)valueEditor).ConfigurationObject = dataType.ConfigurationObject; var result = valueEditor.ConvertDbToString(prop.PropertyType, prop.GetValue()); Assert.AreEqual("Value 1,Value 2,Value 3", result);