Skip to content

Report getter-only properties in output parameter errors - #2279

Open
tuncaypeker wants to merge 1 commit into
DapperLib:mainfrom
tuncaypeker:fix/output-readonly-property-error
Open

tuncaypeker wants to merge 1 commit into
DapperLib:mainfrom
tuncaypeker:fix/output-readonly-property-error

Conversation

@tuncaypeker

Copy link
Copy Markdown

Fixes #1148.

Registering an Output expression that targets a getter-only property currently passes a null setter to ILGenerator.Emit, producing ArgumentNullException with the internal parameter name "meth".

Throw InvalidOperationException naming the property and explaining that an output property needs a setter. Keep using GetSetMethod(true) so private setters remain supported. No public signatures or dependencies are added.

Validation:

  • Reproduced on unmodified upstream main at 1880947 on net10.0: anonymous, getter-only, and nested getter-only properties all produce the internal ArgumentNullException. The three regression cases fail; four valid output controls pass.
  • Seven database-free tests cover the three rejection cases and successful callback assignment through public setters, private setters, getter-only intermediate parents with writable final properties, and fields. The controls prepare a disconnected SqlCommand and invoke the parameter callbacks without opening a database connection.
  • The seven new cases plus existing output-expression tests pass on net481, net8.0, and net10.0: 31 passed per framework, with no failures or skips. Existing integration cases use SQL Server 2025 LocalDB with both SqlClient providers.
  • The full repository test suite was not run.
  • Release library build succeeds for net461, netstandard2.0, net8.0, and net10.0 with zero warnings or errors.

This branch has not been deployed

No deployments
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.

Poor error message when using 'DynamicParameter.Output<T>' on property without setter

1 participant