Skip to content

Commit

Permalink
Port nullability annotations from System.Private.Xml.Linq to contracts (
Browse files Browse the repository at this point in the history
dotnet#41086)

* Enable nullability on System.Xml.XPath.XDocument src

* Port nullability annotations to System.Xml.XPath.XDocument

* Port nullability annotations to System.Xml.XDocument

* Add ? to XmlAttribute argument in int? explicit operator
  • Loading branch information
jozkee authored and carlossanlop committed Aug 28, 2020
1 parent 71627b9 commit 181bca2
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public static explicit operator int(XAttribute attribute)
/// </returns>
[CLSCompliant(false)]
[return: NotNullIfNotNull("attribute")]
public static explicit operator int?(XAttribute attribute)
public static explicit operator int?(XAttribute? attribute)
{
if (attribute == null) return null;
return XmlConvert.ToInt32(attribute.value);
Expand Down
260 changes: 144 additions & 116 deletions src/libraries/System.Xml.XDocument/ref/System.Xml.XDocument.cs

Large diffs are not rendered by default.

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.XDocument.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<RootNamespace>System.Xml</RootNamespace>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml.Linq\src\System.Private.Xml.Linq.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ namespace System.Xml.XPath
public static partial class Extensions
{
public static System.Xml.XPath.XPathNavigator CreateNavigator(this System.Xml.Linq.XNode node) { throw null; }
public static System.Xml.XPath.XPathNavigator CreateNavigator(this System.Xml.Linq.XNode node, System.Xml.XmlNameTable nameTable) { throw null; }
public static System.Xml.XPath.XPathNavigator CreateNavigator(this System.Xml.Linq.XNode node, System.Xml.XmlNameTable? nameTable) { throw null; }
public static object XPathEvaluate(this System.Xml.Linq.XNode node, string expression) { throw null; }
public static object XPathEvaluate(this System.Xml.Linq.XNode node, string expression, System.Xml.IXmlNamespaceResolver resolver) { throw null; }
public static System.Xml.Linq.XElement XPathSelectElement(this System.Xml.Linq.XNode node, string expression) { throw null; }
public static System.Xml.Linq.XElement XPathSelectElement(this System.Xml.Linq.XNode node, string expression, System.Xml.IXmlNamespaceResolver resolver) { throw null; }
public static object XPathEvaluate(this System.Xml.Linq.XNode node, string expression, System.Xml.IXmlNamespaceResolver? resolver) { throw null; }
public static System.Xml.Linq.XElement? XPathSelectElement(this System.Xml.Linq.XNode node, string expression) { throw null; }
public static System.Xml.Linq.XElement? XPathSelectElement(this System.Xml.Linq.XNode node, string expression, System.Xml.IXmlNamespaceResolver? resolver) { throw null; }
public static System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> XPathSelectElements(this System.Xml.Linq.XNode node, string expression) { throw null; }
public static System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> XPathSelectElements(this System.Xml.Linq.XNode node, string expression, System.Xml.IXmlNamespaceResolver resolver) { throw null; }
public static System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> XPathSelectElements(this System.Xml.Linq.XNode node, string expression, System.Xml.IXmlNamespaceResolver? resolver) { throw null; }
}
public static partial class XDocumentExtensions
{
Expand Down
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.XDocument.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Xml\XPath\XDocumentExtensions.cs" />
Expand Down

0 comments on commit 181bca2

Please sign in to comment.