Skip to content

refactor!: drop redundant/ambiguous dictionary extensions from TryExtensions - #82

Merged
ANcpLua merged 1 commit into
mainfrom
drop-ambiguous-dict-extensions
Apr 30, 2026
Merged

refactor!: drop redundant/ambiguous dictionary extensions from TryExtensions#82
ANcpLua merged 1 commit into
mainfrom
drop-ambiguous-dict-extensions

Conversation

@ANcpLua

@ANcpLua ANcpLua commented Apr 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove GetOrNull (redundant with BCL GetValueOrDefault) and GetOrDefault (same)
  • Drop all IDictionary/IList overloads that cause ambiguous invocation on types implementing both mutable and read-only interfaces (mirrors BCL's design of scoping to IReadOnlyDictionary only)
  • Keep: GetValueOrNull (struct, returns Nullable<T> — no BCL equivalent), GetOrElse (lazy factory), all TryParse*, collection safe-access on IReadOnlyList

Test plan

  • Build succeeds with 0 errors
  • AnalyzerConfigOptionsProviderExtensions.cs unaffected (uses its own GetValueOrNull for AnalyzerConfigOptions, not the dictionary extension)

🤖 Generated with Claude Code

…ensions

Remove GetOrNull (redundant with BCL GetValueOrDefault), GetOrDefault
(same), and all IDictionary/IList overloads that cause ambiguous
invocation on types implementing both mutable and read-only interfaces.

Kept: GetValueOrNull (struct, no BCL equivalent), GetOrElse (lazy
factory), all TryParse methods, collection safe-access on IReadOnlyList.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 30, 2026 20:59
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

Summary by CodeRabbit

  • Breaking Changes
    • Removed multiple extension methods for dictionary retrieval and list element access operations.
    • Consolidated API to prioritize lazy-default patterns for dictionary value retrieval.

Walkthrough

The extension API surface in TryExtensions.cs is reduced by removing dictionary and collection safe-access overloads (GetOrNull, GetValueOrNull, GetOrDefault, ElementAtOrNull, ValueAtOrNull, ElementAtOrDefault), retaining only the lazy-default GetOrElse variants for both IDictionary and IReadOnlyDictionary interfaces.

Changes

Cohort / File(s) Summary
Extension API reduction
src/ANcpLua.Roslyn.Utilities/TryExtensions.cs
Removed 8 extension methods across dictionary and collection helpers; retained GetOrElse overloads as the canonical safe-access API. Net change: +4/−196 lines including final newline addition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

breaking


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Title check ❌ Error Title exceeds 72-character limit at 76 characters and lacks required scope prefix matching area labels. Add scope in parentheses (e.g., 'refactor!(utilities): ...') and reduce to 72 characters maximum, e.g., 'refactor(utilities): drop redundant dict extensions'.
✅ Passed checks (7 passed)
Check name Status Explanation
Description check ✅ Passed Description directly addresses the changeset, detailing removed methods, retained functionality, and test verification.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Otel Instrumentation Required ✅ Passed PR modifies static utility extension methods in TryExtensions.cs; extension methods cannot be registered in DI containers and do not require OpenTelemetry instrumentation.
No Unbounded Mcp Responses ✅ Passed PR modifies only TryExtensions.cs with no changes to MCP tool definitions; repository contains no MCP-related files under src/qyl.mcp/.
Duckdb Backpressure On Write Paths ✅ Passed PR refactors TryExtensions.cs removing redundant dictionary/collection methods with no DuckDB write paths introduced.
Cancellationtoken Threading ✅ Passed No public async methods exist in TryExtensions.cs; only synchronous extension methods for dictionary, string, and collection access are modified.

Review rate limit: 3/5 reviews remaining, refill in 23 minutes and 59 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes redundant and ambiguity-prone extension methods from TryExtensions, narrowing dictionary helpers to IReadOnlyDictionary (to match BCL scoping) and trimming list helpers to IReadOnlyList to avoid ambiguous overload resolution on types implementing multiple collection interfaces.

Changes:

  • Removed GetOrNull and GetOrDefault dictionary extensions (redundant with BCL GetValueOrDefault).
  • Removed IDictionary (and IList) overloads to eliminate ambiguous invocation on dual-interface types.
  • Retained GetValueOrNull (value types), GetOrElse (lazy factory), TryParse* helpers, and IReadOnlyList safe-access helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors TryExtensions.cs by removing extension methods targeting mutable interfaces like IDictionary and IList, favoring IReadOnlyDictionary and IReadOnlyList instead. Specifically, it removes GetOrNull for reference types, GetOrDefault for dictionaries, and several IList extensions, while updating the documentation to match the updated API. I have no feedback to provide.

@ANcpLua
ANcpLua merged commit 334ab2e into main Apr 30, 2026
17 of 18 checks passed
@ANcpLua
ANcpLua deleted the drop-ambiguous-dict-extensions branch April 30, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants