Skip to content

Updates StatementExecutionApiClient Execute, Get & GetResultChunk to use source generation#291

Open
mellis-ao wants to merge 11 commits intoAzure:masterfrom
mellis-ao:enable-trim-analyzers
Open

Updates StatementExecutionApiClient Execute, Get & GetResultChunk to use source generation#291
mellis-ao wants to merge 11 commits intoAzure:masterfrom
mellis-ao:enable-trim-analyzers

Conversation

@mellis-ao
Copy link
Contributor

@mellis-ao mellis-ao commented Oct 16, 2025

The aim of this is to resolve #290 but also to start the ball rolling on adding RequiresUnreferencedCode attributes & improve awareness of other contributors whether the code is trim safe.

  • .Net 6 was removed as it is EOL: https://learn.microsoft.com/en-us/lifecycle/products/microsoft-net-and-net-core
    • Source generation compatibility was not where it needs to be to keep .Net 6 as a target without using pre-processor directives to produce conditional code paths.
  • Adds Directory.Build.props to centralise framework targets
  • Adds <EnableTrimAnalyzer>true</EnableTrimAnalyzer> to trigger warnings in the code to prompt use of RequiresUnreferencedCode or to use source generated alternatives.
  • Places some [RequiresUnreferencedCode] usage on ApiClient and other areas related to the SQL Api.
  • Fixes Execute, Get & GetResultChunk methods to use source generation instead of reflection.
    • Also converted to use JsonContent instead of StringContent to avoid the overhead of UTF-16 on strings.

Testing:

Unit tests pass:

image

Also published a copy of this package to our private Azure Artifacts feed with the fixes and tested in our scenarios. We were able to add <JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault> to our project and not hit any errors (as well was getting results as expected).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StatementExecutionApiClient - Execute, Get & GetResultChunk should be trim friendly by using source generation

1 participant