I’m currently working on a C# project where I’m encountering a warning from SonarLint with the message: “Remove this argument from the method call; it hides the caller information.” However, I’m not explicitly providing caller information arguments (CallerMemberName, CallerFilePath, CallerLineNumber) in the relevant code section.
The warning occurs at this specific line:
Guard.Against.Null(tenant, $"Tenant: {@event.MpsPayment.TenantId} not found.");
Here, Guard.Against.Null is a method from a custom guard clause library, and @event.MpsPayment.TenantId retrieves the tenant ID.
I’m unsure why this warning is appearing and how to resolve it. I’ve checked the method implementation of Guard.Against.Null and confirmed that it doesn’t expect caller information arguments.
Could anyone provide insights or suggestions on why this warning might occur and how to address it? I’m using SonarLint in Visual Studio for code analysis.
Any help or guidance would be greatly appreciated. Thanks!
I attempted to resolve the warning by reviewing the code and ensuring that I’m not explicitly providing caller information attributes (CallerMemberName, CallerFilePath, CallerLineNumber) in the relevant method call.
I expected that since I’m not explicitly providing caller information attributes, the warning would not occur, and the code would pass the SonarLint analysis without issues.
However, despite not providing explicit caller information attributes, the SonarLint analysis flagged the code with the warning: “Remove this argument from the method call; it hides the caller information.”
temo mikava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2