Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#nullable enable

using System;
using System.Collections.Generic;
using System.Net;
Expand All @@ -16,12 +18,14 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
public class WebRequestSession : IDisposable
{
private HttpClient _client;
#region Fields

private HttpClient? _client;
private CookieContainer _cookies;
private bool _useDefaultCredentials;
private ICredentials _credentials;
private X509CertificateCollection _certificates;
private IWebProxy _proxy;
private ICredentials? _credentials;
private X509CertificateCollection? _certificates;
private IWebProxy? _proxy;
private int _maximumRedirection;
private WebSslProtocol _sslProtocol;
private bool _allowAutoRedirect;
Expand All @@ -35,6 +39,8 @@ public class WebRequestSession : IDisposable
/// </summary>
private bool _disposedClient;

#endregion Fields

/// <summary>
/// Gets or sets the Header property.
/// </summary>
Expand All @@ -61,15 +67,15 @@ public class WebRequestSession : IDisposable
/// <summary>
/// Gets or sets the Credentials property.
/// </summary>
public ICredentials Credentials { get => _credentials; set => SetClassVar(ref _credentials, value); }
public ICredentials? Credentials { get => _credentials; set => SetClassVar(ref _credentials, value); }

/// <summary>
/// Gets or sets the Certificates property.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public X509CertificateCollection Certificates { get => _certificates; set => SetClassVar(ref _certificates, value); }
public X509CertificateCollection? Certificates { get => _certificates; set => SetClassVar(ref _certificates, value); }

#endregion
#endregion Credentials

/// <summary>
/// Gets or sets the UserAgent property.
Expand All @@ -79,7 +85,7 @@ public class WebRequestSession : IDisposable
/// <summary>
/// Gets or sets the Proxy property.
/// </summary>
public IWebProxy Proxy
public IWebProxy? Proxy
{
get => _proxy;
set
Expand Down Expand Up @@ -238,7 +244,7 @@ private HttpClient CreateHttpClient()
};
}

private void SetClassVar<T>(ref T oldValue, T newValue) where T : class
private void SetClassVar<T>(ref T oldValue, T newValue) where T : class?
{
if (oldValue != newValue)
{
Expand Down