Home

Custom generic class doesn't benefit from the autocomplete when not defined in the current scope

When you refer to a generic class defined outside of the current scope, the autocomplete feature will not work.
The problem can be reproduced under :
v4.55.03 Premium edition
v4.56.06 Premium edition

void Main() { //check CustomGenericClassTest and GenericClassTest //mouseover the entitylist's member or type '.' after the entitylist[n] } void CustomGenericClassTest() { var entitylist1 = new EntityList<Employee>(); var entitylist2 = new CompanyContext().Employees; var entitylist3 = EntityLocator.Resolve<Employee>(); //entitylist1 has full autocomplete support entitylist1.Update(null); //entitylist1/3 doesnt have autocomplete support beside Dump() and DumpTrace() methods entitylist2.Insert(null); entitylist3.GetTable().Dump(); //explicitly casting it, will fix the problem. however it is rather inconvenient (entitylist2 as EntityList<Employee>).Update(null); } void GenericClassTest() { var list1 = new List<Employee>(); var list2 = new CompanyContext().Employees2; var list3 = EntityLocator.Resolve2<Employee>(); //autocomplete fully supported with List<T> list1.Count.Dump(); list2.Count.Dump(); list3.Count.Dump(); } // Define other methods and classes here class EntityList<T> where T : new() { public void Update(T item) { } public void Insert(T item) { } public List<T> GetTable() { return Enumerable.Repeat(new T(), 10); } } class Employee { public int EmployeeID { get; set; } public int FirstName { get; set; } public int LastName { get; set; } } class CompanyContext { public EntityList<Employee> Employees { get; set; } public List<Employee> Employees2 { get; set; } public CompanyContext() { Employees = new EntityList<Employee>(); Employees2 = new List<Employee(); } } static class EntityLocator { public static EntityList<T> Resolve<T>() where T : new() { return new EntityList<T>(); } public static List<T> Resolve2<T>() where T : new() { return new List<T>(); } }

Download the linq

Comments

Sign In or Register to comment.