Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c3e5d2a

Browse files
committed
Remove unnecessary usage of 'this'
Per feedback on the original PR and on my previous commits in this PR.
1 parent a3c0e95 commit c3e5d2a

16 files changed

+62
-62
lines changed

src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.PrivateKey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public AsymmetricAlgorithm PrivateKey
4141
// We never want to stomp over certificate private keys.
4242
cspParameters.Flags |= CspProviderFlags.UseExistingKey;
4343

44-
int algId = OidInfo.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_OID_KEY, this.KeyAlgorithm, OidGroup.PublicKeyAlgorithm, fallBackToAllGroups: true).AlgId;
44+
int algId = OidInfo.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_OID_KEY, KeyAlgorithm, OidGroup.PublicKeyAlgorithm, fallBackToAllGroups: true).AlgId;
4545
switch (algId)
4646
{
4747
case AlgId.CALG_RSA_KEYX:

src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public void AppendPrivateKeyInfo(StringBuilder sb)
396396
CspKeyContainerInfo cspKeyContainerInfo = null;
397397
try
398398
{
399-
if (this.HasPrivateKey)
399+
if (HasPrivateKey)
400400
{
401401
CspParameters parameters = GetPrivateKey();
402402
cspKeyContainerInfo = new CspKeyContainerInfo(parameters);

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/PublicKey.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public sealed class PublicKey
1818
public PublicKey(Oid oid, AsnEncodedData parameters, AsnEncodedData keyValue)
1919
{
2020
_oid = new Oid(oid);
21-
this.EncodedParameters = new AsnEncodedData(parameters);
22-
this.EncodedKeyValue = new AsnEncodedData(keyValue);
21+
EncodedParameters = new AsnEncodedData(parameters);
22+
EncodedKeyValue = new AsnEncodedData(keyValue);
2323
return;
2424
}
2525

@@ -33,7 +33,7 @@ public AsymmetricAlgorithm Key
3333
{
3434
AsymmetricAlgorithm key = _lazyKey;
3535
if (key == null)
36-
key = _lazyKey = X509Pal.Instance.DecodePublicKey(this.Oid, this.EncodedKeyValue.RawData, this.EncodedParameters.RawData);
36+
key = _lazyKey = X509Pal.Instance.DecodePublicKey(Oid, EncodedKeyValue.RawData, EncodedParameters.RawData);
3737
return key;
3838
}
3939
}

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X500DistinguishedName.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public String Name
5858
public String Decode(X500DistinguishedNameFlags flag)
5959
{
6060
ThrowIfInvalid(flag);
61-
return X509Pal.Instance.X500DistinguishedNameDecode(this.RawData, flag);
61+
return X509Pal.Instance.X500DistinguishedNameDecode(RawData, flag);
6262
}
6363

6464
public override String Format(bool multiLine)
6565
{
66-
return X509Pal.Instance.X500DistinguishedNameFormat(this.RawData, multiLine);
66+
return X509Pal.Instance.X500DistinguishedNameFormat(RawData, multiLine);
6767
}
6868

6969
private static byte[] Encode(String distinguishedName, X500DistinguishedNameFlags flags)

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509BasicConstraintsExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ private static byte[] EncodeExtension(bool certificateAuthority, bool hasPathLen
8282
private void DecodeExtension()
8383
{
8484
if (Oid.Value == Oids.BasicConstraints)
85-
X509Pal.Instance.DecodeX509BasicConstraintsExtension(this.RawData, out _certificateAuthority, out _hasPathLenConstraint, out _pathLenConstraint);
85+
X509Pal.Instance.DecodeX509BasicConstraintsExtension(RawData, out _certificateAuthority, out _hasPathLenConstraint, out _pathLenConstraint);
8686
else
87-
X509Pal.Instance.DecodeX509BasicConstraints2Extension(this.RawData, out _certificateAuthority, out _hasPathLenConstraint, out _pathLenConstraint);
87+
X509Pal.Instance.DecodeX509BasicConstraints2Extension(RawData, out _certificateAuthority, out _hasPathLenConstraint, out _pathLenConstraint);
8888

8989
_decoded = true;
9090
}

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,21 @@ public override bool Equals(Object obj)
125125
X509Certificate other = obj as X509Certificate;
126126
if (other == null)
127127
return false;
128-
return this.Equals(other);
128+
return Equals(other);
129129
}
130130

131131
public virtual bool Equals(X509Certificate other)
132132
{
133133
if (other == null)
134134
return false;
135135

136-
if (this.Pal == null)
136+
if (Pal == null)
137137
return other.Pal == null;
138138

139-
if (!this.Issuer.Equals(other.Issuer))
139+
if (!Issuer.Equals(other.Issuer))
140140
return false;
141141

142-
byte[] thisSerialNumber = this.GetSerialNumber();
142+
byte[] thisSerialNumber = GetSerialNumber();
143143
byte[] otherSerialNumber = other.GetSerialNumber();
144144
if (thisSerialNumber.Length != otherSerialNumber.Length)
145145
return false;
@@ -264,19 +264,19 @@ public virtual String ToString(bool fVerbose)
264264
// Subject
265265
sb.AppendLine("[Subject]");
266266
sb.Append(" ");
267-
sb.AppendLine(this.Subject);
267+
sb.AppendLine(Subject);
268268

269269
// Issuer
270270
sb.AppendLine();
271271
sb.AppendLine("[Issuer]");
272272
sb.Append(" ");
273-
sb.AppendLine(this.Issuer);
273+
sb.AppendLine(Issuer);
274274

275275
// Serial Number
276276
sb.AppendLine();
277277
sb.AppendLine("[Serial Number]");
278278
sb.Append(" ");
279-
byte[] serialNumber = this.GetSerialNumber();
279+
byte[] serialNumber = GetSerialNumber();
280280
Array.Reverse(serialNumber);
281281
sb.Append(serialNumber.ToHexArrayUpper());
282282
sb.AppendLine();
@@ -285,19 +285,19 @@ public virtual String ToString(bool fVerbose)
285285
sb.AppendLine();
286286
sb.AppendLine("[Not Before]");
287287
sb.Append(" ");
288-
sb.AppendLine(FormatDate(this.GetNotBefore()));
288+
sb.AppendLine(FormatDate(GetNotBefore()));
289289

290290
// NotAfter
291291
sb.AppendLine();
292292
sb.AppendLine("[Not After]");
293293
sb.Append(" ");
294-
sb.AppendLine(FormatDate(this.GetNotAfter()));
294+
sb.AppendLine(FormatDate(GetNotAfter()));
295295

296296
// Thumbprint
297297
sb.AppendLine();
298298
sb.AppendLine("[Thumbprint]");
299299
sb.Append(" ");
300-
sb.Append(this.GetCertHash().ToHexArrayUpper());
300+
sb.Append(GetCertHash().ToHexArrayUpper());
301301
sb.AppendLine();
302302

303303
return sb.ToString();

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public AsymmetricAlgorithm PrivateKey
157157
{
158158
ThrowIfInvalid();
159159

160-
if (!this.HasPrivateKey)
160+
if (!HasPrivateKey)
161161
return null;
162162

163163
AsymmetricAlgorithm privateKey = _lazyPrivateKey;
@@ -170,7 +170,7 @@ public AsymmetricAlgorithm PrivateKey
170170
{
171171
ThrowIfInvalid();
172172

173-
AsymmetricAlgorithm publicKey = this.PublicKey.Key;
173+
AsymmetricAlgorithm publicKey = PublicKey.Key;
174174
Pal.SetPrivateKey(value, publicKey);
175175
_lazyPrivateKey = value;
176176
}
@@ -185,9 +185,9 @@ public PublicKey PublicKey
185185
PublicKey publicKey = _lazyPublicKey;
186186
if (publicKey == null)
187187
{
188-
String keyAlgorithmOid = this.GetKeyAlgorithm();
189-
byte[] parameters = this.GetKeyAlgorithmParameters();
190-
byte[] keyValue = this.GetPublicKey();
188+
String keyAlgorithmOid = GetKeyAlgorithm();
189+
byte[] parameters = GetKeyAlgorithmParameters();
190+
byte[] keyValue = GetPublicKey();
191191
Oid oid = new Oid(keyAlgorithmOid);
192192
publicKey = _lazyPublicKey = new PublicKey(oid, new AsnEncodedData(oid, parameters), new AsnEncodedData(oid, keyValue));
193193
}
@@ -311,14 +311,14 @@ public override String ToString(bool verbose)
311311
// Version
312312
sb.AppendLine("[Version]");
313313
sb.Append(" V");
314-
sb.Append(this.Version);
314+
sb.Append(Version);
315315

316316
// Subject
317317
sb.AppendLine();
318318
sb.AppendLine();
319319
sb.AppendLine("[Subject]");
320320
sb.Append(" ");
321-
sb.Append(this.SubjectName.Name);
321+
sb.Append(SubjectName.Name);
322322
String simpleName = GetNameInfo(X509NameType.SimpleName, false);
323323
if (simpleName.Length > 0)
324324
{
@@ -357,7 +357,7 @@ public override String ToString(bool verbose)
357357
sb.AppendLine();
358358
sb.AppendLine("[Issuer]");
359359
sb.Append(" ");
360-
sb.Append(this.IssuerName.Name);
360+
sb.Append(IssuerName.Name);
361361
simpleName = GetNameInfo(X509NameType.SimpleName, true);
362362
if (simpleName.Length > 0)
363363
{
@@ -396,33 +396,33 @@ public override String ToString(bool verbose)
396396
sb.AppendLine();
397397
sb.AppendLine("[Serial Number]");
398398
sb.Append(" ");
399-
sb.AppendLine(this.SerialNumber);
399+
sb.AppendLine(SerialNumber);
400400

401401
// NotBefore
402402
sb.AppendLine();
403403
sb.AppendLine("[Not Before]");
404404
sb.Append(" ");
405-
sb.AppendLine(FormatDate(this.NotBefore));
405+
sb.AppendLine(FormatDate(NotBefore));
406406

407407
// NotAfter
408408
sb.AppendLine();
409409
sb.AppendLine("[Not After]");
410410
sb.Append(" ");
411-
sb.AppendLine(FormatDate(this.NotAfter));
411+
sb.AppendLine(FormatDate(NotAfter));
412412

413413
// Thumbprint
414414
sb.AppendLine();
415415
sb.AppendLine("[Thumbprint]");
416416
sb.Append(" ");
417-
sb.AppendLine(this.Thumbprint);
417+
sb.AppendLine(Thumbprint);
418418

419419
// Signature Algorithm
420420
sb.AppendLine();
421421
sb.AppendLine("[Signature Algorithm]");
422422
sb.Append(" ");
423-
sb.Append(this.SignatureAlgorithm.FriendlyName);
423+
sb.Append(SignatureAlgorithm.FriendlyName);
424424
sb.Append('(');
425-
sb.Append(this.SignatureAlgorithm.Value);
425+
sb.Append(SignatureAlgorithm.Value);
426426
sb.AppendLine(")");
427427

428428
// Public Key
@@ -431,7 +431,7 @@ public override String ToString(bool verbose)
431431
// It could throw if it's some user-defined CryptoServiceProvider
432432
try
433433
{
434-
PublicKey pubKey = this.PublicKey;
434+
PublicKey pubKey = PublicKey;
435435

436436
sb.AppendLine();
437437
sb.Append(" ");
@@ -466,7 +466,7 @@ public override String ToString(bool verbose)
466466
Pal.AppendPrivateKeyInfo(sb);
467467

468468
// Extensions
469-
X509ExtensionCollection extensions = this.Extensions;
469+
X509ExtensionCollection extensions = Extensions;
470470
if (extensions.Count > 0)
471471
{
472472
sb.AppendLine();

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2Collection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ public X509Certificate2Collection()
2121

2222
public X509Certificate2Collection(X509Certificate2 certificate)
2323
{
24-
this.Add(certificate);
24+
Add(certificate);
2525
}
2626

2727
public X509Certificate2Collection(X509Certificate2[] certificates)
2828
{
29-
this.AddRange(certificates);
29+
AddRange(certificates);
3030
}
3131

3232
public X509Certificate2Collection(X509Certificate2Collection certificates)
3333
{
34-
this.AddRange(certificates);
34+
AddRange(certificates);
3535
}
3636

3737
public new X509Certificate2 this[int index]

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509CertificateCollection.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public X509CertificateCollection()
2727
public X509CertificateCollection(X509Certificate[] value)
2828
: this()
2929
{
30-
this.AddRange(value);
30+
AddRange(value);
3131
}
3232

3333
public X509CertificateCollection(X509CertificateCollection value)
3434
: this()
3535
{
36-
this.AddRange(value);
36+
AddRange(value);
3737
}
3838

3939
public int Count
@@ -114,7 +114,7 @@ public void AddRange(X509Certificate[] value)
114114

115115
for (int i = 0; i < value.Length; i++)
116116
{
117-
this.Add(value[i]);
117+
Add(value[i]);
118118
}
119119
}
120120

@@ -125,7 +125,7 @@ public void AddRange(X509CertificateCollection value)
125125

126126
for (int i = 0; i < value.Count; i++)
127127
{
128-
this.Add(value[i]);
128+
Add(value[i]);
129129
}
130130
}
131131

src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public bool Build(X509Certificate2 certificate)
7676

7777
Reset();
7878

79-
X509ChainPolicy chainPolicy = this.ChainPolicy;
79+
X509ChainPolicy chainPolicy = ChainPolicy;
8080
_pal = ChainPal.BuildChain(
8181
false,
8282
certificate.Pal,

0 commit comments

Comments
 (0)