C#: Address co-pilot review comments.

This commit is contained in:
Michael Nebel
2026-05-13 09:22:31 +02:00
parent 5ed3014f7d
commit fa2d633596
2 changed files with 4 additions and 4 deletions

View File

@@ -53,11 +53,11 @@ namespace Semmle.Extraction.CSharp.Util
});
/// <summary>
/// The operatorname for user-defined increment and decrement operators are "op_IncrementAssignment" and
/// The operatorname for user-defined instance increment- and decrement operators are "op_IncrementAssignment" and
/// "op_DecrementAssignment" respectively.
/// Thus we need to handle this explicitly to avoid postfixing them with an "=".
/// </summary>
private static bool isIncrementOrDecrement(string operatorName) => operatorName == "++" || operatorName == "--";
private static bool IsIncrementOrDecrement(string operatorName) => operatorName == "++" || operatorName == "--";
/// <summary>
/// Convert an operator method name in to a symbolic name.
@@ -79,7 +79,7 @@ namespace Semmle.Extraction.CSharp.Util
if (match.Success && methodToOperator.TryGetValue($"op_{match.Groups[2]}", out var rawOperatorName))
{
var prefix = match.Groups[1].Success ? "checked " : "";
var postfix = match.Groups[3].Success && !isIncrementOrDecrement(rawOperatorName) ? "=" : "";
var postfix = match.Groups[3].Success && !IsIncrementOrDecrement(rawOperatorName) ? "=" : "";
operatorName = $"{prefix}{rawOperatorName}{postfix}";
return true;
}

View File

@@ -576,7 +576,7 @@ class MutatorOperatorCall extends OperatorCall {
*
* ```csharp
* class A {
* public void operator++() { ... }
* public void operator ++() { ... }
*
* public static void Increment(A a) {
* a++;