Repository navigation
Conversation
…es in fallout-migrate Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…rate Now that RewriteCsprojsStep also rewrites *.props files, a System.Security.Cryptography.Xml reference in a root Directory.Build.props was removed too. That reference applies to every project in the repository, not only the build project, so it is kept. Also mention *.props and central package versions in the migration step skill and in docs/Migration/from-nuke.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ChrisonSimtian
left a comment
There was a problem hiding this comment.
One blocking issue, the rest are optional.
Blocking: <FalloutVersion> is added to unrelated .csproj/.props files when any variable is ambiguous (reproduced, see the inline comment on line 206).
The design is sound: classifying version variables over all files first is the right fix for the imported Version.props case in #492. The specs are well chosen and follow the repo conventions.
…ut-migrate Review feedback on the central package versions change: - Add the FalloutVersion property only to a file where a reference was redirected to $(FalloutVersion). Before, every .csproj and .props file got the property when any version variable was shared with another package. - Keep a version range such as [10.1.0,) as written. Before, only the lower bound was replaced, which left an invalid range. - Report a file that can't be read because of missing permissions as a warning instead of stopping the run. - Find a version variable when the Version attribute comes before Include. - Merge the two Nuke. prefix patterns into one and document that ambiguity is decided by variable name over all files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@ChrisonSimtian All 5 points are addressed in b54279c, with a reply on each thread. Ready for another review. (I can't re-request review myself, because I don't have triage permission on this repo.) CI for b54279c is waiting for approval from a maintainer. Could you approve the two |
dennisdoomen
left a comment
There was a problem hiding this comment.
Impressive change, but because all the AI slop, it needs some rework to be understandable by us mere mortals.
| // produce NU1603 ("not found, falling back to next-higher") which `WarningsAsErrors` in the | ||
| // migrated project escalates. Pinning in the same pass avoids a broken post-migrate build | ||
| // (#217). MSBuild variables (`$(...)`) are handled by HandleMsBuildVariable below. | ||
| private static readonly Regex packageItemPattern = new( |
There was a problem hiding this comment.
🔧 We need to start clarifying all these regexes in a human-friendly way. Like this one
/// <summary>
/// Finds the opening tag of a NuGet package element in an MSBuild file.
/// It matches <c><PackageReference></c>, <c><PackageVersion></c>,
/// and <c><PackageDownload></c>.
/// </summary>
/// <remarks>
/// The match is the whole opening tag, including all attributes.
/// It does not return the package name or version as separate values.
/// The match is case-sensitive. A <c>></c> character inside an attribute value
/// ends the match early.
/// </remarks>Same for the other regexes that got affected by this PR
There was a problem hiding this comment.
Done in 276ae8a. The shared regexes live in MsBuildPatterns.cs now, and every regex has a <summary> and <remarks> in the style of your example.
There was a problem hiding this comment.
Follow-up: b4500df writes every pattern as a raw string literal and keeps the group names next to their pattern. Would you rather we replace these regexes with structured XML editing, for example XDocument with LoadOptions.PreserveWhitespace (Fallout.Utilities' ReadXml already loads that way)? Renames and version pins would then work on elements and attributes instead of text, so findings like the attribute-order and version-range ones could not happen. I'd do that as a separate PR after this one, since most of these regexes predate it.
…r behavior TryRead reads with File.ReadAllText. AbsolutePath.ReadAllText throws an ArgumentException for a missing path before it reads, so that file was not reported as a warning and the unreadable-file spec failed. The specs say "redirected to FalloutVersion" instead of "decoupled". The new spec lines use explicit types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@dennisdoomen @ChrisonSimtian Ready for another look. I replied on each thread. Changes since your reviews:
The CI failure on 276ae8a came from my new spec. It is fixed in 167947c, and CI is green. Could a maintainer add the Once you're both happy, I'll fold the review commits into the commits they belong to and rebase onto |
|
@dennisdoomen @ChrisonSimtian A scope question before your next look. #686 (fallout-migrate 10.4.0 leftovers) has one open point. When the migration removes the The fix belongs in the code this PR moves to Should I add it to this PR? Otherwise I'll open a separate PR after this one merges. A separate PR now would conflict with this one. |
Every pattern is now a raw string literal, so quotes read as quotes instead of doubled "" escapes (AV1582). The renamed Nuke* properties are a named list instead of one long alternation. The include and variable group names stay next to their pattern behind PackageNameOf and VariableNameOf, and replacing the variable inside a matched tag is the named ReplaceGroupValue helper. The patterns themselves are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Please include it here as well. |
|
|
||
| return (variablesToBump, ambiguousVariables); | ||
| // Only a file with a redirected reference needs a property, and only if no file defines it. | ||
| return edits > 0 && !variables.DefinesFalloutVersion |
There was a problem hiding this comment.
⛏️ DefinesFalloutVersion is computed before any file is rewritten. If several files have a redirected reference and no file defines FalloutVersion yet, each of those files gets its own <FalloutVersion>. For example, Directory.Packages.props and a .csproj that both use a shared variable. The values are the same, so nothing breaks, but the definitions are redundant. Optional: add the property to one file only, for example the first one that needs it.
There was a problem hiding this comment.
I kept one property per file that needs it. Your example is safe, because every project imports Directory.Packages.props. But two project files that each need the property would break if only the first one got it. A property in one project file is not visible in another, and this step does not follow MSBuild imports. 8c30f3c adds a comment that says this.
| content = content.Insert( | ||
| propertyGroupIndex + "<PropertyGroup>".Length, | ||
| $"\n <{falloutVersionVariable}>{falloutVersion}</{falloutVersionVariable}>"); | ||
| $"\n <FalloutVersion>{falloutVersion}</FalloutVersion>"); |
There was a problem hiding this comment.
⛏️ This always inserts \n, here and in the fallback on line 185. In a file with CRLF line endings, the result has mixed line endings. Consider using the file's own line ending, for example content.Contains("\r\n") ? "\r\n" : "\n".
There was a problem hiding this comment.
Fixed in 8c30f3c. Both insertions now use the file's own line ending. A spec covers a CRLF file with and without a PropertyGroup.
| /// Property names and values are case-sensitive. | ||
| /// </remarks> | ||
| private static Regex CreatePropertyValuePattern(string variableName) => | ||
| new($"""(?<=<{variableName}\s*>)[^<]+(?=</{variableName}\s*>)"""); |
There was a problem hiding this comment.
⛏️ variableName comes from the file content and goes into the pattern without Regex.Escape. MSBuild property names are normally safe, but escaping it costs nothing and protects against unexpected input.
There was a problem hiding this comment.
Fixed in 8c30f3c. The name is escaped now. A spec uses $(Odd[Name), which crashed the run before.
| /// dependency version to win. A pin in a shared props file is kept because it affects other projects. | ||
| /// </remarks> | ||
| public static readonly Regex CryptographyXmlPackageReference = new( | ||
| """^[ \t]*<PackageReference\s+Include="System\.Security\.Cryptography\.Xml"[^/]*/>[ \t]*\r?\n?""", |
There was a problem hiding this comment.
⛏️ This pattern still requires Include as the first attribute, so <PackageReference Version="..." Include="System.Security.Cryptography.Xml" /> is not removed. The remarks document this, and it was the same before this PR. Optional, since the other patterns now accept either attribute order. Could also go in the follow-up for #686.
There was a problem hiding this comment.
Fixed here in 8c30f3c. The pattern now finds Include in any position, and a spec covers Version before Include.
iirc then we did this to leave behind a breadcrumb of what we did, so Id say keep it I'll look at the rest once im in front of a screen 😊 |
…ibute order The inserted FalloutVersion property now uses the file's own line ending, so a CRLF file no longer gets mixed line endings. A version variable name comes from the file, so it is escaped before it goes into the property pattern. A name such as Odd[Name crashed the run before. The System.Security.Cryptography.Xml pin is now removed when Version comes before Include, like the other package patterns. A comment says why each file with a redirected reference gets its own FalloutVersion property. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@dennisdoomen @ChrisonSimtian Changes since your last review: https://github.com/Fallout-build/Fallout/pull/694/files/b4500df807dacc16ea07d8cdc9c8f41c024b23a0..8c30f3c0a7f7360ad9b09e6dfc4db5a69dd8f3cc. I replied on each thread. About the comment above the removed CI: all tests pass on 8c30f3c. One |
Rewrite central package versions and version properties in
.propsfiles, so a repository with central package management (Directory.Packages.props) restores afterfallout-migrate.What changed
RewriteCsprojsSteprewrites*.propsfiles as well as*.csprojfiles.PackageReference,PackageVersion,PackageDownload) go fromNuke.XtoFallout.X. A literalVersionorVersionOverrideis pinned to the current Fallout version, in either attribute order. Version ranges stay as written.PackageDownloadkeeps its[exact]brackets. An item that is alreadyFallout.Xkeeps its version.Nuke.*packages is bumped in the file that defines it, such as an importedVersion.props.<NukeVersion>becomes<FalloutVersion>.$(FalloutVersion). That property is added to a file with a redirected reference, and only when no file defines it yet.System.Security.Cryptography.Xmlpin is still removed from*.csprojfiles only. A pin in a*.propsfile applies to every project, so it stays.MsBuildPatterns.csand the variable check inVersionVariables.cs. Each pass of the step is a named method.docs/Migration/from-nuke.mdmention*.propsfiles and central package versions.This builds on #478 (version variable handling) instead of replacing it.
Verification
./build.sh Teston 167947c: all 68Fallout.Migrate.Specspass.RewriteCsprojsStepSpecsand 2 inMigrationFileOperationsSpecs.Closes #492 (NU1010 restore failure in central package management repositories after migration)
🤖 Generated with Claude Code