diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlProcessingInstruction.cs b/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlProcessingInstruction.cs index c66148d813c05..3e1ce5ccb832f 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlProcessingInstruction.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlProcessingInstruction.cs @@ -16,9 +16,9 @@ public class XmlProcessingInstruction : XmlLinkedNode protected internal XmlProcessingInstruction(string target, string? data, XmlDocument doc) : base(doc) { - Debug.Assert(target != null, "All callsites should have already checked for null"); + ArgumentNullException.ThrowIfNull(target); - if (string.IsNullOrEmpty(target)) + if (target.Length == 0) { throw new ArgumentException(SR.Xml_EmptyName); } @@ -38,7 +38,7 @@ protected internal XmlProcessingInstruction(string target, string? data, XmlDocu public override string Value { get => _data; - set { Data = value; } // use Data instead of data so that event will be fired + set { Data = value; } // use Data instead of data so that event will be fired and null will be normalized to empty string } // Gets the target of the processing instruction. @@ -75,7 +75,7 @@ public string Data public override string InnerText { get => _data; - set { Data = value; } // use Data instead of data so that change event will be fired + set { Data = value; } // use Data instead of data so that event will be fired and null will be normalized to empty string } ///