Repository navigation
fix(analyzers): drop the nonexistent TryGetValue from E128221 - #169
Merged
Merged
Conversation
E128221 told callers to read a union case through TryGetValue. Probed on net11.0 at LangVersion latest and preview, and on Roslyn 5.12.0, a compiler-declared union exposes no TryGetValue member and no HasValue property. The message, the XML doc, and the README now name a case pattern only. Bump E128.Analyzers to 3.1.1 and promote the changed rule rows. Move Microsoft.CodeAnalysis.CSharp and the CodeStyle package to 5.12.0. The band adds C# 15 and union pattern plumbing, with no new IDE rules or style options. Meziantou.Analyzer moves to 3.0.341. Build reports no new diagnostic. Co-Authored-By: Claude
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.
Executive Summary
E128221 reported a
Valueread on a union and told the developer to rewrite it as a pattern or aTryGetValuecall. The second option does not exist. A compiler-declared union exposesValueand case patterns only.Probed on net11.0 at
LangVersionlatestand again atpreview, with Roslyn 5.12.0:result.TryGetValue(out var value)fails with CS1061, andresult.HasValuefails the same way. The rule message, the XML doc, the package README, and the lode rule detail now name the pattern only.Code Changes
UnionValueReadAnalyzer: message and XML doc name a case pattern. No rule id, category, or severity change.src/E128.Analyzers/README.md: E128221 prose and theAfterexample use a pattern. The install version moves to 3.1.1.AnalyzerReleases.Shipped.md: newRelease 3.1.1section carries the E128220 row from Unshipped plus a new E128221 row.E128.Analyzers.csproj: version 3.1.0 to 3.1.1.Directory.Packages.props:Microsoft.CodeAnalysis.CSharp,Microsoft.CodeAnalysis.CSharp.CodeStyle, andMicrosoft.CodeAnalysis.CSharp.Workspacesmove 5.9.0 to 5.12.0.Meziantou.Analyzermoves 3.0.326 to 3.0.341.PolySharpmoves to 1.17.1.lode/dotnet/analyzers/rule-details-union.md: records the probe result and the corrected rule text.lode/dotnet/analyzers/authoring.md: probe timestamp refreshed after the suite passed on the new band.The 5.12.0 band adds the C# 15 language version and union pattern plumbing. IDE diagnostic ids (132) and style options (126) are identical to 5.9.0, so no
.editorconfigentry changes.Tests and Tooling
scripts/check.sh --all: shell lint, format check, build, and full suite pass.AnalysisLevel latest-allandAnalysisMode All.scripts/internal/analyzer-release-check.sh --json: clean.scripts/readme-table-diff.sh --analyzer --json: no drift.Not run: the reference app was not launched against the package. The union probe compiled inside
E128.Reference.Coreand the probe file was removed before commit.Review Guide
Start at
UnionValueReadAnalyzer.csfor the message and doc change. Then read the E128221 section ofsrc/E128.Analyzers/README.md. The rest is version and release bookkeeping.Rollback
Revert the commit. No public API, rule id, category, or severity changes. The version can drop back to 3.1.0 if 3.1.1 has not been published.
Links
🤖 Generated with Claude Code