Add a language attribute code fix and MA0218/MA0219 for XML comments - #1320
Merged
Merged
Conversation
MA0154 could only be fixed by replacing the element with <see langword="..." />. Add a second code fix that adds an empty language attribute instead, which is the right fix when the content is not a C# keyword. It does not support fix all, as the value has to be filled in by the user. Add two rules to the same analyzer: - MA0218 (info): the language (or lang) attribute is set but empty - MA0219 (hidden): the <c>/<code> element has no language, lang, or langword attribute. It is not reported when MA0154 already suggests using langword.
This was referenced Aug 26, 2026
Closed
Bump Meziantou.Analyzer from 3.0.103 to 3.0.182
Analogy-LogViewer/Analogy.LogViewer.OpenTelemetry#98
Closed
Closed
Closed
Closed
Bump Meziantou.Analyzer from 3.0.139 to 3.0.189
Analogy-LogViewer/Analogy.LogViewer.NLog.Targets#556
Closed
This was referenced Sep 14, 2026
Closed
Open
Bump Meziantou.Analyzer from 3.0.139 to 3.0.258
Analogy-LogViewer/Analogy.LogViewer.NLog.Targets#573
Open
Open
Bump Meziantou.Analyzer from 3.0.139 to 3.0.258
Analogy-LogViewer/Analogy.AspNetCore.LogProvider#556
Open
Open
Open
Open
Open
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.
What
Extends the MA0154 analyzer file with a second code fix and two new rules.
New code fix for MA0154 —
UseLangwordInXmlCommentAddLanguageAttributeFixer<c>void</c>could only be fixed by replacing the element with<see langword="void" />. The new fix adds an emptylanguageattribute instead (<c language="">void</c>), which is the right answer when the content is not meant to be a C# keyword. It intentionally does not support fix all (GetFixAllProvider() => null), since the user has to fill in the value.MA0218 — The language attribute is empty (info, enabled by default)
Reports a
language/langattribute on<c>/<code>that has no value (whitespace-only counts as empty). The diagnostic is on the attribute itself. This is the follow-up to the new code fix, which produceslanguage="".MA0219 — Set the language attribute in XML comment (hidden, enabled by default)
Reports a
<c>/<code>element that has nolanguage,lang, orlangwordattribute. Being hidden, it does not show up in the build, but the "Add language attribute" fix is offered in the IDE, and the severity can be raised via editorconfig.Notes for the reviewer
<c>void</c>, MA0154 already suggests<see langword="void" />, so asking for a language attribute on the same span would be contradictory. Thecontinuein the analyzer is what implements this.languageis what the code fix writes and what the rule titles/docs use, butlangis still detected by MA0218/MA0219 so existing comments are handled.README.md,docs/README.md, the five packed.editorconfig) were refreshed withdotnet run --project src/DocumentationGenerator, which re-runs clean.Validation
dotnet buildon the solution: 0 warnings, 0 errors.Meziantou.Analyzer.Test.roslyn5.9suite: 3791/3791 passing.UseLangwordInXmlCommentAnalyzerTestson roslyn5.9 and roslyn4.8: 26/26 each.