diff --git a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationProperty.cs b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationProperty.cs index b8094122e4e6..7742d8709a9c 100644 --- a/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationProperty.cs +++ b/src/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationProperty.cs @@ -22,7 +22,7 @@ public ConfigurationProperty(string name, Type type) { object defaultValue = null; - ConstructorInit(name, type, ConfigurationPropertyOptions.None, null, null); + ConstructorInit(name, type, ConfigurationPropertyOptions.None, null, null, null); if (type == typeof(string)) { @@ -61,7 +61,7 @@ public ConfigurationProperty(string name, Type type, object defaultValue, Config ConfigurationPropertyOptions options, string description) { - ConstructorInit(name, type, options, validator, typeConverter); + ConstructorInit(name, type, options, validator, typeConverter, description); SetDefaultValue(defaultValue); } @@ -147,19 +147,16 @@ internal ConfigurationProperty(PropertyInfo info) info.PropertyType, propertyAttribute.Options, validator, - typeConverter); + typeConverter, + descriptionAttribute?.Description); // 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; } + public string Description { get; private set; } internal string ProvidedName { get; private set; } @@ -216,7 +213,8 @@ public TypeConverter Converter Type type, ConfigurationPropertyOptions options, ConfigurationValidatorBase validator, - TypeConverter converter) + TypeConverter converter, + string description) { if (typeof(ConfigurationSection).IsAssignableFrom(type)) { @@ -237,6 +235,7 @@ public TypeConverter Converter } Name = name; + Description = description; Type = type; _options = options; Validator = validator; diff --git a/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ConfigurationPropertyTests.cs b/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ConfigurationPropertyTests.cs index e4b6bac3eb50..bb4a148cf0ee 100644 --- a/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ConfigurationPropertyTests.cs +++ b/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ConfigurationPropertyTests.cs @@ -138,6 +138,16 @@ public void TypeConverterRecognized() Assert.IsType(property.Converter); } + [Fact] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full framework does not have the fix #41873")] + 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 {