diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 214002c1b..4a1417bc0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ CA1822;CS1591;CS0649;xUnit1026;xUnit1013;CS1573;VerifyTestsProjectDir;VerifySetParameters;PolyFillTargetsForNuget - 28.7.1 + 28.8.0 enable preview 1.0.0 diff --git a/src/Verify.Tests/Serialization/EnsureScrubbingParameters.Test.verified.txt b/src/Verify.Tests/Serialization/EnsureScrubbingParameters.Test.verified.txt new file mode 100644 index 000000000..265095090 --- /dev/null +++ b/src/Verify.Tests/Serialization/EnsureScrubbingParameters.Test.verified.txt @@ -0,0 +1 @@ +new value \ No newline at end of file diff --git a/src/Verify.Tests/Serialization/EnsureScrubbingParameters.cs b/src/Verify.Tests/Serialization/EnsureScrubbingParameters.cs new file mode 100644 index 000000000..3c80ae064 --- /dev/null +++ b/src/Verify.Tests/Serialization/EnsureScrubbingParameters.cs @@ -0,0 +1,15 @@ +public class EnsureScrubbingParameters +{ + [ModuleInitializer] + public static void Initialize() => + VerifierSettings.AddScrubber((builder, counter, settings) => + { + Assert.NotNull(counter); + Assert.NotNull(settings); + builder.Replace("EnsureScrubbingParameters", "new value"); + }); + + [Fact] + public Task Test() => + Verify("EnsureScrubbingParameters"); +} \ No newline at end of file diff --git a/src/Verify/Serialization/Scrubbers/ApplyScrubbers.cs b/src/Verify/Serialization/Scrubbers/ApplyScrubbers.cs index 04bfdfc8a..5420df83c 100644 --- a/src/Verify/Serialization/Scrubbers/ApplyScrubbers.cs +++ b/src/Verify/Serialization/Scrubbers/ApplyScrubbers.cs @@ -129,7 +129,7 @@ public static void ApplyForExtension(string extension, StringBuilder target, Ver foreach (var scrubber in VerifierSettings.GlobalScrubbers) { - scrubber(target, counter); + scrubber(target, counter, settings); } foreach (var replace in replacements) @@ -157,7 +157,7 @@ public static void ApplyForPropertyValue(VerifySettings settings, Counter counte foreach (var scrubber in VerifierSettings.GlobalScrubbers) { - scrubber(builder, counter); + scrubber(builder, counter, settings); } foreach (var replace in replacements) diff --git a/src/Verify/Serialization/Scrubbers/VerifierSettings_GlobalScrubbers.cs b/src/Verify/Serialization/Scrubbers/VerifierSettings_GlobalScrubbers.cs index 382131834..a621da7ed 100644 --- a/src/Verify/Serialization/Scrubbers/VerifierSettings_GlobalScrubbers.cs +++ b/src/Verify/Serialization/Scrubbers/VerifierSettings_GlobalScrubbers.cs @@ -2,21 +2,24 @@ public static partial class VerifierSettings { - internal static List> GlobalScrubbers = []; + internal static List> GlobalScrubbers = []; /// /// Modify the resulting test content using custom code. /// - public static void AddScrubber(Action scrubber, ScrubberLocation location = ScrubberLocation.First) - { - InnerVerifier.ThrowIfVerifyHasBeenRun(); - AddScrubber((builder, _) => scrubber(builder), location); - } + public static void AddScrubber(Action scrubber, ScrubberLocation location = ScrubberLocation.First) => + AddScrubber((builder, _, _) => scrubber(builder), location); + + /// + /// Modify the resulting test content using custom code. + /// + public static void AddScrubber(Action scrubber, ScrubberLocation location = ScrubberLocation.First) => + AddScrubber((builder, counter, _) => scrubber(builder, counter), location); /// /// Modify the resulting test content using custom code. /// - public static void AddScrubber(Action scrubber, ScrubberLocation location = ScrubberLocation.First) + public static void AddScrubber(Action scrubber, ScrubberLocation location = ScrubberLocation.First) { InnerVerifier.ThrowIfVerifyHasBeenRun(); switch (location)