Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/NuGet.Core/NuGet.Protocol/HttpSourceCacheContext.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

using System;
using System.Diagnostics;

namespace NuGet.Protocol.Core.Types
{
public class HttpSourceCacheContext
{
private HttpSourceCacheContext(string rootTempFolder, TimeSpan maxAge, bool directDownload, SourceCacheContext cacheContext)
private HttpSourceCacheContext(string? rootTempFolder, TimeSpan maxAge, bool directDownload, SourceCacheContext cacheContext)
{
if (maxAge <= TimeSpan.Zero)
{
Expand Down Expand Up @@ -40,7 +38,7 @@ private HttpSourceCacheContext(string rootTempFolder, TimeSpan maxAge, bool dire
/// A suggested root folder to drop temporary files under, it will get cleared by the
/// disposal of the <see cref="SourceCacheContext"/> that was used to create this instance.
/// </summary>
public string RootTempFolder { get; }
public string? RootTempFolder { get; }

/// <summary>
/// Inner cache context.
Expand Down
8 changes: 3 additions & 5 deletions src/NuGet.Core/NuGet.Protocol/NullSourceCacheContext.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#nullable disable

namespace NuGet.Protocol.Core.Types
{
public class NullSourceCacheContext : SourceCacheContext
{
private static SourceCacheContext _instance;
private static SourceCacheContext? _instance;

public static SourceCacheContext Instance
{
Expand All @@ -28,8 +26,8 @@ public override string GeneratedTempFolder
}
}

public override SourceCacheContext WithRefreshCacheTrue() { return _instance; }
public override SourceCacheContext WithRefreshCacheTrue() { return Instance; }

public override SourceCacheContext Clone() { return _instance; }
public override SourceCacheContext Clone() { return Instance; }
}
}
14 changes: 6 additions & 8 deletions src/NuGet.Core/NuGet.Protocol/PackageDownloadContext.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

using System;
using NuGet.Configuration;
using NuGet.Packaging.Signing;
Expand All @@ -21,7 +19,7 @@ public PackageDownloadContext(SourceCacheContext sourceCacheContext) : this(

public PackageDownloadContext(
SourceCacheContext sourceCacheContext,
string directDownloadDirectory,
string? directDownloadDirectory,
bool directDownload)
{
if (sourceCacheContext == null)
Expand All @@ -43,9 +41,9 @@ public PackageDownloadContext(

public PackageDownloadContext(
SourceCacheContext sourceCacheContext,
string directDownloadDirectory,
string? directDownloadDirectory,
bool directDownload,
PackageSourceMapping packageSourceMappingConfiguration) : this(
PackageSourceMapping? packageSourceMappingConfiguration) : this(
sourceCacheContext,
directDownloadDirectory,
directDownload)
Expand All @@ -55,11 +53,11 @@ public PackageDownloadContext(

public SourceCacheContext SourceCacheContext { get; }
public bool DirectDownload { get; }
public string DirectDownloadDirectory { get; }
public string? DirectDownloadDirectory { get; }

public Guid ParentId { get; set; }

public ClientPolicyContext ClientPolicyContext { get; set; }
public PackageSourceMapping PackageSourceMapping { get; }
public ClientPolicyContext? ClientPolicyContext { get; set; }
public PackageSourceMapping? PackageSourceMapping { get; }
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions src/NuGet.Core/NuGet.Protocol/RemoteSourceDependencyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -40,6 +38,11 @@ public RemoteSourceDependencyInfo(
throw new ArgumentNullException(nameof(dependencyGroups));
}

if (contentUri == null)
{
throw new ArgumentNullException(nameof(contentUri));
}

Identity = identity;
Listed = listed;
DependencyGroups = dependencyGroups.ToList();
Expand All @@ -66,15 +69,15 @@ public RemoteSourceDependencyInfo(
/// </summary>
public string ContentUri { get; set; }

public bool Equals(RemoteSourceDependencyInfo other)
public bool Equals(RemoteSourceDependencyInfo? other)
{
return other != null &&
Identity.Equals(other.Identity) &&
new HashSet<PackageDependencyGroup>(DependencyGroups).SetEquals(other.DependencyGroups) &&
string.Equals(ContentUri, other.ContentUri, StringComparison.Ordinal);
}

public override bool Equals(object obj) => Equals(obj as PackageDependencyInfo);
public override bool Equals(object? obj) => Equals(obj as RemoteSourceDependencyInfo);

public override int GetHashCode()
{
Expand Down
11 changes: 5 additions & 6 deletions src/NuGet.Core/NuGet.Protocol/SourceCacheContext.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

using System;
using System.Diagnostics;
using System.IO;
Expand All @@ -19,7 +17,7 @@ public class SourceCacheContext : IDisposable
/// <summary>
/// Path of temp folder if requested by GeneratedTempFolder
/// </summary>
private string _generatedTempFolder = null;
private string? _generatedTempFolder;

/// <summary>
/// Default amount of time to cache version lists.
Expand Down Expand Up @@ -121,16 +119,17 @@ public virtual string GeneratedTempFolder
/// </summary>
public virtual SourceCacheContext Clone()
{
return new SourceCacheContext()
var clone = new SourceCacheContext()
{
DirectDownload = DirectDownload,
IgnoreFailedSources = IgnoreFailedSources,
MaxAge = MaxAge,
NoCache = NoCache,
GeneratedTempFolder = _generatedTempFolder,
RefreshMemoryCache = RefreshMemoryCache,
SessionId = SessionId
};
clone._generatedTempFolder = _generatedTempFolder;
return clone;
}

/// <summary>
Expand Down Expand Up @@ -161,7 +160,7 @@ protected virtual void Dispose(bool disposing)
{
try
{
Directory.Delete(_generatedTempFolder, recursive: true);
Directory.Delete(currentTempFolder, recursive: true);
}
catch
{
Expand Down
22 changes: 10 additions & 12 deletions src/NuGet.Core/NuGet.Protocol/SourcePackageDependencyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

using System;
using System.Collections.Generic;
using NuGet.Packaging.Core;
Expand All @@ -17,7 +15,7 @@ public SourcePackageDependencyInfo(
NuGetVersion version,
IEnumerable<PackageDependency> dependencies,
bool listed,
SourceRepository source)
SourceRepository? source)
: this(
new PackageIdentity(id, version),
dependencies,
Expand All @@ -33,9 +31,9 @@ public SourcePackageDependencyInfo(
NuGetVersion version,
IEnumerable<PackageDependency> dependencies,
bool listed,
SourceRepository source,
Uri downloadUri,
string packageHash)
SourceRepository? source,
Uri? downloadUri,
string? packageHash)
: this(
new PackageIdentity(id, version),
dependencies,
Expand All @@ -50,9 +48,9 @@ public SourcePackageDependencyInfo(
PackageIdentity identity,
IEnumerable<PackageDependency> dependencies,
bool listed,
SourceRepository source,
Uri downloadUri,
string packageHash)
SourceRepository? source,
Uri? downloadUri,
string? packageHash)
: base(identity, dependencies)
{
Listed = listed;
Expand All @@ -70,18 +68,18 @@ public SourcePackageDependencyInfo(
/// <summary>
/// Source repository the dependency information was retrieved from.
/// </summary>
public SourceRepository Source { get; }
public SourceRepository? Source { get; }

/// <summary>
/// The HTTP, UNC, or local file URI to the package nupkg.
/// </summary>
/// <remarks>Optional</remarks>
public Uri DownloadUri { get; }
public Uri? DownloadUri { get; }

/// <summary>
/// Package hash
/// </summary>
/// <remarks>Optional</remarks>
public string PackageHash { get; }
public string? PackageHash { get; }
}
}
2 changes: 0 additions & 2 deletions src/NuGet.Core/NuGet.Protocol/UserAgent.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

using System;
using System.Net.Http;
using NuGet.Packaging;
Expand Down
10 changes: 4 additions & 6 deletions src/NuGet.Core/NuGet.Protocol/UserAgentStringBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

#if NETCOREAPP
using System;
#endif
Expand All @@ -22,9 +20,9 @@ public class UserAgentStringBuilder
private const string UserAgentTemplate = "{0}/{1}";

private readonly string _clientName;
private string _vsInfo;
private string _osInfo;
private string _ciInfo;
private string? _vsInfo;
private string? _osInfo;
private string? _ciInfo;

public UserAgentStringBuilder()
: this(DefaultNuGetClientName)
Expand Down Expand Up @@ -54,7 +52,7 @@ internal UserAgentStringBuilder(string clientName, IEnvironmentVariableReader en

public string NuGetClientVersion { get; }

public UserAgentStringBuilder WithVisualStudioSKU(string vsInfo)
public UserAgentStringBuilder WithVisualStudioSKU(string? vsInfo)
{
_vsInfo = vsInfo;
return this;
Expand Down
Loading