Use raw literals throughout analyzer tests - #56069
Merged
tannergooding merged 2 commits intoSep 2, 2026
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
eiriktsarpalis
approved these changes
Sep 1, 2026
eiriktsarpalis
left a comment
Member
There was a problem hiding this comment.
Thanks. Would it make sense to have the agent do this across all analyzer tests in the repo? I found success doing the same with the STJ suite recently.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Review tier: Lite
Findings: None
What changed in this PR
This PR refactors the CA1878 unit tests’ embedded C# sources to use C# raw string literals and raw string interpolation, improving readability by removing brace/quote escaping and string.Format scaffolding.
Changes:
- Replaces
string.Format(CultureInfo.InvariantCulture, ...)-based source templates with$$""" ... """raw interpolated string helpers. - Converts embedded test source fragments to raw string literals while keeping single-line fragments single-line.
- Removes the now-unused
System.Globalizationimport.
| File | Description |
|---|---|
| src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/PreferReadOnlySpanPropertiesOverReadOnlyArrayFieldsTests.cs | Switches embedded C# test sources to raw string literals/interpolation for readability and removes string.Format/CultureInfo usage. |
Member
Author
|
Yeah, was just having it do that. It found a lot of them. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
Author
|
@eiriktsarpalis was definitely "a lot", some 185k lines 😂 |
mthalman
approved these changes
Sep 1, 2026
tannergooding
had a problem deploying
to
copilot-pat-pool
September 2, 2026 12:43 — with
GitHub Actions
Failure
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.
Converts multiline embedded C# and Visual Basic source throughout the analyzer tests from verbatim literals to raw string literals. Statically owned source templates now use raw interpolation instead of escaped braces or
string.Format, while runtime-selected composite formats remain unchanged.Removes leading and trailing blank lines and trailing whitespace where they are not required by diagnostic locations, code fixes, or trivia-sensitive coverage. Single-line fragments remain single-line, and the analyzer test guidance now records the convention.
Follow-up to #55901 (comment).
Note
This pull request was drafted with GitHub Copilot.