diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.cs index 3a69c29494e75..84d26a3faf4ea 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.cs @@ -8,8 +8,8 @@ namespace Microsoft.Extensions.Configuration { public static partial class XmlConfigurationExtensions { - public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddXmlFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, Microsoft.Extensions.FileProviders.IFileProvider provider, string path, bool optional, bool reloadOnChange) { throw null; } - public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddXmlFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, System.Action configureSource) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddXmlFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, Microsoft.Extensions.FileProviders.IFileProvider? provider, string path, bool optional, bool reloadOnChange) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddXmlFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, System.Action? configureSource) { throw null; } public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddXmlFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string path) { throw null; } public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddXmlFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string path, bool optional) { throw null; } public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddXmlFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string path, bool optional, bool reloadOnChange) { throw null; } @@ -32,7 +32,7 @@ public partial class XmlDocumentDecryptor { public static readonly Microsoft.Extensions.Configuration.Xml.XmlDocumentDecryptor Instance; protected XmlDocumentDecryptor() { } - public System.Xml.XmlReader CreateDecryptingXmlReader(System.IO.Stream input, System.Xml.XmlReaderSettings settings) { throw null; } + public System.Xml.XmlReader CreateDecryptingXmlReader(System.IO.Stream input, System.Xml.XmlReaderSettings? settings) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] protected virtual System.Xml.XmlReader DecryptDocumentAndCreateXmlReader(System.Xml.XmlDocument document) { throw null; } } @@ -40,7 +40,7 @@ public partial class XmlStreamConfigurationProvider : Microsoft.Extensions.Confi { public XmlStreamConfigurationProvider(Microsoft.Extensions.Configuration.Xml.XmlStreamConfigurationSource source) : base (default(Microsoft.Extensions.Configuration.StreamConfigurationSource)) { } public override void Load(System.IO.Stream stream) { } - public static System.Collections.Generic.IDictionary Read(System.IO.Stream stream, Microsoft.Extensions.Configuration.Xml.XmlDocumentDecryptor decryptor) { throw null; } + public static System.Collections.Generic.IDictionary Read(System.IO.Stream stream, Microsoft.Extensions.Configuration.Xml.XmlDocumentDecryptor decryptor) { throw null; } } public partial class XmlStreamConfigurationSource : Microsoft.Extensions.Configuration.StreamConfigurationSource { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.csproj b/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.csproj index 68ad5b0137bbc..61e5608a61095 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.csproj @@ -1,6 +1,7 @@ $(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + enable diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj index b07237dd68d22..2f7d296028878 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + enable true false diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlConfigurationElement.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlConfigurationElement.cs index 242d149e440c2..ec51d7cdacd7f 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlConfigurationElement.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlConfigurationElement.cs @@ -10,7 +10,7 @@ internal sealed class XmlConfigurationElement { public string ElementName { get; } - public string Name { get; } + public string? Name { get; } /// /// A composition of ElementName and Name, that serves as the basis for detecting siblings @@ -20,18 +20,18 @@ internal sealed class XmlConfigurationElement /// /// The children of this element /// - public IDictionary> ChildrenBySiblingName { get; set; } + public IDictionary>? ChildrenBySiblingName { get; set; } /// /// Performance optimization: do not initialize a dictionary and a list for elements with a single child /// - public XmlConfigurationElement SingleChild { get; set; } + public XmlConfigurationElement? SingleChild { get; set; } - public XmlConfigurationElementTextContent TextContent { get; set; } + public XmlConfigurationElementTextContent? TextContent { get; set; } - public List Attributes { get; set; } + public List? Attributes { get; set; } - public XmlConfigurationElement(string elementName!!, string name) + public XmlConfigurationElement(string elementName!!, string? name) { ElementName = elementName; Name = name; diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlConfigurationExtensions.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlConfigurationExtensions.cs index 24cb252ec5590..a45173b132cff 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlConfigurationExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlConfigurationExtensions.cs @@ -62,7 +62,7 @@ public static IConfigurationBuilder AddXmlFile(this IConfigurationBuilder builde /// Whether the file is optional. /// Whether the configuration should be reloaded if the file changes. /// The . - public static IConfigurationBuilder AddXmlFile(this IConfigurationBuilder builder!!, IFileProvider provider, string path, bool optional, bool reloadOnChange) + public static IConfigurationBuilder AddXmlFile(this IConfigurationBuilder builder!!, IFileProvider? provider, string path, bool optional, bool reloadOnChange) { if (string.IsNullOrEmpty(path)) { @@ -85,7 +85,7 @@ public static IConfigurationBuilder AddXmlFile(this IConfigurationBuilder builde /// The to add to. /// Configures the source. /// The . - public static IConfigurationBuilder AddXmlFile(this IConfigurationBuilder builder, Action configureSource) + public static IConfigurationBuilder AddXmlFile(this IConfigurationBuilder builder, Action? configureSource) => builder.Add(configureSource); /// diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs index 5fb31b2cdfefc..ba8650882a2ff 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs @@ -19,7 +19,7 @@ public class XmlDocumentDecryptor /// public static readonly XmlDocumentDecryptor Instance = new XmlDocumentDecryptor(); - private readonly Func _encryptedXmlFactory; + private readonly Func? _encryptedXmlFactory; /// /// Initializes a XmlDocumentDecryptor. @@ -50,7 +50,7 @@ private static bool ContainsEncryptedData(XmlDocument document) /// /// Returns an XmlReader that decrypts data transparently. /// - public XmlReader CreateDecryptingXmlReader(Stream input, XmlReaderSettings settings) + public XmlReader CreateDecryptingXmlReader(Stream input, XmlReaderSettings? settings) { // XML-based configurations aren't really all that big, so we can buffer // the whole thing in memory while we determine decryption operations. @@ -98,7 +98,7 @@ protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument docume // Finally, return the new XmlReader from the updated XmlDocument. // Error messages based on this XmlReader won't show line numbers, // but that's fine since we transformed the document anyway. - return document.CreateNavigator().ReadSubtree(); + return document.CreateNavigator()!.ReadSubtree(); } } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlStreamConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlStreamConfigurationProvider.cs index 920a9968f4176..2c0e6f56ecb2a 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlStreamConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlStreamConfigurationProvider.cs @@ -29,7 +29,7 @@ public XmlStreamConfigurationProvider(XmlStreamConfigurationSource source) : bas /// The stream of XML data. /// The to use to decrypt. /// The which was read from the stream. - public static IDictionary Read(Stream stream, XmlDocumentDecryptor decryptor) + public static IDictionary Read(Stream stream, XmlDocumentDecryptor decryptor) { var readerSettings = new XmlReaderSettings() { @@ -39,7 +39,7 @@ public static IDictionary Read(Stream stream, XmlDocumentDecrypt IgnoreWhitespace = true }; - XmlConfigurationElement root = null; + XmlConfigurationElement? root = null; using (XmlReader reader = decryptor.CreateDecryptingXmlReader(stream, readerSettings)) { @@ -211,7 +211,7 @@ private static void ReadAttributes(XmlReader reader, XmlConfigurationElement ele throw new FormatException(SR.Format(SR.Error_NamespaceIsNotSupported, GetLineInfo(reader))); } - element.Attributes.Add(new XmlConfigurationElementAttributeValue(reader.LocalName, reader.Value, lineNumber, linePosition)); + element.Attributes!.Add(new XmlConfigurationElementAttributeValue(reader.LocalName, reader.Value, lineNumber, linePosition)); } // Go back to the element containing the attributes we just processed @@ -221,9 +221,9 @@ private static void ReadAttributes(XmlReader reader, XmlConfigurationElement ele // The special attribute "Name" only contributes to prefix // This method retrieves the Name of the element, if the attribute is present // Unfortunately XmlReader.GetAttribute cannot be used, as it does not support looking for attributes in a case insensitive manner - private static string GetName(XmlReader reader) + private static string? GetName(XmlReader reader) { - string name = null; + string? name = null; while (reader.MoveToNextAttribute()) { @@ -245,9 +245,9 @@ private static string GetName(XmlReader reader) return name; } - private static IDictionary ProvideConfiguration(XmlConfigurationElement root) + private static IDictionary ProvideConfiguration(XmlConfigurationElement? root) { - var configuration = new Dictionary(StringComparer.OrdinalIgnoreCase); + Dictionary configuration = new(StringComparer.OrdinalIgnoreCase); if (root == null) {