-
Notifications
You must be signed in to change notification settings - Fork 874
Milestone
Description
We are using the ICustomTypeDescriptor interface of NpgsqlConnectionStringBuilder to retrieve the connection properties like:
var builder = new NpgsqlConnectionStringBuilder();
var properties = ((ICustomTypeDescriptor)builder).GetProperties().Cast<PropertyDescriptor>()Since version 8.x onward this implementation is broken by a refactoring of the DbConnectionStringBuilder.GetProperties override:
NpgSql Version 7.0.10 - works fine:
protected override void GetProperties(Hashtable propertyDescriptors)
{
// Tweak which properties are exposed via TypeDescriptor. This affects the VS DDEX
// provider, for example.
base.GetProperties(propertyDescriptors);
var toRemove = propertyDescriptors.Values
.Cast<PropertyDescriptor>()
.Where(d =>
!d.Attributes.Cast<Attribute>().Any(a => a is NpgsqlConnectionStringPropertyAttribute) ||
d.Attributes.Cast<Attribute>().Any(a => a is ObsoleteAttribute)
)
.ToList();
foreach (var o in toRemove)
propertyDescriptors.Remove(o.DisplayName);
}NpgSql Version 8.0.0 onwards is broken since it filters out all properties having the NpgsqlConnectionStringPropertyAttribute instead of keeping exact those:
protected override void GetProperties(Hashtable propertyDescriptors)
{
// Tweak which properties are exposed via TypeDescriptor. This affects the VS DDEX
// provider, for example.
base.GetProperties(propertyDescriptors);
var toRemove = new List<PropertyDescriptor>();
foreach (var value in propertyDescriptors.Values)
{
var d = (PropertyDescriptor)value;
foreach (var attribute in d.Attributes)
if (attribute is NpgsqlConnectionStringPropertyAttribute or ObsoleteAttribute)
toRemove.Add(d);
}
foreach (var o in toRemove)
propertyDescriptors.Remove(o.DisplayName);
}Reactions are currently unavailable