Skip to content

Commit 792ec86

Browse files
committed
Upgraded to AngleSharp 0.14.0
1 parent 99082bd commit 792ec86

4 files changed

Lines changed: 55 additions & 113 deletions

File tree

src/bunit.core.tests/bunit.core.tests.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="AngleSharp" Version="0.13.0" />
12-
<PackageReference Include="AngleSharp.Css" Version="0.13.0" />
13-
<PackageReference Include="AngleSharp.Diffing" Version="0.13.3-alpha-44" />
11+
<PackageReference Include="AngleSharp" Version="0.14.0" />
12+
<PackageReference Include="AngleSharp.Css" Version="0.14.0" />
13+
<PackageReference Include="AngleSharp.Diffing" Version="0.14.0" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
1515
<PackageReference Include="Moq" Version="4.13.1" />
1616
<PackageReference Include="Shouldly" Version="4.0.0-beta0002" />
@@ -19,7 +19,10 @@
1919
<PrivateAssets>all</PrivateAssets>
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2121
</PackageReference>
22-
<PackageReference Include="coverlet.collector" Version="1.2.0" />
22+
<PackageReference Include="coverlet.collector" Version="1.2.1">
23+
<PrivateAssets>all</PrivateAssets>
24+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
25+
</PackageReference>
2326
</ItemGroup>
2427

2528
<ItemGroup>
Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
<IsPackable>false</IsPackable>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<IsPackable>false</IsPackable>
66
<RootNamespace>Bunit</RootNamespace>
77
<AssemblyName>Bunit.Web.Tests</AssemblyName>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="AngleSharp" Version="0.13.0" />
12-
<PackageReference Include="AngleSharp.Css" Version="0.13.0" />
13-
<PackageReference Include="AngleSharp.Diffing" Version="0.13.3-alpha-44" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
11+
<PackageReference Include="AngleSharp" Version="0.14.0" />
12+
<PackageReference Include="AngleSharp.Css" Version="0.14.0" />
13+
<PackageReference Include="AngleSharp.Diffing" Version="0.14.0" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
1515
<PackageReference Include="Moq" Version="4.13.1" />
1616
<PackageReference Include="Shouldly" Version="4.0.0-beta0002" />
17-
<PackageReference Include="xunit" Version="2.4.1" />
17+
<PackageReference Include="xunit" Version="2.4.1" />
1818
<PackageReference Include="Xunit.SkippableFact" Version="1.3.12" />
19-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
20-
<PrivateAssets>all</PrivateAssets>
21-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22-
</PackageReference>
23-
<PackageReference Include="coverlet.collector" Version="1.2.0" />
24-
</ItemGroup>
19+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
20+
<PrivateAssets>all</PrivateAssets>
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
</PackageReference>
23+
<PackageReference Include="coverlet.collector" Version="1.2.1">
24+
<PrivateAssets>all</PrivateAssets>
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
</PackageReference>
27+
</ItemGroup>
2528

2629
<ItemGroup>
27-
<ProjectReference Include="..\bunit.core\bunit.core.csproj" />
28-
<ProjectReference Include="..\bunit.web\bunit.web.csproj" />
29-
<ProjectReference Include="..\bunit.xunit\bunit.xunit.csproj" />
30+
<ProjectReference Include="..\bunit.core\bunit.core.csproj" />
31+
<ProjectReference Include="..\bunit.web\bunit.web.csproj" />
32+
<ProjectReference Include="..\bunit.xunit\bunit.xunit.csproj" />
3033
</ItemGroup>
3134

3235
</Project>

src/bunit.web/Diffing/DiffMarkupFormatter.cs

Lines changed: 25 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,107 +6,43 @@
66

77
namespace Bunit.Diffing
88
{
9-
// /// <summary>
10-
// /// A markup formatter, that skips any special Blazor attributes added by the <see cref="TestRenderer"/>/<see cref="Htmlizer"/>.
11-
// /// </summary>
12-
//public class DiffMarkupFormatter : PrettyMarkupFormatter, IMarkupFormatter
13-
//{
14-
// /// <summary>
15-
// /// Gets an instance of the <see cref="DiffMarkupFormatter"/>.
16-
// /// </summary>
17-
// public new static readonly DiffMarkupFormatter Instance = new DiffMarkupFormatter();
18-
19-
// /// <summary>
20-
// /// Creates an instance of the <see cref="DiffMarkupFormatter"/>.
21-
// /// </summary>
22-
// public DiffMarkupFormatter()
23-
// {
24-
// NewLine = Environment.NewLine;
25-
// Indentation = " ";
26-
// }
27-
28-
// /// <summary>
29-
// /// Creates the string representation of the attribute.
30-
// /// </summary>
31-
// /// <param name="attr">The attribute to serialize.</param>
32-
// /// <returns>The string representation.</returns>
33-
// public string ConvertToString(IAttr attr) => base.Attribute(attr);
34-
35-
// /// <summary>
36-
// /// Creates the string representation of the attribute.
37-
// /// If it is a special Blazor renderer attribute, then it is ignored.
38-
// /// </summary>
39-
// /// <param name="attr">The attribute to serialize.</param>
40-
// /// <returns>The string representation.</returns>
41-
// protected override string Attribute(IAttr attr)
42-
// {
43-
// return Htmlizer.IsBlazorAttribute(attr?.Name ?? string.Empty)
44-
// ? string.Empty
45-
// : base.Attribute(attr);
46-
// }
47-
//}
48-
499
/// <summary>
5010
/// A markup formatter, that skips any special Blazor attributes added by the <see cref="TestRenderer"/>/<see cref="Htmlizer"/>.
5111
/// </summary>
52-
public class DiffMarkupFormatter : IMarkupFormatter
12+
public class DiffMarkupFormatter : PrettyMarkupFormatter, IMarkupFormatter
5313
{
54-
private readonly IMarkupFormatter _formatter = new PrettyMarkupFormatter()
55-
{
56-
NewLine = Environment.NewLine,
57-
Indentation = " "
58-
};
14+
/// <summary>
15+
/// Gets an instance of the <see cref="DiffMarkupFormatter"/>.
16+
/// </summary>
17+
public new static readonly DiffMarkupFormatter Instance = new DiffMarkupFormatter();
5918

60-
public static readonly DiffMarkupFormatter Instance = new DiffMarkupFormatter();
19+
/// <summary>
20+
/// Creates an instance of the <see cref="DiffMarkupFormatter"/>.
21+
/// </summary>
22+
public DiffMarkupFormatter()
23+
{
24+
NewLine = Environment.NewLine;
25+
Indentation = " ";
26+
}
6127

6228
/// <summary>
63-
/// Creates the string representation of the attribute.
29+
/// Creates the string representation of the attribute.
6430
/// </summary>
6531
/// <param name="attr">The attribute to serialize.</param>
6632
/// <returns>The string representation.</returns>
67-
public string ConvertToString(IAttr attr) => _formatter.Attribute(attr);
68-
69-
/// <inheritdoc />
70-
public string Attribute(IAttr attribute)
71-
=> Htmlizer.IsBlazorAttribute(attribute?.Name ?? string.Empty)
72-
? string.Empty
73-
: _formatter.Attribute(attribute);
74-
75-
/// <inheritdoc />
76-
public string CloseTag(IElement element, bool selfClosing) => _formatter.CloseTag(element, selfClosing);
33+
public string ConvertToString(IAttr attr) => base.Attribute(attr);
7734

78-
/// <inheritdoc />
79-
public string Comment(IComment comment) => _formatter.Comment(comment);
80-
81-
/// <inheritdoc />
82-
public string Doctype(IDocumentType doctype) => _formatter.Doctype(doctype);
83-
84-
public string LiteralText(ICharacterData text) => throw new NotImplementedException();
85-
86-
/// <inheritdoc />
87-
public string OpenTag(IElement element, bool selfClosing)
35+
/// <summary>
36+
/// Creates the string representation of the attribute.
37+
/// If it is a special Blazor renderer attribute, then it is ignored.
38+
/// </summary>
39+
/// <param name="attr">The attribute to serialize.</param>
40+
/// <returns>The string representation.</returns>
41+
protected override string Attribute(IAttr attr)
8842
{
89-
if (element is null)
90-
throw new ArgumentNullException(nameof(element));
91-
92-
var result = _formatter.OpenTag(element, selfClosing);
93-
94-
foreach (var attr in element.Attributes)
95-
{
96-
if (Htmlizer.IsBlazorAttribute(attr.Name))
97-
{
98-
var attrToRemove = " " + HtmlMarkupFormatter.Instance.Attribute(attr);
99-
result = result.Replace(attrToRemove, "", StringComparison.Ordinal);
100-
}
101-
}
102-
103-
return result;
43+
return Htmlizer.IsBlazorAttribute(attr?.Name ?? string.Empty)
44+
? string.Empty
45+
: base.Attribute(attr);
10446
}
105-
106-
/// <inheritdoc />
107-
public string Processing(IProcessingInstruction processing) => _formatter.Processing(processing);
108-
109-
/// <inheritdoc />
110-
public string Text(ICharacterData text) => _formatter.Text(text);
11147
}
11248
}

src/bunit.web/bunit.web.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="AngleSharp" Version="0.13.0" />
13-
<PackageReference Include="AngleSharp.Css" Version="0.13.0" />
14-
<PackageReference Include="AngleSharp.Diffing" Version="0.13.3-alpha-44" />
15-
<PackageReference Include="AngleSharp.Wrappers" Version="1.1.0" />
12+
<PackageReference Include="AngleSharp" Version="0.14.0" />
13+
<PackageReference Include="AngleSharp.Css" Version="0.14.0" />
14+
<PackageReference Include="AngleSharp.Diffing" Version="0.14.0" />
15+
<PackageReference Include="AngleSharp.Wrappers" Version="1.2.0" />
1616
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.*" />
1717
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.*" />
1818
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.*" />

0 commit comments

Comments
 (0)