dotnet/runtime

Expose XmlTextReaderImpl.Normalization

Open

#49 418 ouverte le 10 mars 2021

Voir sur GitHub
 (15 commentaires) (1 réaction) (0 assignés)C# (5 445 forks)batch import
api-suggestionarea-System.Xmlhelp wanted

Métriques du dépôt

Stars
 (17 886 stars)
Métriques de merge PR
 (Merge moyen 12j 11h) (661 PRs mergées en 30 j)

Description

Background and Motivation

XmlTextReader exposes the Normalization property, by default false, which affects whitespace and attribute value handling. No such property is exposed on XmlReader even though it is internally available on XmlTextReaderImpl where it is effectively hard-coded to true. If the developer wishes to move to the newer API, to be able to specify XmlReaderSettings for example, they have no choice but also change whitespace and attribute value handling, which may not be desirable.

Proposed API

Technically the following should work but it may as well be a new property on XmlReaderSettings.

namespace System.Xml
{
    public abstract class XmlReader : IDisposable {
+        public virtual bool Normalization { get; set; }
     }
}

Usage Examples

See https://github.com/dotnet/msbuild/pull/6232 for an example. The change would make XML parsing in MSBuild significantly faster if the property proposed here was available. In the PR XmlTextReaderImpl.Normalization is called via reflection as a proof of the concept.

Alternative Designs

Unaware of alternative approaches other than implementing our own XML parser.

Risks

N/A

Guide contributeur