Skip to content

IsExtensionMethod

Summary

Severity - Fail

Check method - Here

Details

The IsExtensionMethod check makes sure that an engine method within a query, modify, or convert class is classed as an extension method to the first object type, providing the first object type is not a system type. Extension methods are made by using the this keyword prior to the declaration of the first input parameter. If a method does not take any inputs to operate, then it is exempt from this check.

For example, the following method declaration will fail this check, because it is missing the this keyword before the first object:

public static bool MethodIsValid(Panel myPanel, Opening myOpening)
{
    return false;
}

Whereas this method will pass the check, because the first parameter contains the this keyword to make the method an extension method.

public static bool MethodIsValid(this Panel myPanel, Opening myOpening)
{
    return false;
}

Methods within the Compute and Create classes are exempt from this check.

Files contained within an Engines Objects folder are exempt from this check (e.g. files with the file path Your_Toolkit/Toolkit_Engine/Objects/Foo.cs will be exempt).

Exempted types

System types are also exempt from this requirement. A list of the system types currently exempted is available here. If a system type is missing from this list, please feel free to raise a pull request to add it, or raise an issue for a member of the DevOps team to pick up.