Skip to content

Commit

Permalink
Replace calls to Any() on ICollection in PackageSpecWriter with Count…
Browse files Browse the repository at this point in the history
… > 0 Issue #13213 (#5629)
  • Loading branch information
GenelleM authored Feb 13, 2024
1 parent 2d388e3 commit c1ae39a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/NuGet.Core/NuGet.ProjectModel/PackageSpecWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal static void Write(PackageSpec packageSpec, IObjectWriter writer, bool h
#pragma warning restore CS0612 // Type or member is obsolete


if (packageSpec.Dependencies.Any())
if (packageSpec.Dependencies.Count > 0)
{
SetDependencies(writer, packageSpec.Dependencies);
}
Expand Down Expand Up @@ -553,7 +553,7 @@ internal static void SetCentralTransitveDependencyGroup(IObjectWriter writer, st

private static void SetImports(IObjectWriter writer, IList<NuGetFramework> frameworks)
{
if (frameworks?.Any() == true)
if (frameworks?.Count > 0)
{
var imports = frameworks.Select(framework => framework.GetShortFolderName());

Expand All @@ -563,7 +563,7 @@ private static void SetImports(IObjectWriter writer, IList<NuGetFramework> frame

private static void SetDownloadDependencies(IObjectWriter writer, IList<DownloadDependency> downloadDependencies)
{
if (!downloadDependencies.Any())
if (!(downloadDependencies.Count > 0))
{
return;
}
Expand All @@ -585,7 +585,7 @@ private static void SetDownloadDependencies(IObjectWriter writer, IList<Download

private static void SetFrameworks(IObjectWriter writer, IList<TargetFrameworkInformation> frameworks, bool hashing)
{
if (frameworks.Any())
if (frameworks.Count > 0)
{
writer.WriteObjectStart("frameworks");
var frameworkSorter = NuGetFrameworkSorter.Instance;
Expand Down Expand Up @@ -628,7 +628,7 @@ private static NuGetFramework DeconstructFallbackFrameworks(NuGetFramework nuGet

private static void SetFrameworkReferences(IObjectWriter writer, ISet<FrameworkDependency> frameworkReferences)
{
if (frameworkReferences?.Any() == true)
if (frameworkReferences?.Count > 0)
{
writer.WriteObjectStart("frameworkReferences");

Expand All @@ -644,7 +644,7 @@ private static void SetFrameworkReferences(IObjectWriter writer, ISet<FrameworkD

private static void SetCentralDependencies(IObjectWriter writer, ICollection<CentralPackageVersion> centralPackageVersions, bool hashing)
{
if (!centralPackageVersions.Any())
if (!(centralPackageVersions.Count > 0))
{
return;
}
Expand Down Expand Up @@ -703,7 +703,7 @@ private static void SetArrayValue(IObjectWriter writer, string name, IEnumerable

private static void SetDictionaryValue(IObjectWriter writer, string name, IDictionary<string, string> values)
{
if (values != null && values.Any())
if (values != null && values.Count > 0)
{
writer.WriteObjectStart(name);

Expand All @@ -720,7 +720,7 @@ private static void SetDictionaryValue(IObjectWriter writer, string name, IDicti

private static void SetDictionaryValues(IObjectWriter writer, string name, IDictionary<string, IEnumerable<string>> values)
{
if (values != null && values.Any())
if (values != null && values.Count > 0)
{
writer.WriteObjectStart(name);

Expand Down

0 comments on commit c1ae39a

Please # to comment.