Make Method Static Misses Cast "this"

I had an instance method which was referring to another virtual method.To
make it static, I decided that I should create an interface and have the
class implement the interface by calling the virtual method. I went from:

public class SomeThing : BaseClass where T : DataSet, new() { protected virtual bool ExcludeAttribute(string attributeName) { } private void MethodIWantStatic(string attributeName) { if (ExcludeAttribute(attributeName) {} } } to this: internal interface IExcludeAttributes { bool ShouldAttributeBeExcluded(string attributeName); } public class SomeThing]]> : BaseClass, IExcludeAttributes where T : DataSet,
new()
{
protected virtual bool ExcludeAttribute(string attributeName)
{
}

private void MethodIWantStatic(string attributeName)
{
if
(((IExcludeAttributesFromComparison)this).ShouldAttributeBeExcluded(externalAttributeName))
{}
}
}

I then ran "Make Method Static", and it offered no members to add to the
signature. However, it later noticed the this reference and displayed it as
an error.

Of course, selecting the expression and using "Introduce Parameter" brings
up the quick fix for "Method can be made static".
--
John


1 comment
Comment actions Permalink

Hello,

We appreciate your feedback.

The corresponding JIRA request has been created, and you are welcome to monitor
its status at http://www.jetbrains.net/jira/browse/RSRP-42650.

Best regards,
- Development Team.


0

Please sign in to leave a comment.