From 25a769d75da05bbf9443637260587f54ec686927 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 2 Nov 2020 07:24:43 +0000 Subject: [PATCH] Fix IDE0044: MakeFieldReadonly part 8 (#13891) https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0044 --- .../security/CatalogCommands.cs | 2 +- .../security/CertificateCommands.cs | 2 +- .../security/CertificateProvider.cs | 22 +++++++++---------- .../security/CmsCommands.cs | 6 ++--- .../security/SecureStringCommands.cs | 2 +- .../security/SignatureCommands.cs | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Microsoft.PowerShell.Security/security/CatalogCommands.cs b/src/Microsoft.PowerShell.Security/security/CatalogCommands.cs index 5d09441390..895a551e05 100644 --- a/src/Microsoft.PowerShell.Security/security/CatalogCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/CatalogCommands.cs @@ -60,7 +60,7 @@ namespace Microsoft.PowerShell.Commands // // name of this command // - private string commandName; + private readonly string commandName; /// /// Initializes a new instance of the CatalogCommandsBase class, diff --git a/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs b/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs index 28163845d2..7dc5235edd 100644 --- a/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs @@ -80,7 +80,7 @@ namespace Microsoft.PowerShell.Commands // // list of files that were not found // - private List _filesNotFound = new List(); + private readonly List _filesNotFound = new List(); /// /// Initializes a new instance of the GetPfxCertificateCommand diff --git a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs index ff66e7c993..379dddf06c 100644 --- a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs +++ b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs @@ -127,12 +127,12 @@ namespace Microsoft.PowerShell.Commands /// /// Punycode version of DNS name. /// - private string _punycodeName; + private readonly string _punycodeName; /// /// Unicode version of DNS name. /// - private string _unicodeName; + private readonly string _unicodeName; /// /// Ambiguous constructor of a DnsNameRepresentation. @@ -511,8 +511,8 @@ namespace Microsoft.PowerShell.Commands } private bool _archivedCerts = false; - private X509StoreLocation _storeLocation = null; - private string _storeName = null; + private readonly X509StoreLocation _storeLocation = null; + private readonly string _storeName = null; private CertificateStoreHandle _storeHandle = null; private bool _valid = false; private bool _open = false; @@ -581,7 +581,7 @@ namespace Microsoft.PowerShell.Commands /// -- storeLocations /// -- pathCache. /// - private static object s_staticLock = new object(); + private static readonly object s_staticLock = new object(); /// /// List of store locations. They do not change once initialized. @@ -3068,12 +3068,12 @@ namespace Microsoft.PowerShell.Commands /// /// Localized friendly name of EKU. /// - private string _friendlyName; + private readonly string _friendlyName; /// /// OID of EKU. /// - private string _oid; + private readonly string _oid; /// /// Constructor of an EnhancedKeyUsageRepresentation. @@ -3302,7 +3302,7 @@ namespace Microsoft.PowerShell.Commands /// public sealed class EnhancedKeyUsageProperty { - private List _ekuList = new List(); + private readonly List _ekuList = new List(); /// /// Get property of EKUList. @@ -3345,8 +3345,8 @@ namespace Microsoft.PowerShell.Commands /// public sealed class DnsNameProperty { - private List _dnsList = new List(); - private System.Globalization.IdnMapping idnMapping = new System.Globalization.IdnMapping(); + private readonly List _dnsList = new List(); + private readonly System.Globalization.IdnMapping idnMapping = new System.Globalization.IdnMapping(); private const string dnsNamePrefix = "DNS Name="; private const string distinguishedNamePrefix = "CN="; @@ -3552,7 +3552,7 @@ namespace Microsoft.PowerShell.Commands /// Lock that guards access to the following static members /// -- storeNames. /// - private static object s_staticLock = new object(); + private static readonly object s_staticLock = new object(); internal static readonly List storeNames = new List(); diff --git a/src/Microsoft.PowerShell.Security/security/CmsCommands.cs b/src/Microsoft.PowerShell.Security/security/CmsCommands.cs index 4c90c02e94..c879ac74a0 100644 --- a/src/Microsoft.PowerShell.Security/security/CmsCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/CmsCommands.cs @@ -43,7 +43,7 @@ namespace Microsoft.PowerShell.Commands set; } - private PSDataCollection _inputObjects = new PSDataCollection(); + private readonly PSDataCollection _inputObjects = new PSDataCollection(); /// /// Gets or sets the content of the CMS Message by path. @@ -206,7 +206,7 @@ namespace Microsoft.PowerShell.Commands set; } - private StringBuilder _contentBuffer = new StringBuilder(); + private readonly StringBuilder _contentBuffer = new StringBuilder(); /// /// Gets or sets the CMS Message by path. @@ -351,7 +351,7 @@ namespace Microsoft.PowerShell.Commands set; } - private StringBuilder _contentBuffer = new StringBuilder(); + private readonly StringBuilder _contentBuffer = new StringBuilder(); /// /// Gets or sets the Windows Event Log Message with contents to be decrypted. diff --git a/src/Microsoft.PowerShell.Security/security/SecureStringCommands.cs b/src/Microsoft.PowerShell.Security/security/SecureStringCommands.cs index 74dee890cd..5f7c819fc5 100644 --- a/src/Microsoft.PowerShell.Security/security/SecureStringCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/SecureStringCommands.cs @@ -35,7 +35,7 @@ namespace Microsoft.PowerShell.Commands // // name of this command // - private string _commandName; + private readonly string _commandName; /// /// Initializes a new instance of the SecureStringCommandBase diff --git a/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs b/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs index 91a3e8e3a8..3fa7c054a2 100644 --- a/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs @@ -124,7 +124,7 @@ namespace Microsoft.PowerShell.Commands // // name of this command // - private string _commandName; + private readonly string _commandName; /// /// Initializes a new instance of the SignatureCommandsBase class,