Skip to content

Commit ec8dfd8

Browse files
committed
Keep the vendored DiffPlex internal and drop what Pester does not call
Vendoring put 20 DiffPlex types into Pester's public API. Nothing asked for that, and it would make the vendored library part of the compatibility surface, so replacing it or updating it across a breaking change becomes our problem. Every vendored type is internal now. Pester exposes one method, Pester.StringDiff.Format, which takes the two strings and returns the part of the failure message that describes how they differ. StringDiffResult and Compare are internal, and PesterTests sees them through InternalsVisibleTo. The files were already modified, so there was no reason to keep code we never call. pester.patch removes Differ's convenience methods, IDiffer, ISideBySideDiffBuilder, and the SideBySideDiffBuilder constructors and static helpers that default to LineChunker. Five files then have nothing referring to them and are not vendored at all. 19 files became 14, and Pester.dll grows by 22 KB per target framework instead of 24 KB. WordChunker and DelimiterChunker stay. SideBySideDiffBuilder uses them for the word level sub pieces on a changed line, which we do not render yet, and highlighting the changed part inside a line is the obvious next thing to do to this message. Cutting them means editing the core of SideBySideDiffBuilder rather than deleting whole members. Deleting code is what breaks a vendored copy, because a hand-trimmed one diverges quietly and nobody can tell what was changed on purpose. So the removals are kept as a patch, not applied by hand. Update-VendoredDiffPlex.ps1 rebuilds the whole thing from upstream, applies the namespace rewrite, the internal rewrite and the header, then applies pester.patch, and -Verify compares that against what is on disk. Running it against a newer DiffPlex either works or git says which hunk failed. -Regenerate rewrites the patch after a deliberate hand edit. 🤖
1 parent 87e76ed commit ec8dfd8

25 files changed

Lines changed: 422 additions & 420 deletions

src/csharp/Pester/DiffPlex/Chunkers/CharacterChunker.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/csharp/Pester/DiffPlex/Chunkers/CustomFunctionChunker.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/csharp/Pester/DiffPlex/Chunkers/DelimiterChunker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Vendored from DiffPlex 1.9.0, https://github.com/mmanela/diffplex
22
// Copyright (c) Matthew Manela. Licensed under the Apache License, Version 2.0.
33
// See LICENSE.txt and VENDORING.md in this folder.
4-
// Modified by the Pester Team: the namespace is Pester.DiffPlex instead of DiffPlex.
4+
// Modified by the Pester Team, see VENDORING.md. Rebuild with Update-VendoredDiffPlex.ps1.
55
using System;
66
using System.Collections.Generic;
77

88
namespace Pester.DiffPlex.Chunkers
99
{
10-
public class DelimiterChunker : IChunker
10+
internal class DelimiterChunker : IChunker
1111
{
1212
private readonly char[] delimiters;
1313

src/csharp/Pester/DiffPlex/Chunkers/LineChunker.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/csharp/Pester/DiffPlex/Chunkers/LineEndingsPreservingChunker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Vendored from DiffPlex 1.9.0, https://github.com/mmanela/diffplex
22
// Copyright (c) Matthew Manela. Licensed under the Apache License, Version 2.0.
33
// See LICENSE.txt and VENDORING.md in this folder.
4-
// Modified by the Pester Team: the namespace is Pester.DiffPlex instead of DiffPlex.
4+
// Modified by the Pester Team, see VENDORING.md. Rebuild with Update-VendoredDiffPlex.ps1.
55
using System.Collections.Generic;
66

77
namespace Pester.DiffPlex.Chunkers
88
{
9-
public class LineEndingsPreservingChunker:IChunker
9+
internal class LineEndingsPreservingChunker:IChunker
1010
{
1111
private static readonly string[] EmptyArray = new string[0];
1212

src/csharp/Pester/DiffPlex/Chunkers/WordChunker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Vendored from DiffPlex 1.9.0, https://github.com/mmanela/diffplex
22
// Copyright (c) Matthew Manela. Licensed under the Apache License, Version 2.0.
33
// See LICENSE.txt and VENDORING.md in this folder.
4-
// Modified by the Pester Team: the namespace is Pester.DiffPlex instead of DiffPlex.
4+
// Modified by the Pester Team, see VENDORING.md. Rebuild with Update-VendoredDiffPlex.ps1.
55
namespace Pester.DiffPlex.Chunkers
66
{
7-
public class WordChunker:DelimiterChunker
7+
internal class WordChunker:DelimiterChunker
88
{
99
private static char[] WordSeparators { get; } = { ' ', '\t', '.', '(', ')', '{', '}', ',', '!', '?', ';' };
1010

src/csharp/Pester/DiffPlex/DiffBuilder/ISideBySideDiffBuilder.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/csharp/Pester/DiffPlex/DiffBuilder/Model/DiffPaneModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Vendored from DiffPlex 1.9.0, https://github.com/mmanela/diffplex
22
// Copyright (c) Matthew Manela. Licensed under the Apache License, Version 2.0.
33
// See LICENSE.txt and VENDORING.md in this folder.
4-
// Modified by the Pester Team: the namespace is Pester.DiffPlex instead of DiffPlex.
4+
// Modified by the Pester Team, see VENDORING.md. Rebuild with Update-VendoredDiffPlex.ps1.
55
using System.Collections.Generic;
66
using System.Linq;
77

88
namespace Pester.DiffPlex.DiffBuilder.Model
99
{
10-
public class DiffPaneModel
10+
internal class DiffPaneModel
1111
{
1212
public List<DiffPiece> Lines { get; }
1313

src/csharp/Pester/DiffPlex/DiffBuilder/Model/DiffPiece.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Vendored from DiffPlex 1.9.0, https://github.com/mmanela/diffplex
22
// Copyright (c) Matthew Manela. Licensed under the Apache License, Version 2.0.
33
// See LICENSE.txt and VENDORING.md in this folder.
4-
// Modified by the Pester Team: the namespace is Pester.DiffPlex instead of DiffPlex.
4+
// Modified by the Pester Team, see VENDORING.md. Rebuild with Update-VendoredDiffPlex.ps1.
55
using System;
66
using System.Collections.Generic;
77

88
namespace Pester.DiffPlex.DiffBuilder.Model
99
{
10-
public enum ChangeType
10+
internal enum ChangeType
1111
{
1212
Unchanged,
1313
Deleted,
@@ -16,7 +16,7 @@ public enum ChangeType
1616
Modified
1717
}
1818

19-
public class DiffPiece : IEquatable<DiffPiece>
19+
internal class DiffPiece : IEquatable<DiffPiece>
2020
{
2121
public ChangeType Type { get; set; }
2222
public int? Position { get; set; }

src/csharp/Pester/DiffPlex/DiffBuilder/Model/SideBySideDiffModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Vendored from DiffPlex 1.9.0, https://github.com/mmanela/diffplex
22
// Copyright (c) Matthew Manela. Licensed under the Apache License, Version 2.0.
33
// See LICENSE.txt and VENDORING.md in this folder.
4-
// Modified by the Pester Team: the namespace is Pester.DiffPlex instead of DiffPlex.
4+
// Modified by the Pester Team, see VENDORING.md. Rebuild with Update-VendoredDiffPlex.ps1.
55
namespace Pester.DiffPlex.DiffBuilder.Model
66
{
77
/// <summary>
88
/// A model which represents differences between to texts to be shown side by side
99
/// </summary>
10-
public class SideBySideDiffModel
10+
internal class SideBySideDiffModel
1111
{
1212
public DiffPaneModel OldText { get; }
1313
public DiffPaneModel NewText { get; }

0 commit comments

Comments
 (0)