Skip to content

Commit

Permalink
Nullable: System.Xml, part 5 (XmlDocument) (dotnet#39691)
Browse files Browse the repository at this point in the history
* Nullable: System.Xml, part 5 (XmlDocument)

* apply feedback
  • Loading branch information
krwq authored Jul 24, 2020
1 parent ca95479 commit 0e5614c
Show file tree
Hide file tree
Showing 85 changed files with 1,542 additions and 1,166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public override int AttributeCount
}
}

public override string? GetAttribute(string name, string ns)
public override string? GetAttribute(string name, string? ns)
{
if (ScanState.XmlText == _state)
{
Expand Down Expand Up @@ -721,7 +721,7 @@ public override string GetAttribute(int i)
}
}

public override bool MoveToAttribute(string name, string ns)
public override bool MoveToAttribute(string name, string? ns)
{
if (ScanState.XmlText == _state)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace System.Xml
internal partial interface IDtdParser
{
IDtdInfo ParseInternalDtd(IDtdParserAdapter adapter, bool saveInternalSubset);
IDtdInfo ParseFreeFloatingDtd(string baseUri, string docTypeName, string publicId, string systemId, string internalSubset, IDtdParserAdapter adapter);
IDtdInfo ParseFreeFloatingDtd(string baseUri, string docTypeName, string? publicId, string? systemId, string? internalSubset, IDtdParserAdapter adapter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ namespace System.Xml
/// </summary>
internal interface IRemovableWriter
{
OnRemoveWriter OnRemoveWriterEvent { get; set; }
OnRemoveWriter? OnRemoveWriterEvent { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace System.Xml
internal interface IValidationEventHandling
{
// This is a ValidationEventHandler, but it is not strongly typed due to dependencies on System.Xml.Schema
object EventHandler { get; }
object? EventHandler { get; }

// The exception is XmlSchemaException, but it is not strongly typed due to dependencies on System.Xml.Schema
void SendEvent(Exception exception, XmlSeverityType severity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class QueryOutputWriter : XmlRawWriter
private readonly bool _checkWellFormedDoc;
private bool _hasDocElem;
private bool _inAttr;
private readonly string _systemId, _publicId;
private readonly string? _systemId, _publicId;
private int _depth;

public QueryOutputWriter(XmlRawWriter writer, XmlWriterSettings settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class QueryOutputWriterV1 : XmlWriter
private readonly BitStack? _bitsCData;
private readonly XmlQualifiedName? _qnameCData;
private bool _outputDocType, _inAttr;
private readonly string _systemId, _publicId;
private readonly string? _systemId, _publicId;

public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Xml.Schema;
using System.Diagnostics;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;

namespace System.Xml
{
Expand All @@ -16,12 +18,12 @@ internal class ValidatingReaderNodeData
private string _localName;
private string _namespaceUri;
private string _prefix;
private string _nameWPrefix;
private string? _nameWPrefix;

private string _rawValue;
private string _originalStringValue; // Original value
private string? _originalStringValue; // Original value
private int _depth;
private AttributePSVIInfo _attributePSVIInfo; //Used only for default attributes
private AttributePSVIInfo? _attributePSVIInfo; //Used only for default attributes
private XmlNodeType _nodeType;

private int _lineNo;
Expand Down Expand Up @@ -86,6 +88,7 @@ public string GetAtomizedNameWPrefix(XmlNameTable nameTable)
_nameWPrefix = nameTable.Add(string.Concat(_prefix, ":", _localName));
}
}

return _nameWPrefix;
}

Expand Down Expand Up @@ -113,7 +116,7 @@ public string RawValue
}
}

public string OriginalStringValue
public string? OriginalStringValue
{
get
{
Expand All @@ -137,7 +140,7 @@ public XmlNodeType NodeType
}
}

public AttributePSVIInfo AttInfo
public AttributePSVIInfo? AttInfo
{
get
{
Expand Down Expand Up @@ -165,17 +168,23 @@ public int LinePosition
}
}

[MemberNotNull(nameof(_localName))]
[MemberNotNull(nameof(_prefix))]
[MemberNotNull(nameof(_namespaceUri))]
[MemberNotNull(nameof(_rawValue))]
internal void Clear(XmlNodeType nodeType)
{
_nodeType = nodeType;
_localName = string.Empty;
_prefix = string.Empty;
_namespaceUri = string.Empty;
_rawValue = string.Empty;

if (_attributePSVIInfo != null)
{
_attributePSVIInfo.Reset();
}

_nameWPrefix = null;
_lineNo = 0;
_linePos = 0;
Expand All @@ -187,7 +196,7 @@ internal void SetLineInfo(int lineNo, int linePos)
_linePos = linePos;
}

internal void SetLineInfo(IXmlLineInfo lineInfo)
internal void SetLineInfo(IXmlLineInfo? lineInfo)
{
if (lineInfo != null)
{
Expand All @@ -210,7 +219,7 @@ internal void SetItemData(string value)
SetItemData(value, value);
}

internal void SetItemData(string value, string originalStringValue)
internal void SetItemData(string value, string? originalStringValue)
{
_rawValue = value;
_originalStringValue = originalStringValue;
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
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
Expand Down Expand Up @@ -64,7 +65,7 @@ public override XmlReaderSettings Settings
{
get
{
XmlReaderSettings settings = _coreReader.Settings;
XmlReaderSettings? settings = _coreReader.Settings;
if (null != settings)
{
settings = settings.Clone();
Expand Down Expand Up @@ -151,7 +152,7 @@ public override int Depth
}
}

public override string BaseURI
public override string? BaseURI
{
get
{
Expand Down Expand Up @@ -205,7 +206,7 @@ public override string XmlLang
}
}

public override IXmlSchemaInfo SchemaInfo
public override IXmlSchemaInfo? SchemaInfo
{
get
{
Expand Down Expand Up @@ -418,13 +419,13 @@ public override int AttributeCount
}
}

public override string GetAttribute(string name)
public override string? GetAttribute(string name)
{
CheckAsync();
return _coreReader.GetAttribute(name);
}

public override string GetAttribute(string name, string namespaceURI)
public override string? GetAttribute(string name, string? namespaceURI)
{
CheckAsync();
return _coreReader.GetAttribute(name, namespaceURI);
Expand All @@ -445,7 +446,7 @@ public override string this[int i]
}
}

public override string this[string name]
public override string? this[string name]
{
get
{
Expand All @@ -460,7 +461,7 @@ public override bool MoveToAttribute(string name)
return _coreReader.MoveToAttribute(name);
}

public override bool MoveToAttribute(string name, string ns)
public override bool MoveToAttribute(string name, string? ns)
{
CheckAsync();
return _coreReader.MoveToAttribute(name, ns);
Expand Down Expand Up @@ -541,7 +542,7 @@ public override XmlNameTable NameTable
}
}

public override string LookupNamespace(string prefix)
public override string? LookupNamespace(string prefix)
{
CheckAsync();
return _coreReader.LookupNamespace(prefix);
Expand Down Expand Up @@ -754,7 +755,7 @@ protected override void Dispose(bool disposing)
_coreReader.Dispose();
}

internal override XmlNamespaceManager NamespaceManager
internal override XmlNamespaceManager? NamespaceManager
{
get
{
Expand All @@ -763,7 +764,7 @@ internal override XmlNamespaceManager NamespaceManager
}
}

internal override IDtdInfo DtdInfo
internal override IDtdInfo? DtdInfo
{
get
{
Expand Down Expand Up @@ -930,12 +931,12 @@ IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope(XmlNamesp
return _readerAsIXmlNamespaceResolver.GetNamespacesInScope(scope);
}

string IXmlNamespaceResolver.LookupNamespace(string prefix)
string? IXmlNamespaceResolver.LookupNamespace(string prefix)
{
return _readerAsIXmlNamespaceResolver.LookupNamespace(prefix);
}

string IXmlNamespaceResolver.LookupPrefix(string namespaceName)
string? IXmlNamespaceResolver.LookupPrefix(string namespaceName)
{
return _readerAsIXmlNamespaceResolver.LookupPrefix(namespaceName);
}
Expand Down Expand Up @@ -992,12 +993,12 @@ IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope(XmlNamesp
return _readerAsIXmlNamespaceResolver.GetNamespacesInScope(scope);
}

string IXmlNamespaceResolver.LookupNamespace(string prefix)
string? IXmlNamespaceResolver.LookupNamespace(string prefix)
{
return _readerAsIXmlNamespaceResolver.LookupNamespace(prefix);
}

string IXmlNamespaceResolver.LookupPrefix(string namespaceName)
string? IXmlNamespaceResolver.LookupPrefix(string namespaceName)
{
return _readerAsIXmlNamespaceResolver.LookupPrefix(namespaceName);
}
Expand All @@ -1014,7 +1015,6 @@ public XmlAsyncCheckReaderWithLineInfoNSSchema(XmlReader reader)
_readerAsIXmlSchemaInfo = (IXmlSchemaInfo)reader;
}


#region IXmlSchemaInfo members

XmlSchemaValidity IXmlSchemaInfo.Validity
Expand All @@ -1041,31 +1041,31 @@ bool IXmlSchemaInfo.IsNil
}
}

XmlSchemaSimpleType IXmlSchemaInfo.MemberType
XmlSchemaSimpleType? IXmlSchemaInfo.MemberType
{
get
{
return _readerAsIXmlSchemaInfo.MemberType;
}
}

XmlSchemaType IXmlSchemaInfo.SchemaType
XmlSchemaType? IXmlSchemaInfo.SchemaType
{
get
{
return _readerAsIXmlSchemaInfo.SchemaType;
}
}

XmlSchemaElement IXmlSchemaInfo.SchemaElement
XmlSchemaElement? IXmlSchemaInfo.SchemaElement
{
get
{
return _readerAsIXmlSchemaInfo.SchemaElement;
}
}

XmlSchemaAttribute IXmlSchemaInfo.SchemaAttribute
XmlSchemaAttribute? IXmlSchemaInfo.SchemaAttribute
{
get
{
Expand Down
Loading

0 comments on commit 0e5614c

Please sign in to comment.