Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable: System.Xml, part 7 (Serialization) #41261

Merged
merged 5 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public SchemaNamespaceManager(XmlSchemaObject node)
{ //Special case for the XML namespace
return XmlReservedNs.NsXml;
}
Dictionary<string, string> namespaces;
Dictionary<string, string?> namespaces;
for (XmlSchemaObject? current = _node; current != null; current = current.Parent)
{
namespaces = current.Namespaces.Namespaces;
Expand All @@ -44,15 +44,15 @@ public SchemaNamespaceManager(XmlSchemaObject node)
{ //Special case for the XML namespace
return "xml";
}
Dictionary<string, string> namespaces;
Dictionary<string, string?> namespaces;
for (XmlSchemaObject? current = _node; current != null; current = current.Parent)
{
namespaces = current.Namespaces.Namespaces;
if (namespaces != null && namespaces.Count > 0)
{
foreach (KeyValuePair<string, string> entry in namespaces)
foreach (KeyValuePair<string, string?> entry in namespaces)
{
if (entry.Value.Equals(ns))
if (entry.Value!.Equals(ns))
{
return entry.Key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public class XmlSchema : XmlSchemaObject

public XmlSchema() { }

public static XmlSchema? Read(TextReader reader, ValidationEventHandler validationEventHandler)
public static XmlSchema? Read(TextReader reader, ValidationEventHandler? validationEventHandler)
{
return Read(new XmlTextReader(reader), validationEventHandler);
}

public static XmlSchema? Read(Stream stream, ValidationEventHandler validationEventHandler)
public static XmlSchema? Read(Stream stream, ValidationEventHandler? validationEventHandler)
{
return Read(new XmlTextReader(stream), validationEventHandler);
}

public static XmlSchema? Read(XmlReader reader, ValidationEventHandler validationEventHandler)
public static XmlSchema? Read(XmlReader reader, ValidationEventHandler? validationEventHandler)
{
XmlNameTable nameTable = reader.NameTable;
Parser parser = new Parser(SchemaType.XSD, nameTable, new SchemaNames(nameTable), validationEventHandler);
Expand Down Expand Up @@ -136,7 +136,7 @@ public void Write(XmlWriter writer, XmlNamespaceManager? namespaceManager)
{
ns.Add("xs", XmlReservedNs.NsXs);
}
foreach (string? prefix in namespaceManager)
foreach (string prefix in namespaceManager)
{
if (prefix != "xml" && prefix != "xmlns")
{
Expand All @@ -146,7 +146,7 @@ public void Write(XmlWriter writer, XmlNamespaceManager? namespaceManager)
}
else if (this.Namespaces != null && this.Namespaces.Count > 0)
{
Dictionary<string, string> serializerNS = this.Namespaces.Namespaces;
Dictionary<string, string?> serializerNS = this.Namespaces.Namespaces;
if (!serializerNS.ContainsKey("xs") && !serializerNS.ContainsValue(XmlReservedNs.NsXs))
{ //Prefix xs not defined AND schema namespace not already mapped to a prefix
serializerNS.Add("xs", XmlReservedNs.NsXs);
Expand All @@ -166,15 +166,15 @@ public void Write(XmlWriter writer, XmlNamespaceManager? namespaceManager)
}

[Obsolete("Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. https://go.microsoft.com/fwlink/?linkid=14202")]
public void Compile(ValidationEventHandler validationEventHandler)
public void Compile(ValidationEventHandler? validationEventHandler)
{
SchemaInfo sInfo = new SchemaInfo();
sInfo.SchemaType = SchemaType.XSD;
CompileSchema(null, null, sInfo, null, validationEventHandler, NameTable, false);
}

[Obsolete("Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. https://go.microsoft.com/fwlink/?linkid=14202")]
public void Compile(ValidationEventHandler validationEventHandler, XmlResolver resolver)
public void Compile(ValidationEventHandler? validationEventHandler, XmlResolver? resolver)
{
SchemaInfo sInfo = new SchemaInfo();
sInfo.SchemaType = SchemaType.XSD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,23 @@ internal bool HasAbstractAttribute
}

[XmlAttribute("ref")]
[AllowNull]
public XmlQualifiedName RefName
{
get { return _refName; }
set { _refName = (value == null ? XmlQualifiedName.Empty : value); }
}

[XmlAttribute("substitutionGroup")]
[AllowNull]
public XmlQualifiedName SubstitutionGroup
{
get { return _substitutionGroup; }
set { _substitutionGroup = (value == null ? XmlQualifiedName.Empty : value); }
}

[XmlAttribute("type")]
[AllowNull]
public XmlQualifiedName SchemaTypeName
{
get { return _typeName; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ internal override void StartChildren()
{
if (_namespaces != null && _namespaces.Count > 0)
{
_xso.Namespaces.Namespaces = _namespaces;
_xso.Namespaces.Namespaces = _namespaces!;
_namespaces = null;
}
if (_unhandledAttributes.Count != 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable
namespace System.Xml.Serialization
{
using System;
Expand Down
Loading