Skip to content

Commit

Permalink
Enable nullability on System.Xml.XPath (#41060)
Browse files Browse the repository at this point in the history
* Enable nullability on System.Xml.XPath

* Switch XPathException ctor's message parameter to string?
  • Loading branch information
jozkee authored Aug 20, 2020
1 parent 79af44b commit 6891633
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -92,15 +92,15 @@ 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;
_res = res;
_args = args;
}

private static string CreateMessage(string res, string[]? args)
private static string CreateMessage(string res, string?[]? args)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/System.Xml.XPath/ref/System.Xml.XPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
}
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Xml.XPath/ref/System.Xml.XPath.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Xml.XPath.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Xml.XPath/src/System.Xml.XPath.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
Expand Down

0 comments on commit 6891633

Please sign in to comment.