Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Fallout.Migrate/Steps/RewriteCsprojsStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal sealed class RewriteCsprojsStep : IMigrationStep
// (ADR-0010), so a migrated project must not carry a dead <FalloutTelemetryVersion>.
// Matches the whole element line (either legacy Nuke* or already-Fallout* spelling).
private static readonly Regex telemetryVersionPropertyPattern = new(
@"^[ \t]*<(?<tag>(?:Nuke|Fallout)TelemetryVersion)>.*?</\k<tag>>\s*\r?\n?",
@"^[ \t]*<(?<tag>(?:Nuke|Fallout)TelemetryVersion)>.*?</\k<tag>>[ \t]*\r?\n?",
RegexOptions.Compiled | RegexOptions.Multiline);

// Strip explicit `System.Security.Cryptography.Xml` PackageReferences. NUKE-era projects
Expand All @@ -55,7 +55,7 @@ internal sealed class RewriteCsprojsStep : IMigrationStep
// migrated project wants (#217). Matches a self-closing element with optional surrounding
// indentation + trailing newline.
private static readonly Regex cryptographyXmlPackageRefPattern = new(
@"^[ \t]*<PackageReference\s+Include=""System\.Security\.Cryptography\.Xml""[^/]*/>\s*\r?\n?",
@"^[ \t]*<PackageReference\s+Include=""System\.Security\.Cryptography\.Xml""[^/]*/>[ \t]*\r?\n?",
RegexOptions.Compiled | RegexOptions.Multiline);

/// <inheritdoc />
Expand Down
46 changes: 46 additions & 0 deletions tests/Fallout.Migrate.Specs/RewriteCsprojsStepSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,50 @@ public void Other_system_packages_are_left_alone()
result.EditCount.Should().Be(0);
result.Content.Should().Be(input);
}

[Fact]
public void Telemetry_remove_pattern_does_not_act_greedy()
{
const string input = """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<FalloutTelemetryVersion>1</FalloutTelemetryVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
</Project>
""";

var result = RewriteCsprojsStep.Rewrite(input, TestFalloutVersion);

result.Content.Should().Be("""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>
</Project>
""");
}

[Fact]
public void Cryptography_package_pin_remove_pattern_does_not_act_greedy()
{
const string input = """
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Fallout.Common" Version="10.3.49" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="10.0.10" />
</ItemGroup>
</Project>
""";

var result = RewriteCsprojsStep.Rewrite(input, TestFalloutVersion);

result.Content.Should().Be("""
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Fallout.Common" Version="10.3.49" />
</ItemGroup>
</Project>
""");
}
}
Loading