From 6891633bed0f0204acb2f470b92efc17c310744b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Cant=C3=BA?= Date: Wed, 19 Aug 2020 22:41:41 -0700 Subject: [PATCH] Enable nullability on System.Xml.XPath (#41060) * Enable nullability on System.Xml.XPath * Switch XPathException ctor's message parameter to string? --- .../src/System/Xml/XPath/XPathException.cs | 12 ++++++------ .../System.Xml.XPath/ref/System.Xml.XPath.cs | 4 ++-- .../System.Xml.XPath/ref/System.Xml.XPath.csproj | 1 + .../System.Xml.XPath/src/System.Xml.XPath.csproj | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathException.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathException.cs index 017f4044d6135..af0c9d0bf35e4 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathException.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/XPathException.cs @@ -17,7 +17,7 @@ public class XPathException : SystemException { // we need to keep this members for V1 serialization compatibility private readonly string _res; - private readonly string[]? _args; + private readonly string?[]? _args; // message != null for V1 & V2 exceptions deserialized in Whidbey // message == null for created V2 exceptions; the exception message is stored in Exception._message @@ -60,10 +60,10 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont public XPathException() : this(string.Empty, (Exception?)null) { } - public XPathException(string message) : this(message, (Exception?)null) { } + public XPathException(string? message) : this(message, (Exception?)null) { } - public XPathException(string message, Exception? innerException) : - this(SR.Xml_UserException, new string[] { message }, innerException) + public XPathException(string? message, Exception? innerException) : + this(SR.Xml_UserException, new string?[] { message }, innerException) { } @@ -92,7 +92,7 @@ private XPathException(string res, string[]? args) : { } - private XPathException(string res, string[]? args, Exception? inner) : + private XPathException(string res, string?[]? args, Exception? inner) : base(CreateMessage(res, args), inner) { HResult = HResults.XmlXPath; @@ -100,7 +100,7 @@ private XPathException(string res, string[]? args, Exception? inner) : _args = args; } - private static string CreateMessage(string res, string[]? args) + private static string CreateMessage(string res, string?[]? args) { try { diff --git a/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs b/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs index a13b69f563099..05b896d6f87d5 100644 --- a/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs +++ b/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs @@ -20,8 +20,8 @@ public partial class XPathException : System.SystemException { public XPathException() { } protected XPathException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - public XPathException(string message) { } - public XPathException(string message, System.Exception innerException) { } + public XPathException(string? message) { } + public XPathException(string? message, System.Exception? innerException) { } public override string Message { get { throw null; } } public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } diff --git a/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.csproj b/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.csproj index 6dbe6ca18418a..6cbf41c40f82b 100644 --- a/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.csproj +++ b/src/libraries/System.Xml.XPath/ref/System.Xml.XPath.csproj @@ -1,6 +1,7 @@ $(NetCoreAppCurrent) + enable diff --git a/src/libraries/System.Xml.XPath/src/System.Xml.XPath.csproj b/src/libraries/System.Xml.XPath/src/System.Xml.XPath.csproj index 8159a0e77d94b..a2a87b23e74cf 100644 --- a/src/libraries/System.Xml.XPath/src/System.Xml.XPath.csproj +++ b/src/libraries/System.Xml.XPath/src/System.Xml.XPath.csproj @@ -2,6 +2,7 @@ true $(NetCoreAppCurrent) + enable