feature: support DbString in DapperAOT
DbString is a known type in Dapper and currently there is no dedicated support in DapperAOT for it.
Current PR does 2 things regarding DbString:
- in analyzer mode reports DAP48 and suggests to move from usage of
DbStringtoDbValueattribute. - properly configures
DbParameterif one of parameter members isDbStringby setting.Value,.Sizeand.DbType
Implementation notes:
- I have moved files in
Dapper.AOT.Analyzerswhich are copied to the output in separate folderInGeneration - I have created a single code writer for such types (
PreGeneratedCodeWriter), and included the generation context options inGenerateStateto have a control over which pre-generated types to include in the output. I decided to do in order to avoid writingDbStringHelpersin the output even in those cases, whereDbStringis not even used (basically to have more clear output)
Questions:
- I am pretty sure I messed up on how to get the size of DbString in ANSI encoding. How do we do it properly?
- What exactly do we need to do with the
DbStringinUpdateParameters? Do we need to call the same setup there, or just re-assigning value is fine?
Closes #89
add Integration tests for dbstring (in a separate project Dapper.AOT.Test.Integration)
- dapper.vanilla without any interception (no dapper aot)
- dapper code with dapper aot with dbString
- dbvalue (interception)
Hey @mgravell, I know you asked me to implement integration tests - I tried but I still dont have a solution yet. Filed an issue to do it in a separate PR: #122
regarding testing DbString functionality: I packed Dapper.AOT, installed in local NuGet feed and used in a console app:
-
I can confirm that we emit a proposition to migrate from
DbStringto[DbValue](only in Dapper.AOT mode) [module: DapperAot] -
confirmed that query against local database works and returns the model I have in database (note: we hit the breakpoint in the generated
DbStringHelpers- look at screenshot):