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

Commit 571acc8

Browse files
committed
Rename AppendEncoded() to AppendHtml()
- #3225, 3 of 3
1 parent 493a556 commit 571acc8

File tree

19 files changed

+67
-67
lines changed

19 files changed

+67
-67
lines changed

src/Microsoft.AspNet.Mvc.Razor/TagHelperContentWrapperTextWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public TagHelperContentWrapperTextWriter(Encoding encoding, TagHelperContent con
5454
/// <inheritdoc />
5555
public override void Write(string value)
5656
{
57-
Content.AppendEncoded(value);
57+
Content.AppendHtml(value);
5858
}
5959

6060
/// <inheritdoc />
6161
public override void Write(char value)
6262
{
63-
Content.AppendEncoded(value.ToString());
63+
Content.AppendHtml(value.ToString());
6464
}
6565

6666
/// <inheritdoc />

src/Microsoft.AspNet.Mvc.TagHelpers/LinkTagHelper.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,23 +338,23 @@ private void BuildFallbackBlock(TagHelperContent builder)
338338

339339
// Build the <meta /> tag that's used to test for the presence of the stylesheet
340340
builder
341-
.AppendEncoded("<meta name=\"x-stylesheet-fallback-test\" class=\"")
341+
.AppendHtml("<meta name=\"x-stylesheet-fallback-test\" class=\"")
342342
.Append(FallbackTestClass)
343-
.AppendEncoded("\" />");
343+
.AppendHtml("\" />");
344344

345345
// Build the <script /> tag that checks the effective style of <meta /> tag above and renders the extra
346346
// <link /> tag to load the fallback stylesheet if the test CSS property value is found to be false,
347347
// indicating that the primary stylesheet failed to load.
348348
builder
349-
.AppendEncoded("<script>")
350-
.AppendEncoded(
349+
.AppendHtml("<script>")
350+
.AppendHtml(
351351
string.Format(
352352
CultureInfo.InvariantCulture,
353353
JavaScriptResources.GetEmbeddedJavaScript(FallbackJavaScriptResourceName),
354354
JavaScriptEncoder.JavaScriptStringEncode(FallbackTestProperty),
355355
JavaScriptEncoder.JavaScriptStringEncode(FallbackTestValue),
356356
JavaScriptStringArrayEncoder.Encode(JavaScriptEncoder, fallbackHrefs)))
357-
.AppendEncoded("</script>");
357+
.AppendHtml("</script>");
358358
}
359359
}
360360

@@ -382,7 +382,7 @@ private void EnsureFileVersionProvider()
382382

383383
private void BuildLinkTag(TagHelperAttributeList attributes, TagHelperContent builder)
384384
{
385-
builder.AppendEncoded("<link ");
385+
builder.AppendHtml("<link ");
386386

387387
foreach (var attribute in attributes)
388388
{
@@ -401,13 +401,13 @@ private void BuildLinkTag(TagHelperAttributeList attributes, TagHelperContent bu
401401
}
402402

403403
builder
404-
.AppendEncoded(attribute.Name)
405-
.AppendEncoded("=\"")
404+
.AppendHtml(attribute.Name)
405+
.AppendHtml("=\"")
406406
.Append(HtmlEncoder, ViewContext.Writer.Encoding, attributeValue)
407-
.AppendEncoded("\" ");
407+
.AppendHtml("\" ");
408408
}
409409

410-
builder.AppendEncoded("/>");
410+
builder.AppendHtml("/>");
411411
}
412412

413413
private enum Mode

src/Microsoft.AspNet.Mvc.TagHelpers/ScriptTagHelper.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ private void BuildFallbackBlock(TagHelperAttributeList attributes, DefaultTagHel
293293
if (fallbackSrcs.Any())
294294
{
295295
// Build the <script> tag that checks the test method and if it fails, renders the extra script.
296-
builder.AppendEncoded(Environment.NewLine)
297-
.AppendEncoded("<script>(")
298-
.AppendEncoded(FallbackTestExpression)
299-
.AppendEncoded("||document.write(\"");
296+
builder.AppendHtml(Environment.NewLine)
297+
.AppendHtml("<script>(")
298+
.AppendHtml(FallbackTestExpression)
299+
.AppendHtml("||document.write(\"");
300300

301301
// May have no "src" attribute in the dictionary e.g. if Src and SrcInclude were not bound.
302302
if (!attributes.ContainsName(SrcAttributeName))
@@ -310,7 +310,7 @@ private void BuildFallbackBlock(TagHelperAttributeList attributes, DefaultTagHel
310310
// Fallback "src" values come from bound attributes and globbing. Must always be non-null.
311311
Debug.Assert(src != null);
312312

313-
builder.AppendEncoded("<script");
313+
builder.AppendHtml("<script");
314314

315315
foreach (var attribute in attributes)
316316
{
@@ -338,10 +338,10 @@ private void BuildFallbackBlock(TagHelperAttributeList attributes, DefaultTagHel
338338
}
339339
}
340340

341-
builder.AppendEncoded("><\\/script>");
341+
builder.AppendHtml("><\\/script>");
342342
}
343343

344-
builder.AppendEncoded("\"));</script>");
344+
builder.AppendHtml("\"));</script>");
345345
}
346346
}
347347

@@ -371,7 +371,7 @@ private void BuildScriptTag(
371371
TagHelperAttributeList attributes,
372372
TagHelperContent builder)
373373
{
374-
builder.AppendEncoded("<script");
374+
builder.AppendHtml("<script");
375375

376376
foreach (var attribute in attributes)
377377
{
@@ -392,29 +392,29 @@ private void BuildScriptTag(
392392
AppendAttribute(builder, attribute.Name, attributeValue, escapeQuotes: false);
393393
}
394394

395-
builder.AppendEncoded("></script>");
395+
builder.AppendHtml("></script>");
396396
}
397397

398398
private void AppendAttribute(TagHelperContent content, string key, object value, bool escapeQuotes)
399399
{
400400
content
401-
.AppendEncoded(" ")
402-
.AppendEncoded(key);
401+
.AppendHtml(" ")
402+
.AppendHtml(key);
403403
if (escapeQuotes)
404404
{
405405
// Passed only JavaScript-encoded strings in this case. Do not perform HTML-encoding as well.
406406
content
407-
.AppendEncoded("=\\\"")
408-
.AppendEncoded((string)value)
409-
.AppendEncoded("\\\"");
407+
.AppendHtml("=\\\"")
408+
.AppendHtml((string)value)
409+
.AppendHtml("\\\"");
410410
}
411411
else
412412
{
413413
// HTML-encoded the given value if necessary.
414414
content
415-
.AppendEncoded("=\"")
415+
.AppendHtml("=\"")
416416
.Append(HtmlEncoder, ViewContext.Writer.Encoding, value)
417-
.AppendEncoded("\"");
417+
.AppendHtml("\"");
418418
}
419419
}
420420

src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultEditorTemplates.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public static IHtmlContent ObjectTemplate(IHtmlHelper htmlHelper)
282282
valueDivTag.AddCssClass("editor-field");
283283

284284
valueDivTag.InnerHtml.Append(templateBuilderResult);
285-
valueDivTag.InnerHtml.AppendEncoded(" ");
285+
valueDivTag.InnerHtml.AppendHtml(" ");
286286
valueDivTag.InnerHtml.Append(htmlHelper.ValidationMessage(
287287
propertyMetadata.PropertyName,
288288
message: null,

src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ public virtual TagBuilder GenerateValidationSummary(
818818

819819
if (!isHtmlSummaryModified)
820820
{
821-
htmlSummary.InnerHtml.AppendEncoded(HiddenListItem);
821+
htmlSummary.InnerHtml.AppendHtml(HiddenListItem);
822822
htmlSummary.InnerHtml.AppendLine();
823823
}
824824

test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ public async Task WriteTagHelperAsync_WritesContentAppropriately(
16581658
uniqueId: string.Empty,
16591659
executeChildContentAsync: () =>
16601660
{
1661-
defaultTagHelperContent.AppendEncoded(input);
1661+
defaultTagHelperContent.AppendHtml(input);
16621662
return Task.FromResult(result: true);
16631663
},
16641664
startTagHelperWritingScope: () => { },
@@ -1702,7 +1702,7 @@ public async Task WriteTagHelperToAsync_WritesToSpecifiedWriter()
17021702
tagName: "p",
17031703
attributes: new TagHelperAttributeList(),
17041704
getChildContentAsync: (_) => Task.FromResult<TagHelperContent>(new DefaultTagHelperContent()));
1705-
tagHelperExecutionContext.Output.Content.AppendEncoded("Hello World!");
1705+
tagHelperExecutionContext.Output.Content.AppendHtml("Hello World!");
17061706

17071707
// Act
17081708
var page = CreatePage(p =>
@@ -1763,11 +1763,11 @@ private static TagHelperOutput GetTagHelperOutput(
17631763
TagMode = tagMode
17641764
};
17651765

1766-
output.PreElement.AppendEncoded(preElement);
1767-
output.PreContent.AppendEncoded(preContent);
1768-
output.Content.AppendEncoded(content);
1769-
output.PostContent.AppendEncoded(postContent);
1770-
output.PostElement.AppendEncoded(postElement);
1766+
output.PreElement.AppendHtml(preElement);
1767+
output.PreContent.AppendHtml(preContent);
1768+
output.Content.AppendHtml(content);
1769+
output.PostContent.AppendHtml(postContent);
1770+
output.PostElement.AppendHtml(postElement);
17711771

17721772
return output;
17731773
}

test/Microsoft.AspNet.Mvc.TagHelpers.Test/InputTagHelperTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public async Task CheckBoxHandlesMultipleAttributesSameNameCorrectly(
9898
{
9999
TagMode = TagMode.SelfClosing,
100100
};
101-
output.Content.AppendEncoded(originalContent);
101+
output.Content.AppendHtml(originalContent);
102102
var htmlGenerator = new TestableHtmlGenerator(new EmptyModelMetadataProvider());
103103
var tagHelper = GetTagHelper(htmlGenerator, model: false, propertyName: nameof(Model.IsACar));
104104

@@ -277,9 +277,9 @@ public async Task ProcessAsync_CallsGenerateCheckBox_WithExpectedParameters()
277277
{
278278
TagMode = TagMode.SelfClosing,
279279
};
280-
output.PreContent.AppendEncoded(expectedPreContent);
281-
output.Content.AppendEncoded(originalContent);
282-
output.PostContent.AppendEncoded(expectedPostContent);
280+
output.PreContent.AppendHtml(expectedPreContent);
281+
output.Content.AppendHtml(originalContent);
282+
output.PostContent.AppendHtml(expectedPostContent);
283283

284284
var htmlGenerator = new Mock<IHtmlGenerator>(MockBehavior.Strict);
285285
var tagHelper = GetTagHelper(htmlGenerator.Object, model: false, propertyName: nameof(Model.IsACar));

test/Microsoft.AspNet.Mvc.TagHelpers.Test/LabelTagHelperTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,17 @@ public async Task ProcessAsync_GeneratesExpectedOutput(
204204
getChildContentAsync: useCachedResult =>
205205
{
206206
var tagHelperContent = new DefaultTagHelperContent();
207-
tagHelperContent.AppendEncoded(tagHelperOutputContent.OriginalChildContent);
207+
tagHelperContent.AppendHtml(tagHelperOutputContent.OriginalChildContent);
208208
return Task.FromResult<TagHelperContent>(tagHelperContent);
209209
});
210-
output.PreContent.AppendEncoded(expectedPreContent);
211-
output.PostContent.AppendEncoded(expectedPostContent);
210+
output.PreContent.AppendHtml(expectedPreContent);
211+
output.PostContent.AppendHtml(expectedPostContent);
212212

213213
// LabelTagHelper checks IsContentModified so we don't want to forcibly set it if
214214
// tagHelperOutputContent.OriginalContent is going to be null or empty.
215215
if (!string.IsNullOrEmpty(tagHelperOutputContent.OriginalContent))
216216
{
217-
output.Content.AppendEncoded(tagHelperOutputContent.OriginalContent);
217+
output.Content.AppendHtml(tagHelperOutputContent.OriginalContent);
218218
}
219219

220220
var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator, metadataProvider);

test/Microsoft.AspNet.Mvc.TagHelpers.Test/SelectTagHelperTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ public async Task ProcessAsync_WithItems_GeneratesExpectedOutput_DoesNotChangeSe
299299
getChildContentAsync: useCachedResult =>
300300
{
301301
var tagHelperContent = new DefaultTagHelperContent();
302-
tagHelperContent.AppendEncoded("Something");
302+
tagHelperContent.AppendHtml("Something");
303303
return Task.FromResult<TagHelperContent>(tagHelperContent);
304304
})
305305
{
306306
TagMode = TagMode.SelfClosing,
307307
};
308-
output.PreContent.AppendEncoded(expectedPreContent);
309-
output.Content.AppendEncoded(expectedContent);
310-
output.PostContent.AppendEncoded(originalPostContent);
308+
output.PreContent.AppendHtml(expectedPreContent);
309+
output.Content.AppendHtml(expectedContent);
310+
output.PostContent.AppendHtml(originalPostContent);
311311

312312
var htmlGenerator = new TestableHtmlGenerator(metadataProvider)
313313
{
@@ -403,15 +403,15 @@ public async Task ProcessAsyncInTemplate_WithItems_GeneratesExpectedOutput_DoesN
403403
getChildContentAsync: useCachedResult =>
404404
{
405405
var tagHelperContent = new DefaultTagHelperContent();
406-
tagHelperContent.AppendEncoded("Something");
406+
tagHelperContent.AppendHtml("Something");
407407
return Task.FromResult<TagHelperContent>(tagHelperContent);
408408
})
409409
{
410410
TagMode = TagMode.SelfClosing,
411411
};
412-
output.PreContent.AppendEncoded(expectedPreContent);
413-
output.Content.AppendEncoded(expectedContent);
414-
output.PostContent.AppendEncoded(originalPostContent);
412+
output.PreContent.AppendHtml(expectedPreContent);
413+
output.Content.AppendHtml(expectedContent);
414+
output.PostContent.AppendHtml(originalPostContent);
415415

416416
var htmlGenerator = new TestableHtmlGenerator(metadataProvider)
417417
{

test/Microsoft.AspNet.Mvc.TagHelpers.Test/ValidationMessageTagHelperTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ public async Task ProcessAsync_DoesNotOverrideOutputContent(
170170
getChildContentAsync: useCachedResult =>
171171
{
172172
var tagHelperContent = new DefaultTagHelperContent();
173-
tagHelperContent.AppendEncoded(childContent);
173+
tagHelperContent.AppendHtml(childContent);
174174
return Task.FromResult<TagHelperContent>(tagHelperContent);
175175
});
176-
output.Content.AppendEncoded(outputContent);
176+
output.Content.AppendHtml(outputContent);
177177

178178
var context = new TagHelperContext(
179179
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(

test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/TagBuilderTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void WriteTo_IncludesInnerHtml()
110110
{
111111
// Arrange
112112
var tagBuilder = new TagBuilder("p");
113-
tagBuilder.InnerHtml.AppendEncoded("<span>Hello</span>");
113+
tagBuilder.InnerHtml.AppendHtml("<span>Hello</span>");
114114
tagBuilder.InnerHtml.Append(", World!");
115115

116116
// Act

test/WebSites/ActivatorWebSite/TagHelpers/FooterTagHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public class FooterTagHelper : TagHelper
1717
public override void Process(TagHelperContext context, TagHelperOutput output)
1818
{
1919
output.PostContent
20-
.AppendEncoded("<footer>")
20+
.AppendHtml("<footer>")
2121
.Append((string)ViewContext.ViewData["footer"])
22-
.AppendEncoded("</footer>");
22+
.AppendHtml("</footer>");
2323
}
2424
}
2525
}

test/WebSites/TagHelpersWebSite/TagHelpers/AutoLinkerTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
1515
var childContent = await output.GetChildContentAsync();
1616

1717
// Find Urls in the content and replace them with their anchor tag equivalent.
18-
output.Content.AppendEncoded(Regex.Replace(
18+
output.Content.AppendHtml(Regex.Replace(
1919
childContent.GetContent(),
2020
@"\b(?:https?://|www\.)(\S+)\b",
2121
"<strong><a target=\"_blank\" href=\"http://$0\">$0</a></strong>"));

test/WebSites/TagHelpersWebSite/TagHelpers/BoldTagHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public override int Order
1919
public override void Process(TagHelperContext context, TagHelperOutput output)
2020
{
2121
output.Attributes.RemoveAll("bold");
22-
output.PreContent.AppendEncoded("<b>");
23-
output.PostContent.AppendEncoded("</b>");
22+
output.PreContent.AppendHtml("<b>");
23+
output.PostContent.AppendHtml("</b>");
2424
}
2525
}
2626
}

test/WebSites/TagHelpersWebSite/TagHelpers/NestedViewImportsTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class NestedViewImportsTagHelper : TagHelper
1010
{
1111
public override void Process(TagHelperContext context, TagHelperOutput output)
1212
{
13-
output.Content.AppendEncoded("nested-content");
13+
output.Content.AppendHtml("nested-content");
1414
}
1515
}
1616
}

test/WebSites/TagHelpersWebSite/TagHelpers/RootViewStartTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class RootViewStartTagHelper : TagHelper
1010
{
1111
public override void Process(TagHelperContext context, TagHelperOutput output)
1212
{
13-
output.Content.AppendEncoded("root-content");
13+
output.Content.AppendHtml("root-content");
1414
}
1515
}
1616
}

test/WebSites/TagHelpersWebSite/TagHelpers/SurroundTagHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
2323
{
2424
var surroundingTagName = Surround.ToLowerInvariant();
2525

26-
output.PreElement.AppendEncoded($"<{surroundingTagName}>");
27-
output.PostElement.AppendEncoded($"</{surroundingTagName}>");
26+
output.PreElement.AppendHtml($"<{surroundingTagName}>");
27+
output.PostElement.AppendHtml($"</{surroundingTagName}>");
2828
}
2929
}
3030
}

test/WebSites/TagHelpersWebSite/TagHelpers/TagCloudViewComponentTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ await result.ExecuteAsync(new ViewComponentContext(
5656
writer));
5757

5858
output.TagName = null;
59-
output.Content.AppendEncoded(writer.ToString());
59+
output.Content.AppendHtml(writer.ToString());
6060
}
6161

6262
public async Task<IViewComponentResult> InvokeAsync(int count)

test/WebSites/TagHelpersWebSite/TagHelpers/WebsiteInformationTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class WebsiteInformationTagHelper : TagHelper
1414
public override void Process(TagHelperContext context, TagHelperOutput output)
1515
{
1616
output.TagName = "section";
17-
output.PostContent.AppendEncoded(string.Format(
17+
output.PostContent.AppendHtml(string.Format(
1818
"<p><strong>Version:</strong> {0}</p>" + Environment.NewLine +
1919
"<p><strong>Copyright Year:</strong> {1}</p>" + Environment.NewLine +
2020
"<p><strong>Approved:</strong> {2}</p>" + Environment.NewLine +

0 commit comments

Comments
 (0)