Skip to content

Commit 9524bb5

Browse files
authored
Fix StyleCop rule SA1129 ("Do not use default value type constructor") (dotnet/corefx#42531)
Commit migrated from dotnet/corefx@88f40ad
1 parent 18d611f commit 9524bb5

238 files changed

Lines changed: 428 additions & 433 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/libraries/Common/src/Interop/FreeBSD/Interop.Process.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public static unsafe ProcessInfo GetProcessInfoById(int pid)
396396
/// </returns>
397397
public static unsafe proc_stats GetThreadInfo(int pid, int tid)
398398
{
399-
proc_stats ret = new proc_stats();
399+
proc_stats ret = default;
400400
kinfo_proc* info = null;
401401
int count;
402402

src/libraries/Common/src/Interop/OSX/Interop.libproc.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ internal static unsafe rusage_info_v3 proc_pid_rusage(int pid)
473473
throw new ArgumentOutOfRangeException(nameof(pid), SR.NegativePidNotSupported);
474474
}
475475

476-
rusage_info_v3 info = new rusage_info_v3();
476+
rusage_info_v3 info = default;
477477

478478
// Get the PIDs rusage info
479479
int result = proc_pid_rusage(pid, RUSAGE_INFO_V3, &info);

src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ internal static ECParameters GetECKeyParameters(
113113
SafeBignumHandle qx_bn, qy_bn, d_bn;
114114
IntPtr d_bn_not_owned;
115115
int qx_cb, qy_cb, d_cb;
116-
ECParameters parameters = new ECParameters();
116+
ECParameters parameters = default;
117117

118118
bool refAdded = false;
119119
try
@@ -254,7 +254,7 @@ internal static ECParameters GetECCurveParameters(
254254
int cbSubgroupOrder = GetMax(order_cb, d_cb);
255255

256256
// Copy values to ECParameters
257-
ECParameters parameters = new ECParameters();
257+
ECParameters parameters = default;
258258
parameters.Q = new ECPoint
259259
{
260260
X = Crypto.ExtractBignum(qx_bn, cbFieldLength),

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal static unsafe uint LsaOpenPolicy(
2424
int AccessMask,
2525
out SafeLsaPolicyHandle PolicyHandle)
2626
{
27-
var systemNameUnicode = new UNICODE_STRING();
27+
UNICODE_STRING systemNameUnicode = default;
2828
if (SystemName != null)
2929
{
3030
fixed (char* c = SystemName)

src/libraries/Common/src/Interop/Windows/BCrypt/Interop.Blobs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ internal unsafe struct BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
302302

303303
public static BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO Create()
304304
{
305-
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO ret = new BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO();
305+
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO ret = default;
306306

307307
ret.cbSize = sizeof(BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO);
308308

src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private static byte[] DeriveKeyMaterial(
4949
Span<NCryptBuffer> parameters = stackalloc NCryptBuffer[4];
5050
int parameterCount = 0;
5151
// We always need to marshal the hashing function
52-
NCryptBuffer hashAlgorithmBuffer = new NCryptBuffer();
52+
NCryptBuffer hashAlgorithmBuffer = default;
5353
hashAlgorithmBuffer.cbBuffer = (hashAlgorithm.Length + 1) * sizeof(char);
5454
hashAlgorithmBuffer.BufferType = BufferType.KdfHashAlgorithm;
5555
hashAlgorithmBuffer.pvBuffer = hashAlgorithmString;
@@ -67,7 +67,7 @@ private static byte[] DeriveKeyMaterial(
6767

6868
if (pHmacKey != null)
6969
{
70-
NCryptBuffer hmacKeyBuffer = new NCryptBuffer();
70+
NCryptBuffer hmacKeyBuffer = default;
7171
hmacKeyBuffer.cbBuffer = hmacKey.Length;
7272
hmacKeyBuffer.BufferType = BufferType.KdfHmacKey;
7373
hmacKeyBuffer.pvBuffer = new IntPtr(pHmacKey);
@@ -78,7 +78,7 @@ private static byte[] DeriveKeyMaterial(
7878

7979
if (pSecretPrepend != null)
8080
{
81-
NCryptBuffer secretPrependBuffer = new NCryptBuffer();
81+
NCryptBuffer secretPrependBuffer = default;
8282
secretPrependBuffer.cbBuffer = secretPrepend.Length;
8383
secretPrependBuffer.BufferType = BufferType.KdfSecretPrepend;
8484
secretPrependBuffer.pvBuffer = new IntPtr(pSecretPrepend);
@@ -89,7 +89,7 @@ private static byte[] DeriveKeyMaterial(
8989

9090
if (pSecretAppend != null)
9191
{
92-
NCryptBuffer secretAppendBuffer = new NCryptBuffer();
92+
NCryptBuffer secretAppendBuffer = default;
9393
secretAppendBuffer.cbBuffer = secretAppend.Length;
9494
secretAppendBuffer.BufferType = BufferType.KdfSecretAppend;
9595
secretAppendBuffer.pvBuffer = new IntPtr(pSecretAppend);
@@ -126,7 +126,7 @@ private static unsafe byte[] DeriveKeyMaterial(
126126
{
127127
fixed (NCryptBuffer* pParameters = &MemoryMarshal.GetReference(parameters))
128128
{
129-
NCryptBufferDesc parameterDesc = new NCryptBufferDesc();
129+
NCryptBufferDesc parameterDesc = default;
130130
parameterDesc.ulVersion = 0;
131131
parameterDesc.cBuffers = parameters.Length;
132132
parameterDesc.pBuffers = new IntPtr(pParameters);
@@ -225,13 +225,13 @@ internal static byte[] DeriveKeyMaterialTls(
225225
{
226226
fixed (byte* pLabel = label, pSeed = seed)
227227
{
228-
NCryptBuffer labelBuffer = new NCryptBuffer();
228+
NCryptBuffer labelBuffer = default;
229229
labelBuffer.cbBuffer = label.Length;
230230
labelBuffer.BufferType = BufferType.KdfTlsLabel;
231231
labelBuffer.pvBuffer = new IntPtr(pLabel);
232232
buffers[0] = labelBuffer;
233233

234-
NCryptBuffer seedBuffer = new NCryptBuffer();
234+
NCryptBuffer seedBuffer = default;
235235
seedBuffer.cbBuffer = seed.Length;
236236
seedBuffer.BufferType = BufferType.KdfTlsSeed;
237237
seedBuffer.pvBuffer = new IntPtr(pSeed);

src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal partial class NtDll
1313

1414
internal static unsafe int RtlGetVersionEx(out RTL_OSVERSIONINFOEX osvi)
1515
{
16-
osvi = new RTL_OSVERSIONINFOEX();
16+
osvi = default;
1717
osvi.dwOSVersionInfoSize = (uint)sizeof(RTL_OSVERSIONINFOEX);
1818
return RtlGetVersion(ref osvi);
1919
}

src/libraries/Common/src/Interop/Windows/SChannel/Interop.Sec_Application_Protocols.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static unsafe byte[] ToByteArray(List<SslApplicationProtocol> application
3737
}
3838
}
3939

40-
Sec_Application_Protocols protocols = new Sec_Application_Protocols();
40+
Sec_Application_Protocols protocols = default;
4141

4242
int protocolListConstSize = sizeof(Sec_Application_Protocols) - sizeof(uint) /* offsetof(Sec_Application_Protocols, ProtocolExtensionType) */;
4343
protocols.ProtocolListsSize = (uint)(protocolListConstSize + protocolListSize);

src/libraries/Common/src/Interop/Windows/SspiCli/SSPISecureChannelType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public unsafe int QueryContextChannelBinding(SafeDeleteContext phContext, Intero
9999
refHandle = SafeFreeContextBufferChannelBinding.CreateEmptyHandle();
100100

101101
// Bindings is on the stack, so there's no need for a fixed block.
102-
SecPkgContext_Bindings bindings = new SecPkgContext_Bindings();
102+
SecPkgContext_Bindings bindings = default;
103103
return SafeFreeContextBufferChannelBinding.QueryContextChannelBinding(phContext, attribute, &bindings, refHandle);
104104
}
105105

src/libraries/Common/src/Interop/Windows/SspiCli/SafeDeleteContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal abstract partial class SafeDeleteContext : SafeHandle
2929

3030
protected SafeDeleteContext() : base(IntPtr.Zero, true)
3131
{
32-
_handle = new Interop.SspiCli.CredHandle();
32+
_handle = default;
3333
}
3434

3535
public override bool IsInvalid

0 commit comments

Comments
 (0)