Skip to content

Commit

Permalink
Port nullability annotations to refs XmlDocument and XmlSerializer (#…
Browse files Browse the repository at this point in the history
…41474)

* Port nullability annotations to refs XmlDocument and XmlSerializer

* Fix new System.Data.Common nullability related errors

* Switch nullability of parameter in SoapElementAttribute ctor
  • Loading branch information
jozkee authored Aug 28, 2020
1 parent e6b9b48 commit c587f9d
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public override object ConvertXmlToObject(string s)

StringReader strreader = new StringReader(s);
XmlSerializer deserializerWithOutRootAttribute = ObjectStorage.GetXmlSerializer(type);
return (deserializerWithOutRootAttribute.Deserialize(strreader));
return (deserializerWithOutRootAttribute.Deserialize(strreader))!;
}

// Prevent inlining so that reflection calls are not moved to caller that may be in a different assembly that may have a different grant set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public override object ConvertXmlToObject(string s)

StringReader strreader = new StringReader(s);
XmlSerializer deserializerWithOutRootAttribute = ObjectStorage.GetXmlSerializer(_dataType);
return (deserializerWithOutRootAttribute.Deserialize(strreader));
return (deserializerWithOutRootAttribute.Deserialize(strreader))!;
}

// Prevent inlining so that reflection calls are not moved to caller that may be in a different assembly that may have a different grant set.
Expand All @@ -188,7 +188,7 @@ public override object ConvertXmlToObject(XmlReader xmlReader, XmlRootAttribute
else
{
XmlSerializer deserializerWithRootAttribute = ObjectStorage.GetXmlSerializer(_dataType, xmlAttrib);
return (deserializerWithRootAttribute.Deserialize(xmlReader));
return (deserializerWithRootAttribute.Deserialize(xmlReader))!;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public SoapElementAttribute()
{
}

public SoapElementAttribute(string elementName)
public SoapElementAttribute(string? elementName)
{
_elementName = elementName;
}
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.XmlDocument.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>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
Expand Down
594 changes: 310 additions & 284 deletions src/libraries/System.Xml.XmlSerializer/ref/System.Xml.XmlSerializer.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.XmlSerializer.cs" />
Expand Down
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 c587f9d

Please sign in to comment.