When using DapperAOT, passing a CancellationToken as part of the parameters object triggers diagnostic DAP018. However, this appears to be a false positive because DapperAOT has special handling for CancellationToken when included in the parameters object.
Reproduction Code:
await connection.QueryAsync(
"SELECT * FROM my_table",
new { cancellationToken }
);
Observed Behavior:
The analyzer raises warning DAP018 for the above code.
Expected Behavior:
No warning should be raised. CancellationToken is explicitly supported as part of the parameters object and handled specially by DapperAOT, so this usage is valid.
Additional Context:
Rule reference: https://aot.dapperlib.dev/rules/DAP018
The current analyzer behavior does not account for Dapper’s special-case handling of CancellationToken, leading to an incorrect diagnostic.
Impact:
This produces unnecessary warnings in valid code, potentially confusing users and encouraging incorrect refactoring.
Suggested Fix:
Update the DAP018 rule logic to detect and exclude CancellationToken when it is passed via the parameters object.
When using DapperAOT, passing a CancellationToken as part of the parameters object triggers diagnostic DAP018. However, this appears to be a false positive because DapperAOT has special handling for CancellationToken when included in the parameters object.
Reproduction Code:
await connection.QueryAsync(
"SELECT * FROM my_table",
new { cancellationToken }
);
Observed Behavior:
The analyzer raises warning DAP018 for the above code.
Expected Behavior:
No warning should be raised. CancellationToken is explicitly supported as part of the parameters object and handled specially by DapperAOT, so this usage is valid.
Additional Context:
Rule reference: https://aot.dapperlib.dev/rules/DAP018
The current analyzer behavior does not account for Dapper’s special-case handling of CancellationToken, leading to an incorrect diagnostic.
Impact:
This produces unnecessary warnings in valid code, potentially confusing users and encouraging incorrect refactoring.
Suggested Fix:
Update the DAP018 rule logic to detect and exclude CancellationToken when it is passed via the parameters object.