Repository navigation
Derive the λ1012 code fix from ExtensionMemberCodeFix for a one-pass Fix-All - #1026
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the λ1012 migration to the shared Fix-All infrastructure.
No open issues 🎉
What changed in this PR
Moves the λ1012 code fix onto the shared ExtensionMemberCodeFix infrastructure from #1013, addressing #1020 by avoiding conflicting using-directive insertions during Fix-All.
Changes:
- Reuses document-based Fix-All to rewrite eligible calls together and add
using Funcky.Extensions;once per using container. - Adds regression tests for multiple fixes with file-level and namespace-level usings.
- Updates the changelog to include λ1012 in the Fix-All correction.
| File | Description |
|---|---|
| Funcky.Analyzers/Funcky.Analyzers.Test/OrNone/PreferOrNoneTest.cs | Adds one-pass Fix-All regression tests for both using placements. |
| Funcky.Analyzers/Funcky.Analyzers.CodeFixes/OrNone/PreferOrNoneCodeFix.cs | Adopts the shared base with a binding predicate tailored to GetOrElse. |
| changelog.md | Adds λ1012 and #1020 to the shared Fix-All release note. |
Review effort: Balanced
…Fix-All The fix inserted `using Funcky.Extensions;` through its own path with the default BatchFixer, so three or more diagnostics in one document that all needed the directive collided and some were only rewritten by a second Fix-All pass, the same defect as #1009. It now derives from the base of #1013, which rewrites all flagged calls of a document at once and adds the directive once. The rewrite replaces the whole `?? fallback` coalesce, which the base covers unchanged; only the binding probe differs, since the replacement binds to `Option.GetOrElse` in `Funcky.Monads` rather than to a member of `Funcky.Extensions`, so the fix overrides `TryApplyAsync` with a predicate that takes any bound method as proof the directive is in place. Two tests with three and four fixes per document, with the usings at file level and inside the namespace, failed before with "Expected '1' iterations but found '2' iterations". Closes #1020 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
FreeApophis
force-pushed
the
prefer-or-none-fix-all
branch
from
October 29, 2026 12:45
69b64a2 to
c6573a2
Compare
JudoJosef
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1013 (
fix-all-using-insertion). Retarget tomainafter #1013 merges; the diff then shows only this commit.Closes #1020
What
The λ1012 code fix (prefer
…OrNone()over…OrDefault()with a null check) insertedusing Funcky.Extensions;through its own path with the defaultBatchFixer, so three or more diagnostics in one document that all needed the directive collided and some were only rewritten by a second Fix-All pass, the same defect as #1009.PreferOrNoneCodeFixnow derives from theExtensionMemberCodeFixbase introduced by #1013: document-based Fix-All provider, all flagged calls of a document rewritten at once, the directive added once. Titles and the single-fix behaviour are unchanged.Notes for the review
xs.FirstOrDefault() ?? fallbackcoalesce withxs.FirstOrNone().GetOrElse(fallback).ExtensionMemberRewrite(Original, Replacement)covers that as-is (Originalis the coalesce), no change to the base.IsDeclaredInFunckyExtensionschecks the symbol of the whole replacement, which here isOption<T>.GetOrElseinFuncky.Monads, so it would always add the using. The fix overridesTryApplyAsyncwithsymbol is IMethodSymbol:GetOrElseonly binds when its…OrNone()receiver binds, which needs the directive. This corresponds to the oldIsExtensionsNamespaceImportedcheck; the old code also accepted a non-emptyCandidateSymbolsset, which the base'sFunc<ISymbol?, bool>cannot see. No existing test needed it.ThreeFixesThatAllNeedTheUsingAreAppliedInOnePass(four fixes, file-level usings) andThreeFixesInANamespaceThatAllNeedTheUsingAreAppliedInOnePass(three fixes, usings inside the namespace) both failed on the base branch withExpected '1' iterations but found '2' iterations., confirming the defect.dotnet build Funcky.slnx -warnaserrorclean, analyzer tests 248/248 green.🤖 Generated with Claude Code