XML: recognize additional .NET XML file extensions#7448
Merged
Conversation
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.
246cb97 to
5c83273
Compare
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.
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.
Summary
Extends
XmlParserto recognize more .NET XML file formats:targets,slnx,ruleset, anddotsettingsto the accepted extension listApp.*.config/Web.*.configXDT transform variants (e.g.Web.Release.config,App.Debug.config)Test plan
XmlParserTest.acceptWithValidPaths/acceptWithInvalidPaths./gradlew :rewrite-xml:testpasses