DapperAOT icon indicating copy to clipboard operation
DapperAOT copied to clipboard

analyzer: Warn about potentially incorrect pseudo-positional arguments processing

Open DeagleGross opened this issue 1 year ago • 1 comments

Dapper.Vanilla will incorrectly process ? symbol assuming its a syntax for pseudo-positional arguments even when it is used in the SQL string. I.e:

select 'this ?looks? like pseudo-positional'

Added the processing step for StringLiteral in TSqlProcessor where we report a diagnostic only if criterias below are met:

  1. string contains 2 question marks
  2. string contains 2 question marks in AsciiStringLiteral only
  3. CompiledRegex.PseudoPositional regex returns true

IIRC we decided not to report diagnostic for OLE Db smell check.

Closes #60

DeagleGross avatar Apr 28 '24 15:04 DeagleGross

TODO:

  • [x] detect specific SQL parse failure and ignore it\
  • [x] overcome the warning Parameter 'Id' is not used, but will be included
    • run PseudoPosArg regex after variables are assigned, and if there is something - mark it as used

DeagleGross avatar May 10 '24 21:05 DeagleGross