I wish to write a custom rule for StyleCop that is the opposite of SA1101; namely, I want a violation to occur if there is a redundant this.
(similar to ReSharper). This happens if the methods/indexers/delegates/constructors containing the element does not have a parameter that is the same name as the element.
For the custom source analyzer, within the VisitElement(CsElement element, CsElement parentElement, T context)
, how do I get the names of the parameter of each methods/indexers/delegates/constructors containing the element?
You can cast the CsElement
to StyleCop.CSharp.IParameterContainer
, then use its Parameters
property to retrieve the parameters.