Skip to content

Optimize WebUtility.HtmlEncode and WebUtility.HtmlDecode #19445

@safern

Description

@safern

When porting WebUtility missing members:

    public static class WebUtility {
        public static void HtmlDecode(string value, TextWriter output);
        public static void HtmlEncode(string value, TextWriter output);
    }

We found that we already had a private method on .NET Core that would do exactly the same as this two members but instead of having a TextWriter as the output they have a StringBuilder. This members where ported on PR dotnet/corefx#13875 with a simple solution of just calling the existing private member and writing the result to the TextWriter output Here is the source code.

On PR dotnet/corefx#13875 we had a large discussion with different solutions. With a conclusion that the best one is @jkotas's solution.

cc @danmosemsft @AlexGhiondea

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.NetenhancementProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributorstenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions