Skip to content

XML: recognize additional .NET XML file extensions#7448

Merged
macsux merged 5 commits intomainfrom
macsux/xml-dotnet-extensions
Apr 27, 2026
Merged

XML: recognize additional .NET XML file extensions#7448
macsux merged 5 commits intomainfrom
macsux/xml-dotnet-extensions

Conversation

@macsux
Copy link
Copy Markdown
Contributor

@macsux macsux commented Apr 21, 2026

Summary

Extends XmlParser to recognize more .NET XML file formats:

  • Adds targets, slnx, ruleset, and dotsettings to the accepted extension list
  • Accepts App.*.config / Web.*.config XDT transform variants (e.g. Web.Release.config, App.Debug.config)
  • Makes filename matching case-insensitive via lowercase comparison

Test plan

  • New cases added to XmlParserTest.acceptWithValidPaths / acceptWithInvalidPaths
  • ./gradlew :rewrite-xml:test passes

macsux added 4 commits April 21, 2026 19:47
Adds `targets`, `slnx`, `ruleset`, and `dotsettings` to the list of
accepted XML extensions, and accepts `App.*.config` / `Web.*.config`
XDT transform variants (e.g. `Web.Release.config`).
XmlParser was leaving the BOM byte in the input string for the lexer to
choke on, and the XmlPrinter wasn't writing the BOM back out. csproj
files saved by Visual Studio commonly start with a BOM, so we'd round-
trip them without it. Also fixes File.ReadAllText silently stripping
BOMs in RewriteRpcServer when reading project files for parsing.
MSBuild treats `net8` and `net8.0` as the same target framework moniker
(.NET 5+). The recipe was doing strict string equality, so users with
short-form TFMs in their csproj files (or short-form input on the
recipe parameter) would silently no-op. Normalize both sides before
comparing.
Three related fixes for version-spec resolution:

- Accept the OpenRewrite wildcard convention `10.0.x` and translate it
  to NuGet's `10.0.*` so composite migration recipes that pass `x`-form
  specs no longer silently no-op.
- When the NuGet feed query returns nothing (offline, private feed, or
  package not indexed), fall back to the range's MinVersion as the
  upgrade target instead of giving up.
- Recognize a floating `currentVersion` like `14.0.*` when deciding
  whether the project is already at or above the target, comparing
  against `VersionRange.MinVersion` rather than treating it as unknown.
@macsux macsux force-pushed the macsux/xml-dotnet-extensions branch from 246cb97 to 5c83273 Compare April 27, 2026 17:50
CharsetBomMarked is captured from raw file bytes (Roslyn strips the BOM
from the source string before it reaches the parser). The print-equals-
input idempotency check in SolutionParser compares the printer output
against the BOM-stripped source, so emitting `` from the visitor
caused every BOM-marked file to flip to ParseError — breaking
SolutionParserTests.ParseFileWithBomPreservesCharsetBomMarked and
WorkingSetRoundTripTests.CharsetBomMarked_SetFromParser. The flag is
preserved on the LST for downstream patch generation, which is what was
actually needed.
@macsux macsux merged commit 0b668b7 into main Apr 27, 2026
1 check passed
@macsux macsux deleted the macsux/xml-dotnet-extensions branch April 27, 2026 18:49
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant