Extract the type of expression with Resharper structural replace
-
12-10-2022 - |
Question
I am trying to make a R# structural search and replace to offer the following
foo.ToList()
should be converted to the below if the user selects the refactoring
foo as List<int> ?? foo.ToList()
so in R# I would try for the pattern
$expr$.ToList()
and for the replace
$expr$ as List<$type$> ?? $expr$.ToList()
however I can't figure out how I could assign $type$
where
typeof($expr$) is IEnumerable<$type$>
In theorey it should work because I can constrain $expr$
to be of type IEnumerable<T>
but I don't have $T$
available as a replace token.
Is this in way at all possible?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow