mirror of
https://github.com/github/codeql.git
synced 2026-05-24 08:07:07 +02:00
C#: Address co-pilot review comments.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -576,7 +576,7 @@ class MutatorOperatorCall extends OperatorCall {
|
||||
*
|
||||
* ```csharp
|
||||
* class A {
|
||||
* public void operator++() { ... }
|
||||
* public void operator ++() { ... }
|
||||
*
|
||||
* public static void Increment(A a) {
|
||||
* a++;
|
||||
|
||||
Reference in New Issue
Block a user