JetBrains Rider
 
Get JetBrains Rider
Get your hands on the new features ahead of the release by joining the Early Access Program for Rider 2025.1! Learn more

Code inspection: Redundant 'partial' modifier on method declaration

Last modified: 08 April 2024

Partial methods allow separating the method signature (declaration) from its implementation. A single declaration part of a partial method might indicate that the development was not completed.

A missing implementation part does not cause an error because in this case the method and all its calls are removed from the assembly at compile time. However, JetBrains Rider suggests that it is better to make such a method non-partial to eliminate unclear code.

If it is the declaration part that is missing, an error occurs. Again, JetBrains Rider suggests making such a method non-partial.

In the example below, the method ToCart() has only the declaration part, implementation parts of the method were not found in any part of the class. JetBrains Rider removes the partial keyword and adds a method body according to the preferences on the Editor | Member Generation page of JetBrains Rider settings CtrlAlt0S: