ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 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, ReSharper 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, ReSharper 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. ReSharper removes the partial keyword and adds a method body according to the preferences on the Code Editing | Member Generation page of ReSharper options Alt+R, O: