Repository navigation
Docs: clarify NpgsqlParameterCollection.Add(object) requires NpgsqlParameter - #6342
Conversation
|
See feedback on #6179 (comment) |
There was a problem hiding this comment.
Pull Request Overview
This PR improves the XML documentation for NpgsqlParameterCollection.Add(object) and Insert(int, object) methods to clarify that these methods require NpgsqlParameter instances, not raw values, addressing issue #6150. The documentation now explicitly warns that passing raw values will result in an InvalidCastException and directs users to appropriate alternatives like AddWithValue.
- Replaced
<inheritdoc />tags with explicit XML documentation forAdd(object)andInsert(int, object) - Added clarifications that raw values are not supported and will throw
InvalidCastException - Included references to alternative methods for adding parameters by value
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Improves XML documentation for methods that accept `object` (e.g. Add, Insert, Remove, IndexOf), but only support `NpgsqlParameter` instances. Now clearly states that passing any other type throws `InvalidCastException`. Also fixes a CS1584 error caused by an incorrect <see cref="Add(object).)"/> cref.
|
Hi @NinoFloris , thanks for the reference you shared earlier. I’ve reviewed the issue you pointed to and updated the XML documentation accordingly, in line with the feedback. Let me know if there’s anything else that needs adjustment! |
|
There are build failures that have to be fixed. |
Resolve CS1572, CS1573, and CS0419 compiler warnings for XML comments
NinoFloris
left a comment
There was a problem hiding this comment.
Thanks @nimanikoo, please take a look. Sorry for the short replies earlier, we've been very busy getting 10.0 ready for release.
| /// Removes the specified <see cref="NpgsqlParameter"/> from the collection. | ||
| /// </summary> | ||
| /// <param name="value">The <see cref="NpgsqlParameter"/> to remove from the collection.</param> | ||
|
|
There was a problem hiding this comment.
Please undo this newline. You probably wanted to replace this param doc as well.
There was a problem hiding this comment.
Mind adding your version of the doc to this Remove method too? That's all the feedback from me!
There was a problem hiding this comment.
Thanks! And sorry I missed that one initially.
Since I contribute to various projects, it sometimes takes a bit of time to switch gears and adapt to the specific culture/style of a new codebase. I appreciate the guidance!
I've applied the change.
There was a problem hiding this comment.
It's my bad, there is a Remove(object value) overload below this method that I intended to comment on. Please take a look, it doesn't have the remarks yet.
There was a problem hiding this comment.
@nimanikoo please take a look, the remaining CI error is unrelated (there is github-wide intermittent issue with the hashFiles function on macOS runners).
There was a problem hiding this comment.
Good catch. I’ve updated the documentation for Remove(object value) to match the other methods., so this should be good to go.
@NinoFloris
Move lengthy parameter descriptions to <remarks> sections per Microsoft guidelines. Keeps <param> tags concise and improves IDE readability.
|
The test failure in Could you please re-run the failed test or advise if this is a known issue? Thank you! 🙏 |
|
Thanks @nimanikoo! |
|
Thank you! I’m glad I could contribute. I’m really enjoying the project and I’m looking forward to collaborating on future issues. |
…metry (#347) Updated [Npgsql.EntityFrameworkCore.PostgreSQL](https://github.com/npgsql/efcore.pg) from 10.0.3 to 10.0.4. <details> <summary>Release notes</summary> _Sourced from [Npgsql.EntityFrameworkCore.PostgreSQL's releases](https://github.com/npgsql/efcore.pg/releases)._ ## 10.0.4 [Milestone issue](https://github.com/npgsql/efcore.pg/milestone/79?closed=1) ## What's Changed * [10.0] Backport regex operand parentheses fix by @roji in npgsql/efcore.pg#3928 * [10.0] Remove unused SSL setup from Windows CI by @roji in npgsql/efcore.pg#3931 * [10.0] Backport unnest type mapping inference fix by @roji in npgsql/efcore.pg#3945 * [10.0] Truncate sub-microsecond ticks when formatting TimeSpan as interval by @roji in npgsql/efcore.pg#3947 * [10.0] Preserve row value type mappings when rewriting expressions by @roji in npgsql/efcore.pg#3954 * [10.0] Fix Last() on primitive collections returning the first array element by @roji in npgsql/efcore.pg#3956 * [10.0] Configure row value regression tuple mapping locally by @roji in npgsql/efcore.pg#3960 * [10.0] Update EF Core and other dependencies by @roji in npgsql/efcore.pg#3963 * [10.0] Fix collection conversion with nullable element converters (#3965) by @roji in npgsql/efcore.pg#3967 * [10.0] Fix Contains on an object collection over a value-converted column (#3961) by @roji in npgsql/efcore.pg#3970 * [10.0] Fix tsvector metadata cast for IReadOnlyList by @roji in npgsql/efcore.pg#3986 * [10.0] Fix explicit column types for owned JSON collections by @roji in npgsql/efcore.pg#3989 * [10.0] Prevent PadLeft/PadRight from truncating shorter target widths by @roji in npgsql/efcore.pg#3993 * [10.0] Fix array type inference for mixed collection types by @roji in npgsql/efcore.pg#3996 * [10.0] Fix null checks on unbounded NodaTime Interval bounds by @roji in npgsql/efcore.pg#4002 * [10.0] Backport fix for null propagation in date/time intervals by @roji in npgsql/efcore.pg#4015 * [10.0] Support System.Text.Json serialization of LTree by @roji in npgsql/efcore.pg#4010 * [10.0] Preserve array element converters with explicit column types by @roji in npgsql/efcore.pg#4011 * [10.0] Fix repeated seed-data updates for list properties by @roji in npgsql/efcore.pg#4029 * [10.0] Fix BCE NodaTime SQL literal formatting by @roji in npgsql/efcore.pg#4027 * [10.0] Preserve inherited HiLo sequences in model snapshots by @roji in npgsql/efcore.pg#4032 * [10.0] Fix date/time mapping round-tripping and cloning by @roji in npgsql/efcore.pg#4037 * [10.0] Fix Regex.Replace to replace all matches by @roji in npgsql/efcore.pg#4041 * [10.0] Restore raw JSON byte array mapping by @roji in npgsql/efcore.pg#4044 * [10.0] Translate ToString() on string expressions by @roji in npgsql/efcore.pg#4050 * [10.0] Own newly cloned connections by @roji in npgsql/efcore.pg#4056 * [10.0] Fix type mapping for derived tsquery parameters by @roji in npgsql/efcore.pg#4060 * [10.0] Fix precision-only numeric migration snapshot churn by @roji in npgsql/efcore.pg#4070 * [10.0] Fix byte-array projections from JSON collections by @roji in npgsql/efcore.pg#4073 * [10.0] Fix tsvector columns over JSON-mapped navigations/complex properties by @roji in npgsql/efcore.pg#4076 * [10.0] Fix hstore SQL literal generation for null and escaped values by @roji in npgsql/efcore.pg#4106 * [10.0] Fix TimeOnly.IsBetween for midnight-spanning ranges by @roji in npgsql/efcore.pg#4131 * [10.0] Parenthesize the item of ANY/ALL when its precedence requires it by @roji in npgsql/efcore.pg#4132 * [10.0] Format storage parameter values with the invariant culture by @roji in npgsql/efcore.pg#4133 **Full Changelog**: npgsql/efcore.pg@v10.0.3...v10.0.4 Commits viewable in [compare view](npgsql/efcore.pg@v10.0.3...v10.0.4). </details> Pinned [Npgsql.OpenTelemetry](https://github.com/npgsql/npgsql) at 11.0.0. <details> <summary>Release notes</summary> _Sourced from [Npgsql.OpenTelemetry's releases](https://github.com/npgsql/npgsql/releases)._ ## 11.0.0 See the [release notes](https://www.npgsql.org/doc/release-notes/11.0.html). The full list of changes is available [here](https://github.com/npgsql/npgsql/milestone/132?closed=1). ## What's Changed * Bump GitHubActionsTestLogger from 2.4.1 to 3.0.1 by @dependabot[bot] in npgsql/npgsql#6353 * Docs: clarify NpgsqlParameterCollection.Add(object) requires NpgsqlParameter by @nimanikoo in npgsql/npgsql#6342 * Bump actions/setup-dotnet from 5.0.0 to 5.0.1 by @dependabot[bot] in npgsql/npgsql#6355 * Bump Scriban.Signed from 6.5.1 to 6.5.2 by @dependabot[bot] in npgsql/npgsql#6356 * Fix flaky test PostgresType by @vonzshik in npgsql/npgsql#6354 * Drop net8.0 and net9.0 TFMs by @roji in npgsql/npgsql#6358 * Bump BenchmarkDotNet from 0.15.6 to 0.15.8 by @dependabot[bot] in npgsql/npgsql#6361 * Bump NUnit3TestAdapter from 5.2.0 to 6.0.0 by @dependabot[bot] in npgsql/npgsql#6365 * Throw OperationCancelledException with correct CancellationToken from Dns.GetHostAddressesAsync by @vonzshik in npgsql/npgsql#6364 * Bump dotnet logging and DI dependencies by @roji in npgsql/npgsql#6371 * Bump NodaTime from 3.2.2 to 3.2.3 by @dependabot[bot] in npgsql/npgsql#6375 * Bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in npgsql/npgsql#6377 * Bump actions/cache from 4 to 5 by @dependabot[bot] in npgsql/npgsql#6378 * For COPY operations treat 0 as infinite timeout in addition to -1 by @vonzshik in npgsql/npgsql#6352 * Bump NUnit3TestAdapter from 6.0.0 to 6.0.1 by @dependabot[bot] in npgsql/npgsql#6387 * Fix reading numerics as BigInteger by @vonzshik in npgsql/npgsql#6385 * Add empty permissions block in Github Actions configs (#3694) by @roji in npgsql/npgsql#6392 * Fix test timeout_during_authentication by @vonzshik in npgsql/npgsql#6388 * Fix retrieving sequence file for hanging tests by @vonzshik in npgsql/npgsql#6397 * Fix reading BigInteger with composites by @vonzshik in npgsql/npgsql#6390 * Do not include password in data source name with Persist Security Info=true by @roji in npgsql/npgsql#6395 * [Tests] Remove npgsqldbtype passing and rename related flag by @NinoFloris in npgsql/npgsql#6305 * Year++ by @vonzshik in npgsql/npgsql#6402 * Bump NodaTime from 3.2.3 to 3.3.0 by @dependabot[bot] in npgsql/npgsql#6403 * Bump NUnit3TestAdapter from 6.0.1 to 6.1.0 by @dependabot[bot] in npgsql/npgsql#6405 * Bump some dependencies by @roji in npgsql/npgsql#6411 * Bump actions/setup-dotnet from 5.0.1 to 5.1.0 by @dependabot[bot] in npgsql/npgsql#6412 * Bump Microsoft.Data.SqlClient from 6.1.3 to 6.1.4 by @dependabot[bot] in npgsql/npgsql#6414 * Bump OpenTelemetry.Api from 1.14.0 to 1.15.0 by @dependabot[bot] in npgsql/npgsql#6420 * Bump OpenTelemetry and OpenTelemetry.Exporter.InMemory by @dependabot[bot] in npgsql/npgsql#6421 * Improve fallback handling for GSS session encryption when native library is missing by @vonzshik in npgsql/npgsql#6422 * Fix wrapping OperationCancelledException for physical open by @vonzshik in npgsql/npgsql#6425 * Fix reusing NpgsqlBatch with auto prepare by @vonzshik in npgsql/npgsql#6433 * Do not clear pool while establishing connection if we'll retry it by @vonzshik in npgsql/npgsql#6431 * Fix for retrieving column metadata for Postgres < 10 by @KeltorHD in npgsql/npgsql#6438 * Some SQL query cleanup by @roji in npgsql/npgsql#6439 * Reset connection when closing within TransactionScope by @roji in npgsql/npgsql#6424 * Fix per instance nullability converter resolver info code by @NinoFloris in npgsql/npgsql#6435 * Bump Microsoft.SourceLink.GitHub from 10.0.102 to 10.0.103 by @dependabot[bot] in npgsql/npgsql#6445 * Bump Microsoft.Extensions.DependencyInjection.Abstractions from 10.0.2 to 10.0.3 by @dependabot[bot] in npgsql/npgsql#6441 * Bump extensions versions to 10.0.3 by @roji in npgsql/npgsql#6448 * Bump Scriban.Signed from 6.5.2 to 6.5.3 by @dependabot[bot] in npgsql/npgsql#6455 * [Tests] Fully rework type mapping assertion helpers by @NinoFloris in npgsql/npgsql#6314 * Bump Microsoft.NET.Test.Sdk from 18.0.1 to 18.3.0 by @dependabot[bot] in npgsql/npgsql#6460 * Bump actions/upload-artifact from 6 to 7 by @dependabot[bot] in npgsql/npgsql#6461 ... (truncated) ## 10.0.4 [Release milestone](https://github.com/npgsql/npgsql/milestone/139?closed=1) **Full Changelog**: npgsql/npgsql@v10.0.3...v10.0.4 Commits viewable in [compare view](npgsql/npgsql@v10.0.3...v11.0.0). </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rene Bentes Pinto <[email protected]>
Problem: The inherited docs for Add(object) are misleading, implying callers can pass the parameter Value (a raw value) when the override requires an NpgsqlParameter and will throw otherwise.
Change: Update XML comments on Add(object) (and Insert(object) optionally) to explicitly require NpgsqlParameter and point to AddWithValue/typed overloads for convenience.
Tests: No behavior changes; existing tests for Can_only_add_NpgsqlParameter still pass.
Issue: #6150