11// Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
4- #nullable disable
5-
64using System ;
75using System . Collections . Generic ;
86using System . Linq ;
@@ -13,16 +11,16 @@ namespace NuGet.Packaging
1311{
1412 public static class XElementExtensions
1513 {
16- public static string GetOptionalAttributeValue ( this XElement element , string localName , string namespaceName = null )
14+ public static string ? GetOptionalAttributeValue ( this XElement element , string localName , string ? namespaceName = null )
1715 {
18- XAttribute attr ;
16+ XAttribute ? attr ;
1917 if ( String . IsNullOrEmpty ( namespaceName ) )
2018 {
2119 attr = element . Attribute ( localName ) ;
2220 }
2321 else
2422 {
25- attr = element . Attribute ( XName . Get ( localName , namespaceName ) ) ;
23+ attr = element . Attribute ( XName . Get ( localName , namespaceName ! ) ) ;
2624 }
2725 return attr != null ? attr . Value : null ;
2826 }
@@ -32,7 +30,7 @@ public static IEnumerable<XElement> ElementsNoNamespace(this XContainer containe
3230 return container . Elements ( ) . Where ( e => e . Name . LocalName == localName ) ;
3331 }
3432
35- public static XElement Except ( this XElement source , XElement target )
33+ public static XElement Except ( this XElement source , XElement ? target )
3634 {
3735 if ( target == null )
3836 {
@@ -82,7 +80,7 @@ where AttributeEquals(e, target.Attribute(e.Name))
8280 return source ;
8381 }
8482
85- private static XElement FindElement ( XElement source , XElement targetChild )
83+ private static XElement ? FindElement ( XElement source , XElement targetChild )
8684 {
8785 // Get all of the elements in the source that match this name
8886 var sourceElements = source . Elements ( targetChild . Name ) . ToList ( ) ;
@@ -132,7 +130,7 @@ private static bool HasConflict(XElement source, XElement target)
132130 // Loop over all the other attributes and see if there are
133131 foreach ( var targetAttr in target . Attributes ( ) )
134132 {
135- string sourceValue ;
133+ string ? sourceValue ;
136134 // if any of the attributes are in the source (names match) but the value doesn't match then we've found a conflict
137135 if ( sourceAttr . TryGetValue ( targetAttr . Name , out sourceValue )
138136 && sourceValue != targetAttr . Value )
@@ -143,7 +141,7 @@ private static bool HasConflict(XElement source, XElement target)
143141 return false ;
144142 }
145143
146- private static bool AttributeEquals ( XAttribute source , XAttribute target )
144+ private static bool AttributeEquals ( XAttribute ? source , XAttribute ? target )
147145 {
148146 if ( source == null
149147 && target == null )
0 commit comments