Skip to content

Commit 403fa73

Browse files
committed
Marked DefaultConfiguration members as [Obsolete]
The `DefaultConfiguration` (and related `Configuration` and `GetConfigurationValue()` members) is a left-over of the legacy `AttributeDescriptor` model where attribute type configuration values were configured as a delimited string in an attribute. This is still required for backward compatibility with the legacy **ASP.NET WebForms** editor. The new **ASP.NET Core** editor does not use this, instead relying on the new `AttributeTypeDescriptor` classes, which provide direct access to each configuration value via the standard `Attributes.GetValue()` approach.
1 parent c53ff45 commit 403fa73

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

Ignia.Topics.Tests/TopicMappingServiceTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,15 +639,13 @@ public async Task MapCompatibleProperties() {
639639
var mappingService = new TopicMappingService(_topicRepository, new FakeViewModelLookupService());
640640
var topic = (AttributeDescriptor)TopicFactory.Create("Attribute", "AttributeDescriptor");
641641

642-
topic.DefaultConfiguration = "Value1=1&Value2=2";
643642
topic.EditorType = "TopicList";
644643

645644
topic.VersionHistory.Add(new DateTime(1976, 10, 15, 9, 30, 00));
646645

647646
var target = (CompatiblePropertyTopicViewModel?)await mappingService.MapAsync<CompatiblePropertyTopicViewModel>(topic).ConfigureAwait(false);
648647

649648
Assert.AreEqual<ModelType>(topic.ModelType, target.ModelType);
650-
Assert.AreEqual<IDictionary<string, string?>>(topic.Configuration, target.Configuration);
651649
Assert.AreEqual<int>(1, target.VersionHistory.Count);
652650

653651
}

Ignia.Topics.Tests/TopicTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ public void DerivedTopic() {
273273
[TestMethod]
274274
public void AttributeConfiguration() {
275275

276+
#pragma warning disable CS0618 // Type or member is obsolete
277+
276278
var attribute = (AttributeDescriptor)TopicFactory.Create("Topic", "AttributeDescriptor");
277279
attribute.DefaultConfiguration = "IsRequired=\"True\" DisplayName=\"Display Name\"";
278280

@@ -284,6 +286,8 @@ public void AttributeConfiguration() {
284286
Assert.ReferenceEquals("True", attribute.GetConfigurationValue("DisplayName"));
285287
Assert.ReferenceEquals("NotFound", attribute.GetConfigurationValue("MissingAttribute", "NotFound"));
286288

289+
#pragma warning restore CS0618 // Type or member is obsolete
290+
287291
}
288292

289293
} //Class

Ignia.Topics/Metadata/AttributeDescriptor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ public string? DisplayGroup {
215215
/// User Controls as well as AngularJS Directives, the format is Property1="Value" Propert2="Value".
216216
/// </para>
217217
/// </remarks>
218+
[Obsolete(
219+
"The DefaultConfiguration property is exclusively provided for backward compatibility with the legacy ASP.NET WebForms " +
220+
"version of the OnTopic Editor. New implementations should use the new strongly typed AttributeTypeDescriptor model " +
221+
"instead."
222+
)]
218223
public string DefaultConfiguration {
219224
get => Attributes.GetValue("DefaultConfiguration", "")?? "";
220225
set {
@@ -230,6 +235,11 @@ public string DefaultConfiguration {
230235
/// Retrieves a dictionary representing a parsed collection of key/value pairs from the
231236
/// <see cref="DefaultConfiguration"/>.
232237
/// </summary>
238+
[Obsolete(
239+
"The Configuration property is exclusively provided for backward compatibility with the legacy ASP.NET WebForms " +
240+
"version of the OnTopic Editor. New implementations should use the new strongly typed AttributeTypeDescriptor model " +
241+
"instead."
242+
)]
233243
public IDictionary<string, string?> Configuration {
234244
get {
235245
if (_configuration.Count.Equals(0) && DefaultConfiguration.Length > 0) {
@@ -252,6 +262,11 @@ public string DefaultConfiguration {
252262
/// Retrieves a configuration value from the <see cref="Configuration"/> dictionary; if the value doesn't exist, then
253263
/// optionally returns a default value.
254264
/// </summary>
265+
[Obsolete(
266+
"The GetConfigurationValue method is exclusively provided for backward compatibility with the legacy ASP.NET WebForms " +
267+
"version of the OnTopic Editor. New implementations should use the new strongly typed AttributeTypeDescriptor model " +
268+
"instead."
269+
)]
255270
public string? GetConfigurationValue(string key, string? defaultValue = null) {
256271
Contract.Requires(!String.IsNullOrWhiteSpace(key));
257272
if (Configuration.ContainsKey(key) && Configuration[key] != null) {

0 commit comments

Comments
 (0)