BUG: Ineligible autocomplete entries (generic extension methods with constraints)
I have some extensions defined to help with chaining expressions with common interfaces and operations.
public static class ChainableExtensions
{
public static T With<T>(this T source, Action<T> action)
{
action(source);
return source;
}
public static TResult Let<T, TResult>(this T source, Func<T, TResult> func)
{
return func(source);
}
#region IDictionary<TKey, TValue> extensions
public static TDictionary AddChained<TKey, TValue, TDictionary>(this TDictionary dict, TKey key, TValue value) where TDictionary : IDictionary<TKey, TValue>
{
dict.Add(key, value);
return dict;
}
...
#endregion
#region IList<T> extensions
public static TList InsertChained<T, TList>(this TList list, int index, T item) where TList : IList<T>
{
list.Insert(index, item);
return list;
}
...
#endregion
#region ISet<T> extensions
public static TSet UnionWithChained<T, TSet>(this TSet set, IEnumerable<T> other) where TSet : ISet<T>
{
set.UnionWith(other);
return set;
}
...
#endregion
#region ICollection<T> extensions
public static TCollection AddChained<T, TCollection>(this TCollection coll, T item) where TCollection : ICollection<T>
{
coll.Add(item);
return coll;
}
...
#endregion
}
Autocomplete doesn't seem to take the constraints into account. All of the above methods are showing as options in autocomplete, even for types that do not satisfy the constraint. I feel like this should be fixed.

LinqPad Beta 7.1.4
.Net Runtime 6.0.1
Comments
-
LINQPad uses Roslyn to filter the autocompletion lists, which has an open issue with type constraints:
https://github.com/dotnet/roslyn/issues/39689
