Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit 117bbe7

Browse files
committed
Rename AppendEncoded() to AppendHtml() and SetContentEncoded() to SetHtmlContent()
- aspnet/Mvc#3225, 2 of 3 - also correct parameter names
1 parent 6a7082d commit 117bbe7

File tree

3 files changed

+44
-16
lines changed

3 files changed

+44
-16
lines changed

src/Microsoft.AspNet.Razor.Runtime/TagHelpers/DefaultTagHelperContent.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,16 @@ public override bool IsEmpty
122122
}
123123

124124
/// <inheritdoc />
125-
public override TagHelperContent Append(string value)
125+
public override TagHelperContent Append(string unencoded)
126126
{
127-
Buffer.Append(value);
127+
Buffer.Append(unencoded);
128128
return this;
129129
}
130130

131-
public override TagHelperContent AppendEncoded(string value)
131+
/// <inheritdoc />
132+
public override TagHelperContent AppendHtml(string encoded)
132133
{
133-
Buffer.AppendEncoded(value);
134+
Buffer.AppendHtml(encoded);
134135
return this;
135136
}
136137

src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperContent.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ public TagHelperContent SetContent(string unencoded)
6161
/// as-provided and no further encoding will be performed.
6262
/// </param>
6363
/// <returns>A reference to this instance after the set operation has completed.</returns>
64-
public TagHelperContent SetContentEncoded(string encoded)
64+
public TagHelperContent SetHtmlContent(string encoded)
6565
{
66-
HtmlContentBuilderExtensions.SetContentEncoded(this, encoded);
66+
HtmlContentBuilderExtensions.SetHtmlContent(this, encoded);
6767
return this;
6868
}
6969

7070
/// <summary>
71-
/// Appends <paramref name="value"/> to the existing content.
71+
/// Appends <paramref name="unencoded"/> to the existing content.
7272
/// </summary>
73-
/// <param name="value">The <see cref="string"/> to be appended.</param>
73+
/// <param name="unencoded">The <see cref="string"/> to be appended.</param>
7474
/// <returns>A reference to this instance after the append operation has completed.</returns>
75-
public abstract TagHelperContent Append(string value);
75+
public abstract TagHelperContent Append(string unencoded);
7676

7777
/// <summary>
7878
/// Appends <paramref name="htmlContent"/> to the existing content.
@@ -82,12 +82,12 @@ public TagHelperContent SetContentEncoded(string encoded)
8282
public abstract TagHelperContent Append(IHtmlContent htmlContent);
8383

8484
/// <summary>
85-
/// Appends <paramref name="value"/> to the existing content. <paramref name="value"/> is assumed
85+
/// Appends <paramref name="encoded"/> to the existing content. <paramref name="encoded"/> is assumed
8686
/// to be an HTML encoded <see cref="string"/> and no further encoding will be performed.
8787
/// </summary>
88-
/// <param name="value">The <see cref="string"/> to be appended.</param>
88+
/// <param name="encoded">The <see cref="string"/> to be appended.</param>
8989
/// <returns>A reference to this instance after the append operation has completed.</returns>
90-
public abstract TagHelperContent AppendEncoded(string value);
90+
public abstract TagHelperContent AppendHtml(string encoded);
9191

9292
/// <summary>
9393
/// Appends the specified <paramref name="format"/> to the existing content after
@@ -157,9 +157,9 @@ IHtmlContentBuilder IHtmlContentBuilder.Append(string unencoded)
157157
}
158158

159159
/// <inheritdoc />
160-
IHtmlContentBuilder IHtmlContentBuilder.AppendEncoded(string encoded)
160+
IHtmlContentBuilder IHtmlContentBuilder.AppendHtml(string encoded)
161161
{
162-
return AppendEncoded(encoded);
162+
return AppendHtml(encoded);
163163
}
164164

165165
/// <inheritdoc />

test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/DefaultTagHelperContentTest.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,33 @@ public void SetContentClearsExistingContent()
3939
Assert.Equal(expected, tagHelperContent.GetContent(new CommonTestEncoder()));
4040
}
4141

42+
[Fact]
43+
public void SetHtmlContent_TextIsNotFurtherEncoded()
44+
{
45+
// Arrange
46+
var tagHelperContent = new DefaultTagHelperContent();
47+
48+
// Act
49+
tagHelperContent.SetHtmlContent("Hi");
50+
51+
// Assert
52+
Assert.Equal("Hi", tagHelperContent.GetContent(new CommonTestEncoder()));
53+
}
54+
55+
[Fact]
56+
public void SetHtmlContent_ClearsExistingContent()
57+
{
58+
// Arrange
59+
var tagHelperContent = new DefaultTagHelperContent();
60+
tagHelperContent.AppendHtml("Contoso");
61+
62+
// Act
63+
tagHelperContent.SetHtmlContent("Hello World!");
64+
65+
// Assert
66+
Assert.Equal("Hello World!", tagHelperContent.GetContent(new CommonTestEncoder()));
67+
}
68+
4269
[Theory]
4370
[InlineData("HelloWorld!", "HtmlEncode[[HelloWorld!]]")]
4471
[InlineData(" ", "HtmlEncode[[ ]]")]
@@ -473,11 +500,11 @@ public void Append_WrittenAsEncoded()
473500
}
474501

475502
[Fact]
476-
public void AppendEncoded_DoesNotGetEncoded()
503+
public void AppendHtml_DoesNotGetEncoded()
477504
{
478505
// Arrange
479506
var tagHelperContent = new DefaultTagHelperContent();
480-
tagHelperContent.AppendEncoded("Hi");
507+
tagHelperContent.AppendHtml("Hi");
481508

482509
var writer = new StringWriter();
483510

0 commit comments

Comments
 (0)