We have extension methods To<T> and As<T> that do a fluent style version of (T)v and (v as T). I'd like to make a custom pattern to find redundant uses of these when the underlying 'v' is already of type T.
So I would like to do something like this:
pattern = $expr$.To<$type$>()
replace = $expr$
Where $expr$ is an expression of type $type$. This obviously doesn't work.
So in effect I'm looking for something similar to R#'s built-in ability to detect unnecessary use of Cast<T>() on an enumerable. Is this something I can do with a Custom Pattern?