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

Commit 1b1332e

Browse files
committed
Rename AppendEncoded() to AppendHtml()
- #3225, 3 of 3
1 parent da731fc commit 1b1332e

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
@@ -1657,7 +1657,7 @@ public async Task WriteTagHelperAsync_WritesContentAppropriately(
16571657
uniqueId: string.Empty,
16581658
executeChildContentAsync: () =>
16591659
{
1660-
defaultTagHelperContent.AppendEncoded(input);
1660+
defaultTagHelperContent.AppendHtml(input);
16611661
return Task.FromResult(result: true);
16621662
},
16631663
startTagHelperWritingScope: () => { },
@@ -1695,7 +1695,7 @@ public async Task WriteTagHelperToAsync_WritesToSpecifiedWriter()
16951695
startTagHelperWritingScope: () => { },
16961696
endTagHelperWritingScope: () => new DefaultTagHelperContent());
16971697
tagHelperExecutionContext.Output = new TagHelperOutput("p", new TagHelperAttributeList());
1698-
tagHelperExecutionContext.Output.Content.AppendEncoded("Hello World!");
1698+
tagHelperExecutionContext.Output.Content.AppendHtml("Hello World!");
16991699

17001700
// Act
17011701
var page = CreatePage(p =>
@@ -1753,11 +1753,11 @@ private static TagHelperOutput GetTagHelperOutput(
17531753
TagMode = tagMode
17541754
};
17551755

1756-
output.PreElement.AppendEncoded(preElement);
1757-
output.PreContent.AppendEncoded(preContent);
1758-
output.Content.AppendEncoded(content);
1759-
output.PostContent.AppendEncoded(postContent);
1760-
output.PostElement.AppendEncoded(postElement);
1756+
output.PreElement.AppendHtml(preElement);
1757+
output.PreContent.AppendHtml(preContent);
1758+
output.Content.AppendHtml(content);
1759+
output.PostContent.AppendHtml(postContent);
1760+
output.PostElement.AppendHtml(postElement);
17611761

17621762
return output;
17631763
}

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

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

@@ -271,9 +271,9 @@ public async Task ProcessAsync_CallsGenerateCheckBox_WithExpectedParameters()
271271
{
272272
TagMode = TagMode.SelfClosing,
273273
};
274-
output.PreContent.AppendEncoded(expectedPreContent);
275-
output.Content.AppendEncoded(originalContent);
276-
output.PostContent.AppendEncoded(expectedPostContent);
274+
output.PreContent.AppendHtml(expectedPreContent);
275+
output.Content.AppendHtml(originalContent);
276+
output.PostContent.AppendHtml(expectedPostContent);
277277

278278
var htmlGenerator = new Mock<IHtmlGenerator>(MockBehavior.Strict);
279279
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
@@ -197,22 +197,22 @@ public async Task ProcessAsync_GeneratesExpectedOutput(
197197
getChildContentAsync: useCachedResult =>
198198
{
199199
var tagHelperContent = new DefaultTagHelperContent();
200-
tagHelperContent.AppendEncoded(tagHelperOutputContent.OriginalChildContent);
200+
tagHelperContent.AppendHtml(tagHelperOutputContent.OriginalChildContent);
201201
return Task.FromResult<TagHelperContent>(tagHelperContent);
202202
});
203203
var htmlAttributes = new TagHelperAttributeList
204204
{
205205
{ "class", "form-control" },
206206
};
207207
var output = new TagHelperOutput(expectedTagName, htmlAttributes);
208-
output.PreContent.AppendEncoded(expectedPreContent);
209-
output.PostContent.AppendEncoded(expectedPostContent);
208+
output.PreContent.AppendHtml(expectedPreContent);
209+
output.PostContent.AppendHtml(expectedPostContent);
210210

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

218218
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
@@ -294,16 +294,16 @@ public async Task ProcessAsync_WithItems_GeneratesExpectedOutput_DoesNotChangeSe
294294
getChildContentAsync: useCachedResult =>
295295
{
296296
var tagHelperContent = new DefaultTagHelperContent();
297-
tagHelperContent.AppendEncoded("Something");
297+
tagHelperContent.AppendHtml("Something");
298298
return Task.FromResult<TagHelperContent>(tagHelperContent);
299299
});
300300
var output = new TagHelperOutput(expectedTagName, originalAttributes)
301301
{
302302
TagMode = TagMode.SelfClosing,
303303
};
304-
output.PreContent.AppendEncoded(expectedPreContent);
305-
output.Content.AppendEncoded(expectedContent);
306-
output.PostContent.AppendEncoded(originalPostContent);
304+
output.PreContent.AppendHtml(expectedPreContent);
305+
output.Content.AppendHtml(expectedContent);
306+
output.PostContent.AppendHtml(originalPostContent);
307307

308308
var htmlGenerator = new TestableHtmlGenerator(metadataProvider)
309309
{
@@ -396,16 +396,16 @@ public async Task ProcessAsyncInTemplate_WithItems_GeneratesExpectedOutput_DoesN
396396
getChildContentAsync: useCachedResult =>
397397
{
398398
var tagHelperContent = new DefaultTagHelperContent();
399-
tagHelperContent.AppendEncoded("Something");
399+
tagHelperContent.AppendHtml("Something");
400400
return Task.FromResult<TagHelperContent>(tagHelperContent);
401401
});
402402
var output = new TagHelperOutput(expectedTagName, originalAttributes)
403403
{
404404
TagMode = TagMode.SelfClosing,
405405
};
406-
output.PreContent.AppendEncoded(expectedPreContent);
407-
output.Content.AppendEncoded(expectedContent);
408-
output.PostContent.AppendEncoded(originalPostContent);
406+
output.PreContent.AppendHtml(expectedPreContent);
407+
output.Content.AppendHtml(expectedContent);
408+
output.PostContent.AppendHtml(originalPostContent);
409409

410410
var htmlGenerator = new TestableHtmlGenerator(metadataProvider)
411411
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public async Task ProcessAsync_DoesNotOverrideOutputContent(
167167
var output = new TagHelperOutput(
168168
"span",
169169
attributes: new TagHelperAttributeList());
170-
output.Content.AppendEncoded(outputContent);
170+
output.Content.AppendHtml(outputContent);
171171

172172
var context = new TagHelperContext(
173173
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
@@ -177,7 +177,7 @@ public async Task ProcessAsync_DoesNotOverrideOutputContent(
177177
getChildContentAsync: useCachedResult =>
178178
{
179179
var tagHelperContent = new DefaultTagHelperContent();
180-
tagHelperContent.AppendEncoded(childContent);
180+
tagHelperContent.AppendHtml(childContent);
181181
return Task.FromResult<TagHelperContent>(tagHelperContent);
182182
});
183183

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 context.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
}

0 commit comments

Comments
 (0)