How to get suggested types to constrained generic method
I have been trying to write a Live Template that will type some code that contains a call to a method that has a generic parameter and have it display a list of classes that satisfy that constraint. I even started to write a Resharper Macro to help with it and had trouble figuring out where to get the type information. I then found that I couldn't get any intellisense for it either. Is this even possible or am I going down a dead end?
Basically I have something like
public abstract class B
{
public string Name { get; set; }
}
public class C : B
{
public string Age { get; set; }
}
public class A
{
IList<string> _listOfNames = new List<string>();
public void AddName<T>(Expression<Func<T, object>> property) where T:B
{
_listOfNames.Add(property.GetMemberInfo().Name);
}
}
And then use it like
classOfTypeA.AddName<C>( x => x.Age );
I would like autocomplete or intellisense or something to display B and C when I type AddName< seeing as how it is constrained to be of type B.
TIA
Please sign in to leave a comment.
Hi,
Thanks for the sample. I created the bug request for you and you are welcome to monitor its status at http://youtrack.jetbrains.net/issue/RSRP-213168
--
Kirill Falk
.NET Team QA Lead
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"