JetBrains Rider 2024.1 Help

Code Inspection: Parameter name differs in partial method declaration

Category

Potential Code Quality Issues

ID

PartialMethodParameterNameMismatch

EditorConfig

resharper_partial_method_parameter_name_mismatch_highlighting

Default severity

Warning

Language

C#

Requires SWA

No

When processing partial methods, C# compiler only checks the order and the types of the parameters, not their names. Although the compiler allows you to use different names for the same parameters in the defining and in the implementing declarations, the example below demonstrates why this could be a bad practice.

JetBrains Rider detects mismatching parameter names and suggests that you use the same names for the same parameters. As it is impossible to infer which parameter name is meant to be correct, JetBrains Rider does not offer any quick-fixes for this warning.

partial class Item { partial void ToCart(int itemId, int transactionId); partial void ToCart(int transactionId, int itemId) { Console.WriteLine($"{transactionId}: success"); Console.WriteLine($"{itemId} added to cart"); } }
Last modified: 15 April 2024