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 . Globalization ;
@@ -19,14 +17,14 @@ namespace NuGet.Packaging
1917 /// </summary>
2018 public class ManifestMetadata : IPackageMetadata
2119 {
22- private string _minClientVersionString ;
20+ private string ? _minClientVersionString ;
2321
2422 private IEnumerable < string > _authors = Enumerable . Empty < string > ( ) ;
2523 private IEnumerable < string > _owners = Enumerable . Empty < string > ( ) ;
2624
27- private string _iconUrl ;
28- private string _licenseUrl ;
29- private string _projectUrl ;
25+ private string ? _iconUrl ;
26+ private string ? _licenseUrl ;
27+ private string ? _projectUrl ;
3028
3129 public ManifestMetadata ( )
3230 {
@@ -42,7 +40,7 @@ public ManifestMetadata(IPackageMetadata copy)
4240 Title = copy . Title ? . Trim ( ) ;
4341 Authors = copy . Authors ;
4442 Owners = copy . Owners ;
45- Tags = string . IsNullOrEmpty ( copy . Tags ) ? null : copy . Tags . Trim ( ) ;
43+ Tags = string . IsNullOrEmpty ( copy . Tags ) ? null : copy . Tags ! . Trim ( ) ;
4644 Serviceable = copy . Serviceable ;
4745 _licenseUrl = copy . LicenseUrl ? . OriginalString ;
4846 _projectUrl = copy . ProjectUrl ? . OriginalString ;
@@ -68,12 +66,12 @@ public ManifestMetadata(IPackageMetadata copy)
6866 Readme = copy . Readme ;
6967 }
7068
71- public string MinClientVersionString
69+ public string ? MinClientVersionString
7270 {
7371 get { return _minClientVersionString ; }
7472 set
7573 {
76- Version version = null ;
74+ Version ? version = null ;
7775 if ( ! String . IsNullOrEmpty ( value ) && ! System . Version . TryParse ( value , out version ) )
7876 {
7977 throw new InvalidDataException ( NuGetResources . Manifest_InvalidMinClientVersion ) ;
@@ -84,13 +82,13 @@ public string MinClientVersionString
8482 }
8583 }
8684
87- public Version MinClientVersion { get ; private set ; }
85+ public Version ? MinClientVersion { get ; private set ; }
8886
89- public string Id { get ; set ; }
87+ public string ? Id { get ; set ; }
9088
91- public NuGetVersion Version { get ; set ; }
89+ public NuGetVersion ? Version { get ; set ; }
9290
93- public string Title { get ; set ; }
91+ public string ? Title { get ; set ; }
9492
9593 public IEnumerable < string > Authors
9694 {
@@ -106,12 +104,12 @@ public IEnumerable<string> Owners
106104
107105 // The (Icon/License/Project)Url properties have backing strings as we need to be able to differentiate
108106 // between the property not being set (valid) and set to an empty value (invalid).
109- public void SetIconUrl ( string iconUrl )
107+ public void SetIconUrl ( string ? iconUrl )
110108 {
111109 _iconUrl = iconUrl ;
112110 }
113111
114- public Uri IconUrl
112+ public Uri ? IconUrl
115113 {
116114 get
117115 {
@@ -124,14 +122,14 @@ public Uri IconUrl
124122 }
125123 }
126124
127- public string Icon { get ; set ; }
125+ public string ? Icon { get ; set ; }
128126
129- public void SetLicenseUrl ( string licenseUrl )
127+ public void SetLicenseUrl ( string ? licenseUrl )
130128 {
131129 _licenseUrl = licenseUrl ;
132130 }
133131
134- public Uri LicenseUrl
132+ public Uri ? LicenseUrl
135133 {
136134 get
137135 {
@@ -144,12 +142,12 @@ public Uri LicenseUrl
144142 }
145143 }
146144
147- public void SetProjectUrl ( string projectUrl )
145+ public void SetProjectUrl ( string ? projectUrl )
148146 {
149147 _projectUrl = projectUrl ;
150148 }
151149
152- public Uri ProjectUrl
150+ public Uri ? ProjectUrl
153151 {
154152 get
155153 {
@@ -168,23 +166,23 @@ public Uri ProjectUrl
168166
169167 public bool DevelopmentDependency { get ; set ; }
170168
171- public string Description { get ; set ; }
169+ public string ? Description { get ; set ; }
172170
173- public string Summary { get ; set ; }
171+ public string ? Summary { get ; set ; }
174172
175- public string ReleaseNotes { get ; set ; }
173+ public string ? ReleaseNotes { get ; set ; }
176174
177- public string Copyright { get ; set ; }
175+ public string ? Copyright { get ; set ; }
178176
179- public string Language { get ; set ; }
177+ public string ? Language { get ; set ; }
180178
181- public string Tags { get ; set ; }
179+ public string ? Tags { get ; set ; }
182180
183- public string Readme { get ; set ; }
181+ public string ? Readme { get ; set ; }
184182
185183 public bool Serviceable { get ; set ; }
186184
187- public RepositoryMetadata Repository { get ; set ; }
185+ public RepositoryMetadata ? Repository { get ; set ; }
188186
189187 private IEnumerable < PackageDependencyGroup > _dependencyGroups = [ ] ;
190188 public IEnumerable < PackageDependencyGroup > DependencyGroups
@@ -222,7 +220,7 @@ private static IEnumerable<PackageReferenceSet> MergePackageAssemblyReferences(I
222220 {
223221 if ( referenceSets == null )
224222 {
225- Enumerable . Empty < PackageReferenceSet > ( ) ;
223+ return Enumerable . Empty < PackageReferenceSet > ( ) ;
226224 }
227225
228226 var referenceSetGroups = referenceSets . GroupBy ( set => set . TargetFramework ) ;
@@ -244,7 +242,7 @@ private static IEnumerable<PackageReferenceSet> MergePackageAssemblyReferences(I
244242
245243 public IEnumerable < PackageType > PackageTypes { get ; set ; } = new List < PackageType > ( ) ;
246244
247- public LicenseMetadata LicenseMetadata { get ; set ; } = null ;
245+ public LicenseMetadata ? LicenseMetadata { get ; set ; } = null ;
248246
249247 private static IEnumerable < PackageDependencyGroup > MergeDependencyGroups ( IEnumerable < PackageDependencyGroup > actualDependencyGroups )
250248 {
@@ -283,7 +281,7 @@ private static PackageDependencyGroup CreatePackageDependencyGroup(PackageDepend
283281 {
284282 var dependenciesList = dependencyGroup . Packages . Select ( dependency =>
285283 new PackageDependency (
286- dependency . Id . SafeTrim ( ) ,
284+ dependency . Id . SafeTrim ( ) ! ,
287285 dependency . VersionRange ,
288286 dependency . Include ,
289287 dependency . Exclude ) ) . ToList ( ) ;
@@ -306,7 +304,7 @@ public IEnumerable<string> Validate()
306304 }
307305 else
308306 {
309- if ( Id . Length > PackageIdValidator . MaxPackageIdLength )
307+ if ( Id ! . Length > PackageIdValidator . MaxPackageIdLength )
310308 {
311309 yield return String . Format ( CultureInfo . CurrentCulture , NuGetResources . Manifest_IdMaxLengthExceeded ) ;
312310 }
@@ -369,7 +367,7 @@ public IEnumerable<string> Validate()
369367 }
370368 }
371369
372- if ( _licenseUrl != null && LicenseMetadata != null && ( string . IsNullOrWhiteSpace ( _licenseUrl ) || ! LicenseUrl . Equals ( LicenseMetadata . LicenseUrl ) ) )
370+ if ( _licenseUrl != null && LicenseMetadata != null && ( string . IsNullOrWhiteSpace ( _licenseUrl ) || ! LicenseUrl ! . Equals ( LicenseMetadata . LicenseUrl ) ) )
373371 {
374372 yield return NuGetResources . Manifest_LicenseUrlCannotBeUsedWithLicenseMetadata ;
375373 }
0 commit comments