Revert "Store Description value of ConfigurationProperty" (dotnet/corefx#41848)
authorViktor Hofer <viktor.hofer@microsoft.com>
Thu, 17 Oct 2019 11:31:16 +0000 (13:31 +0200)
committermsftbot[bot] <48340428+msftbot[bot]@users.noreply.github.com>
Thu, 17 Oct 2019 11:31:16 +0000 (11:31 +0000)
This reverts commit dotnet/corefx@b9186cfa3566ee24e5f16e45c542a3078e128dc6.

Commit migrated from https://github.com/dotnet/corefx/commit/f9233ab726031451edce2b95c02f51fc09960132

src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationProperty.cs
src/libraries/System.Configuration.ConfigurationManager/tests/System/Configuration/ConfigurationPropertyTests.cs

index 7742d87..b809412 100644 (file)
@@ -22,7 +22,7 @@ namespace System.Configuration
         {
             object defaultValue = null;
 
-            ConstructorInit(name, type, ConfigurationPropertyOptions.None, null, null, null);
+            ConstructorInit(name, type, ConfigurationPropertyOptions.None, null, null);
 
             if (type == typeof(string))
             {
@@ -61,7 +61,7 @@ namespace System.Configuration
             ConfigurationPropertyOptions options,
             string description)
         {
-            ConstructorInit(name, type, options, validator, typeConverter, description);
+            ConstructorInit(name, type, options, validator, typeConverter);
 
             SetDefaultValue(defaultValue);
         }
@@ -147,16 +147,19 @@ namespace System.Configuration
                 info.PropertyType,
                 propertyAttribute.Options,
                 validator,
-                typeConverter,
-                descriptionAttribute?.Description);
+                typeConverter);
 
             // Figure out the default value
             InitDefaultValueFromTypeInfo(propertyAttribute, defaultValueAttribute);
+
+            // Get the description
+            if (!string.IsNullOrEmpty(descriptionAttribute?.Description))
+                Description = descriptionAttribute.Description;
         }
 
         public string Name { get; private set; }
 
-        public string Description { get; private set; }
+        public string Description { get; }
 
         internal string ProvidedName { get; private set; }
 
@@ -213,8 +216,7 @@ namespace System.Configuration
             Type type,
             ConfigurationPropertyOptions options,
             ConfigurationValidatorBase validator,
-            TypeConverter converter,
-            string description)
+            TypeConverter converter)
         {
             if (typeof(ConfigurationSection).IsAssignableFrom(type))
             {
@@ -235,7 +237,6 @@ namespace System.Configuration
             }
 
             Name = name;
-            Description = description;
             Type = type;
             _options = options;
             Validator = validator;
index 1f94006..e4b6bac 100644 (file)
@@ -138,15 +138,6 @@ namespace System.ConfigurationTests
             Assert.IsType<DummyCanConverter>(property.Converter);
         }
 
-        [Fact]
-        public void DescriptionValueIsExposed()
-        {
-            FooFailsValidator validator = new FooFailsValidator();
-            DummyCanConverter converter = new DummyCanConverter();
-            ConfigurationProperty property = new ConfigurationProperty("foo", typeof(MyConvertableClass), null, converter, validator, ConfigurationPropertyOptions.None, "bar");
-            Assert.Equal("bar", property.Description);
-        }
-
         [TypeConverter(typeof(DummyCantConverter))]
         public class MyUnconvertableClass
         {