Skip to content

Commit f016fcc

Browse files
committed
more nullable work
1 parent 7a99883 commit f016fcc

10 files changed

Lines changed: 65 additions & 77 deletions

src/NuGet.Core/NuGet.Common/MsBuildStringUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static bool IsTrueOrEmpty(string? value)
9191
/// </summary>
9292
/// <param name="s">A comma or semicolon delimited list of NuGet log codes.</param>
9393
/// <returns>An <see cref="IList{T}" /> containing the <see cref="NuGetLogCode" /> values that were successfully parsed from the specified string.</returns>
94-
public static ImmutableArray<NuGetLogCode> GetNuGetLogCodes(string s)
94+
public static ImmutableArray<NuGetLogCode> GetNuGetLogCodes(string? s)
9595
{
9696
// The Split() method already checks for an empty string and returns Array.Empty<string>().
9797
string[] split = MSBuildStringUtility.Split(s, ';', ',');

src/NuGet.Core/NuGet.Common/PublicAPI.Shipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ static NuGet.Common.LoggingExtensions.GetName(this NuGet.Common.NuGetLogCode cod
576576
static NuGet.Common.LoggingExtensions.TryGetName(this NuGet.Common.NuGetLogCode code, out string? codeString) -> bool
577577
static NuGet.Common.MSBuildStringUtility.Convert(string? value) -> string?
578578
static NuGet.Common.MSBuildStringUtility.GetBooleanOrNull(string? value) -> bool?
579-
static NuGet.Common.MSBuildStringUtility.GetNuGetLogCodes(string! s) -> System.Collections.Immutable.ImmutableArray<NuGet.Common.NuGetLogCode>
579+
static NuGet.Common.MSBuildStringUtility.GetNuGetLogCodes(string? s) -> System.Collections.Immutable.ImmutableArray<NuGet.Common.NuGetLogCode>
580580
static NuGet.Common.MSBuildStringUtility.IsTrue(string? value) -> bool
581581
static NuGet.Common.MSBuildStringUtility.IsTrueOrEmpty(string? value) -> bool
582582
static NuGet.Common.MSBuildStringUtility.Split(string? s) -> string![]!

src/NuGet.Core/NuGet.ProjectModel/CentralTransitiveDependencyGroup.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
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-
64
using System;
75
using System.Collections.Generic;
86
using NuGet.Frameworks;
@@ -32,7 +30,7 @@ public CentralTransitiveDependencyGroup(NuGetFramework framework, IEnumerable<Li
3230

3331
public IEnumerable<LibraryDependency> TransitiveDependencies { get; }
3432

35-
public bool Equals(CentralTransitiveDependencyGroup other)
33+
public bool Equals(CentralTransitiveDependencyGroup? other)
3634
{
3735
if (other == null)
3836
{
@@ -52,7 +50,7 @@ public bool Equals(CentralTransitiveDependencyGroup other)
5250
return false;
5351
}
5452

55-
public override bool Equals(object obj)
53+
public override bool Equals(object? obj)
5654
{
5755
return Equals(obj as CentralTransitiveDependencyGroup);
5856
}

src/NuGet.Core/NuGet.ProjectModel/IExternalProjectReferenceProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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-
4+
using System;
65
using System.Collections.Generic;
76

87
namespace NuGet.ProjectModel
98
{
9+
[Obsolete("This API is unused and will be removed in a future release.")]
1010
/// <summary>
1111
/// Provides external project reference closures.
1212
/// </summary>

src/NuGet.Core/NuGet.ProjectModel/ProjectFileDependencyGroup.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
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-
64
using System;
75
using System.Collections.Generic;
86
using NuGet.Shared;
@@ -13,15 +11,15 @@ public class ProjectFileDependencyGroup : IEquatable<ProjectFileDependencyGroup>
1311
{
1412
public ProjectFileDependencyGroup(string frameworkName, IEnumerable<string> dependencies)
1513
{
16-
FrameworkName = frameworkName;
17-
Dependencies = dependencies;
14+
FrameworkName = frameworkName ?? throw new ArgumentNullException(nameof(frameworkName));
15+
Dependencies = dependencies ?? throw new ArgumentNullException(nameof(dependencies));
1816
}
1917

2018
public string FrameworkName { get; }
2119

2220
public IEnumerable<string> Dependencies { get; }
2321

24-
public bool Equals(ProjectFileDependencyGroup other)
22+
public bool Equals(ProjectFileDependencyGroup? other)
2523
{
2624
if (other == null)
2725
{
@@ -46,7 +44,7 @@ public bool Equals(ProjectFileDependencyGroup other)
4644
return false;
4745
}
4846

49-
public override bool Equals(object obj)
47+
public override bool Equals(object? obj)
5048
{
5149
return Equals(obj as ProjectFileDependencyGroup);
5250
}

src/NuGet.Core/NuGet.ProjectModel/ProjectRestoreMetadataFile.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
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-
64
using System;
75
using NuGet.Shared;
86

@@ -38,7 +36,7 @@ public ProjectRestoreMetadataFile(string packagePath, string absolutePath)
3836
AbsolutePath = absolutePath;
3937
}
4038

41-
public bool Equals(ProjectRestoreMetadataFile other)
39+
public bool Equals(ProjectRestoreMetadataFile? other)
4240
{
4341
if (ReferenceEquals(this, other))
4442
{
@@ -54,7 +52,7 @@ public bool Equals(ProjectRestoreMetadataFile other)
5452
&& StringComparer.Ordinal.Equals(AbsolutePath, other.AbsolutePath);
5553
}
5654

57-
public override bool Equals(object obj)
55+
public override bool Equals(object? obj)
5856
{
5957
return Equals(obj as ProjectRestoreMetadataFile);
6058
}
@@ -74,9 +72,9 @@ public override string ToString()
7472
return PackagePath;
7573
}
7674

77-
public int CompareTo(ProjectRestoreMetadataFile other)
75+
public int CompareTo(ProjectRestoreMetadataFile? other)
7876
{
79-
return StringComparer.Ordinal.Compare(PackagePath, other.PackagePath);
77+
return StringComparer.Ordinal.Compare(PackagePath, other?.PackagePath);
8078
}
8179

8280
public ProjectRestoreMetadataFile Clone()

src/NuGet.Core/NuGet.ProjectModel/ProjectRestoreSettings.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
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-
64
using NuGet.Shared;
75
using NuGet.Versioning;
86

@@ -23,7 +21,7 @@ public class ProjectRestoreSettings
2321
/// Indicates the .NET SDK Version if any.
2422
/// In combination with SdkAnalysisLevel, it allows us to determine whether the analysis level is the default one or manually specified.
2523
/// </summary>
26-
public NuGetVersion SdkVersion { get; set; }
24+
public NuGetVersion? SdkVersion { get; set; }
2725

2826
public ProjectRestoreSettings Clone()
2927
{
@@ -33,12 +31,12 @@ public ProjectRestoreSettings Clone()
3331
return clonedObject;
3432
}
3533

36-
public override bool Equals(object obj)
34+
public override bool Equals(object? obj)
3735
{
3836
return Equals(obj as ProjectRestoreSettings);
3937
}
4038

41-
public bool Equals(ProjectRestoreSettings other)
39+
public bool Equals(ProjectRestoreSettings? other)
4240
{
4341
if (other == null)
4442
{

0 commit comments

Comments
 (0)