diff --git a/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs b/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs
index 49cc830e00e82..dad796280e71a 100644
--- a/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs
+++ b/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs
@@ -115,7 +115,7 @@ internal enum Error
// Represents a platform-agnostic Error and underlying platform-specific errno
internal struct ErrorInfo
{
- private Error _error;
+ private readonly Error _error;
private int _rawErrno;
internal ErrorInfo(int errno)
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs
index 764bdaf85afee..0b9e2c283f0f8 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs
@@ -5,7 +5,6 @@
using System;
using System.Globalization;
using System.Runtime.InteropServices;
-using System.Text;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Casing.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Casing.cs
index 503a864d693c6..499f9445d89ce 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Casing.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Casing.cs
@@ -2,10 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
-using System.Security;
-using System.Text;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Collation.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Collation.cs
index 7d0175473d794..a59292e0fca1d 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Collation.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Collation.cs
@@ -5,7 +5,6 @@
using System;
using System.Globalization;
using System.Runtime.InteropServices;
-using System.Security;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.ICU.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.ICU.cs
index f24c2607848b9..0dce072958a7f 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.ICU.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.ICU.cs
@@ -2,9 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Idna.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Idna.cs
index 89b6c3cebec0a..e9014da1e5d9e 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Idna.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Idna.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Locale.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Locale.cs
index d9a300fd156dc..a6517185ce063 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Locale.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Locale.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs
index d442da0ea137f..09307d22545f6 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Normalization.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
using System.Text;
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs
index df488b6ffa1c4..f60b81f0da8cf 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
-using System.Text;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Utils.cs b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Utils.cs
index 627ab56c9187c..11534cbdee756 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Utils.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Utils.cs
@@ -3,9 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Diagnostics;
using System.Buffers;
-using System.Text;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs
index a723f572a5b0a..b9750fa108330 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Access.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs
index 3c66995182aca..8979d10f4cd8c 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs
index a630a3e82c34a..509fef8272df2 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs
index 8b525fa327294..c964dec144e1b 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs
index 02d259db7d18c..b93f0895360e0 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs
index 28b2309d03ec9..5a9a23f87e06f 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPwUid.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs
index 858506935aef3..fcc9b8db944a5 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Diagnostics;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs
index 1deb9a4313208..5f92357e8f81e 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs
index 134dcb920375f..21479bca65cc9 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Collections.Generic;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs
index 7213cb02640ff..e2c127772020b 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.cs
index 233feabdbb695..e37a2ae6c1d7e 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Read.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
-using Microsoft.Win32.SafeHandles;
internal static partial class Interop
{
diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.cs
index fb06d463beb76..c80f1041fd962 100644
--- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.cs
+++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Write.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
-using Microsoft.Win32.SafeHandles;
internal static partial class Interop
{
diff --git a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs
index ad9e3eaba0c52..4a3b2cee46560 100644
--- a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs
@@ -5,7 +5,6 @@
using System;
using System.Diagnostics;
using System.IO;
-using System.Runtime.InteropServices;
namespace Microsoft.Win32.SafeHandles
{
diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ISet.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ISet.cs
index 657adf787afa4..ce71acba6258b 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ISet.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ISet.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Runtime.CompilerServices;
-
namespace System.Collections.Generic
{
///
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.Unix.cs
index 9259c4fbe66ce..55dcaffa0ea3b 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.Unix.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.Win32.SafeHandles;
-
namespace System.Diagnostics
{
public partial class DebugProvider
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.cs
index 88c1434b0cce3..308c19ada6281 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.cs
@@ -1,8 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+
using System.Collections.Generic;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSourceHelper.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSourceHelper.Unix.cs
index da952d12b4c8a..7b6e43f9ffb4f 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSourceHelper.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSourceHelper.Unix.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-
namespace System.Diagnostics.Tracing
{
internal static class RuntimeEventSourceHelper
diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs
index 6e699b1f38616..06e35e387f22a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs
@@ -2,9 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics;
using System.Collections;
-using Microsoft.Win32;
namespace System
{
diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.Unix.cs
index 8e7982e9992be..993b23a89fc68 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Environment.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Environment.Unix.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Collections;
-using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@@ -454,8 +452,8 @@ public static long WorkingSet
{
using (currentProcess)
{
- object? result = processType!.GetMethod("get_WorkingSet64")?.Invoke(currentProcess, BindingFlags.DoNotWrapExceptions, null, null, null);
- if (result is long) return (long)result;
+ if (processType!.GetMethod("get_WorkingSet64")?.Invoke(currentProcess, BindingFlags.DoNotWrapExceptions, null, null, null) is long result)
+ return result;
}
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs
index d8ed0072f3779..e62a707684cc0 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
-using System.Security;
using System.Text;
using Internal.Runtime.CompilerServices;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Unix.cs
index a8eb8dfdeb00e..4158890e959e4 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Unix.cs
@@ -5,12 +5,7 @@
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Security;
-using System.Threading;
-
-using Internal.Runtime.CompilerServices;
namespace System.Globalization
{
diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs
index f3c3e5d4a329f..67ad489e47adf 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs
@@ -2,12 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Text;
namespace System.Globalization
{
diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/JapaneseCalendar.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/JapaneseCalendar.Unix.cs
index 0bbebba774284..ed4e20de10447 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Globalization/JapaneseCalendar.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/JapaneseCalendar.Unix.cs
@@ -74,7 +74,7 @@ private static bool GetJapaneseEraStartDate(int era, out DateTime dateTime)
{
Debug.Assert(!GlobalizationMode.Invariant);
- dateTime = default(DateTime);
+ dateTime = default;
int startYear;
int startMonth;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs
index 02e7c5f50b969..ef6cff420b9d2 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs
@@ -3,9 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Text;
namespace System.Globalization
{
diff --git a/src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs
index 5a1364d032d2e..3ee426d23a401 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs
@@ -2,9 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
namespace System
{
public partial struct Guid
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs b/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs
index 61acd65b589d8..6ab6272fed463 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs
@@ -672,7 +672,7 @@ public override Task ReadAsync(byte[] buffer, int offset, int count, Cancel
cancellationToken, bytesFromBuffer, semaphoreLockTask).AsTask();
}
- public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken))
+ public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default)
{
if (cancellationToken.IsCancellationRequested)
{
@@ -837,19 +837,6 @@ private int WriteToBuffer(ReadOnlySpan buffer)
return bytesToWrite;
}
- private void WriteToBuffer(byte[] array, ref int offset, ref int count, out Exception? error)
- {
- try
- {
- error = null;
- WriteToBuffer(array, ref offset, ref count);
- }
- catch (Exception ex)
- {
- error = ex;
- }
- }
-
public override void Write(byte[] array, int offset, int count)
{
if (array == null)
@@ -1074,7 +1061,7 @@ public override Task WriteAsync(byte[] buffer, int offset, int count, Cancellati
return WriteAsync(new ReadOnlyMemory(buffer, offset, count), cancellationToken).AsTask();
}
- public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken))
+ public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default)
{
// Fast path check for cancellation already requested
if (cancellationToken.IsCancellationRequested)
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/DriveInfoInternal.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/DriveInfoInternal.Unix.cs
index 78ef95704fe9b..20e2cf9b9ab41 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/DriveInfoInternal.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/DriveInfoInternal.Unix.cs
@@ -2,9 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics;
-using System.Text;
-
namespace System.IO
{
/// Contains internal volume helpers that are shared between many projects.
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs
index 90351282f6ce5..5f53a5d99579a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-
namespace System.IO
{
[Flags]
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Linux.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Linux.cs
index 873c4eb5599d8..6cc56e6acf00e 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Linux.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Linux.cs
@@ -2,11 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.Win32.SafeHandles;
-using System.Diagnostics;
-using System.Threading;
-using System.Threading.Tasks;
-
namespace System.IO
{
public partial class FileStream : Stream
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs
index 2a8e277c35e63..855397ce0dc2e 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs
@@ -143,7 +143,7 @@ private void InitFromHandle(SafeFileHandle handle, FileAccess access, bool useAs
private static Interop.Sys.OpenFlags PreOpenConfigurationFromOptions(FileMode mode, FileAccess access, FileShare share, FileOptions options)
{
// Translate FileMode. Most of the values map cleanly to one or more options for open.
- Interop.Sys.OpenFlags flags = default(Interop.Sys.OpenFlags);
+ Interop.Sys.OpenFlags flags = default;
switch (mode)
{
default:
@@ -574,7 +574,7 @@ private unsafe int ReadNative(Span buffer)
try
{
Memory memory = thisRef._asyncState.Memory;
- thisRef._asyncState.Memory = default(Memory);
+ thisRef._asyncState.Memory = default;
return thisRef.ReadSpan(memory.Span);
}
finally { thisRef._asyncState.Release(); }
@@ -733,7 +733,7 @@ private ValueTask WriteAsyncInternal(ReadOnlyMemory source, CancellationTo
try
{
ReadOnlyMemory readOnlyMemory = thisRef._asyncState.ReadOnlyMemory;
- thisRef._asyncState.ReadOnlyMemory = default(ReadOnlyMemory);
+ thisRef._asyncState.ReadOnlyMemory = default;
thisRef.WriteSpan(readOnlyMemory.Span);
}
finally { thisRef._asyncState.Release(); }
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs
index 288cc12ec8237..23c35de1d521f 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs
@@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
using System.Text;
namespace System.IO
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/PathInternal.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/PathInternal.Unix.cs
index 4d652b6417f59..77dab304e1566 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/PathInternal.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/PathInternal.Unix.cs
@@ -5,7 +5,6 @@
#nullable enable
using System.Diagnostics;
using System.Text;
-using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;
namespace System.IO
diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs
index e5cd43201d462..c49c02c18dd20 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.cs
@@ -899,7 +899,7 @@ public static Matrix4x4 CreatePerspectiveFieldOfView(float fieldOfView, float as
result.M21 = result.M23 = result.M24 = 0.0f;
result.M31 = result.M32 = 0.0f;
- var negFarRange = float.IsPositiveInfinity(farPlaneDistance) ? -1.0f : farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
+ float negFarRange = float.IsPositiveInfinity(farPlaneDistance) ? -1.0f : farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
result.M33 = negFarRange;
result.M34 = -1.0f;
@@ -936,7 +936,7 @@ public static Matrix4x4 CreatePerspective(float width, float height, float nearP
result.M22 = 2.0f * nearPlaneDistance / height;
result.M21 = result.M23 = result.M24 = 0.0f;
- var negFarRange = float.IsPositiveInfinity(farPlaneDistance) ? -1.0f : farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
+ float negFarRange = float.IsPositiveInfinity(farPlaneDistance) ? -1.0f : farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
result.M33 = negFarRange;
result.M31 = result.M32 = 0.0f;
result.M34 = -1.0f;
@@ -978,7 +978,7 @@ public static Matrix4x4 CreatePerspectiveOffCenter(float left, float right, floa
result.M31 = (left + right) / (right - left);
result.M32 = (top + bottom) / (top - bottom);
- var negFarRange = float.IsPositiveInfinity(farPlaneDistance) ? -1.0f : farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
+ float negFarRange = float.IsPositiveInfinity(farPlaneDistance) ? -1.0f : farPlaneDistance / (nearPlaneDistance - farPlaneDistance);
result.M33 = negFarRange;
result.M34 = -1.0f;
@@ -1761,15 +1761,15 @@ public static unsafe Matrix4x4 Transpose(Matrix4x4 matrix)
{
if (Sse.IsSupported)
{
- var row1 = Sse.LoadVector128(&matrix.M11);
- var row2 = Sse.LoadVector128(&matrix.M21);
- var row3 = Sse.LoadVector128(&matrix.M31);
- var row4 = Sse.LoadVector128(&matrix.M41);
+ Vector128 row1 = Sse.LoadVector128(&matrix.M11);
+ Vector128 row2 = Sse.LoadVector128(&matrix.M21);
+ Vector128 row3 = Sse.LoadVector128(&matrix.M31);
+ Vector128 row4 = Sse.LoadVector128(&matrix.M41);
- var l12 = Sse.UnpackLow(row1, row2);
- var l34 = Sse.UnpackLow(row3, row4);
- var h12 = Sse.UnpackHigh(row1, row2);
- var h34 = Sse.UnpackHigh(row3, row4);
+ Vector128 l12 = Sse.UnpackLow(row1, row2);
+ Vector128 l34 = Sse.UnpackLow(row3, row4);
+ Vector128 h12 = Sse.UnpackHigh(row1, row2);
+ Vector128 h34 = Sse.UnpackHigh(row3, row4);
Sse.Store(&matrix.M11, Sse.MoveLowToHigh(l12, l34));
Sse.Store(&matrix.M21, Sse.MoveHighToLow(l34, l12));
@@ -2016,7 +2016,7 @@ public static unsafe Matrix4x4 Lerp(Matrix4x4 matrix1, Matrix4x4 matrix2, float
{
if (Sse.IsSupported)
{
- var row = Sse.LoadVector128(&value1.M11);
+ Vector128 row = Sse.LoadVector128(&value1.M11);
Sse.Store(&value1.M11,
Sse.Add(Sse.Add(Sse.Multiply(Sse.Shuffle(row, row, 0x00), Sse.LoadVector128(&value2.M11)),
Sse.Multiply(Sse.Shuffle(row, row, 0x55), Sse.LoadVector128(&value2.M21))),
diff --git a/src/libraries/System.Private.CoreLib/src/System/PasteArguments.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/PasteArguments.Unix.cs
index 1a4d92850f890..ccb810a6de860 100644
--- a/src/libraries/System.Private.CoreLib/src/System/PasteArguments.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/PasteArguments.Unix.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
-using System.Runtime.CompilerServices;
using System.Text;
namespace System
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComEventsHelpers.NoCom.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComEventsHelpers.NoCom.cs
index 7b29d6f9ad0e4..422698ce088ab 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComEventsHelpers.NoCom.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComEventsHelpers.NoCom.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Runtime.InteropServices.ComTypes;
-
namespace System.Runtime.InteropServices
{
public static class ComEventsHelper
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.PlatformNotSupported.cs
index 77e8b35baae46..05764b08bac53 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.PlatformNotSupported.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.PlatformNotSupported.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Collections;
namespace System.Runtime.InteropServices
@@ -47,7 +46,7 @@ public IntPtr GetOrCreateComInterfaceForObject(object instance, CreateComInterfa
throw new PlatformNotSupportedException();
}
- protected unsafe abstract ComInterfaceEntry* ComputeVtables(object obj, CreateComInterfaceFlags flags, out int count);
+ protected abstract unsafe ComInterfaceEntry* ComputeVtables(object obj, CreateComInterfaceFlags flags, out int count);
public object GetOrCreateObjectForComInstance(IntPtr externalComObject, CreateObjectFlags flags)
{
@@ -73,4 +72,4 @@ protected static void GetIUnknownImpl(out IntPtr fpQueryInterface, out IntPtr fp
throw new PlatformNotSupportedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs
index 9629fa4286abb..3795a5b451577 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs
@@ -364,7 +364,7 @@ public Assembly LoadFromStream(Stream assembly, Stream? assemblySymbols)
byte[]? arrSymbols = null;
if (assemblySymbols != null)
{
- var iSymbolLength = (int)assemblySymbols.Length;
+ int iSymbolLength = (int)assemblySymbols.Length;
arrSymbols = new byte[iSymbolLength];
assemblySymbols.Read(arrSymbols, 0, iSymbolLength);
diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/CodeAccessSecurityAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/CodeAccessSecurityAttribute.cs
index a816f1d0162a2..1a27b3b39da68 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/CodeAccessSecurityAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/CodeAccessSecurityAttribute.cs
@@ -7,6 +7,6 @@ namespace System.Security.Permissions
[AttributeUsage((AttributeTargets)(109), AllowMultiple = true, Inherited = false)]
public abstract partial class CodeAccessSecurityAttribute : SecurityAttribute
{
- protected CodeAccessSecurityAttribute(SecurityAction action) : base(default(SecurityAction)) { }
+ protected CodeAccessSecurityAttribute(SecurityAction action) : base(default) { }
}
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/SecurityPermissionAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/SecurityPermissionAttribute.cs
index e1e74c4166a00..2ec3057bb91a7 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/SecurityPermissionAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/SecurityPermissionAttribute.cs
@@ -7,7 +7,7 @@ namespace System.Security.Permissions
[AttributeUsage((AttributeTargets)(109), AllowMultiple = true, Inherited = false)]
public sealed partial class SecurityPermissionAttribute : CodeAccessSecurityAttribute
{
- public SecurityPermissionAttribute(SecurityAction action) : base(default(SecurityAction)) { }
+ public SecurityPermissionAttribute(SecurityAction action) : base(default) { }
public bool Assertion { get; set; }
public bool BindingRedirects { get; set; }
public bool ControlAppDomain { get; set; }
diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/Principal/TokenImpersonationLevel.cs b/src/libraries/System.Private.CoreLib/src/System/Security/Principal/TokenImpersonationLevel.cs
index 406342ba268cc..25b0e977e1143 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Security/Principal/TokenImpersonationLevel.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Security/Principal/TokenImpersonationLevel.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-
namespace System.Security.Principal
{
public enum TokenImpersonationLevel
diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/SecureString.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Security/SecureString.Unix.cs
index d3fbd9b2bddc9..ca17a89876c42 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Security/SecureString.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Security/SecureString.Unix.cs
@@ -2,11 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics;
-using System.Runtime;
-using System.Runtime.InteropServices;
-using System.Text;
-
namespace System.Security
{
// SecureString attempts to provide a defense-in-depth solution.
diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs
index 978f3cebb61ad..0b354c3b89d35 100644
--- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Runtime.CompilerServices;
using Internal.Runtime.CompilerServices;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf16Utility.Validation.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf16Utility.Validation.cs
index 8d23f74cfe89b..73bfa603f9252 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf16Utility.Validation.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf16Utility.Validation.cs
@@ -3,9 +3,9 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
+using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
-using System.Runtime.CompilerServices;
using System.Numerics;
#if SYSTEM_PRIVATE_CORELIB
diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs
index a1288394d7045..64f76fec69147 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Buffers;
-using System.Buffers.Binary;
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Validation.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Validation.cs
index 137b6775c8944..2d250e7d0ce71 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Validation.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Validation.cs
@@ -4,8 +4,8 @@
using System.Diagnostics;
using System.Numerics;
-using System.Runtime.Intrinsics.X86;
using System.Runtime.CompilerServices;
+using System.Runtime.Intrinsics.X86;
#if SYSTEM_PRIVATE_CORELIB
using Internal.Runtime.CompilerServices;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.WhiteSpace.CoreLib.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.WhiteSpace.CoreLib.cs
index 373f764efd7d0..cf656bc1dc2d1 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.WhiteSpace.CoreLib.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.WhiteSpace.CoreLib.cs
@@ -7,7 +7,6 @@
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
#if TARGET_64BIT
-using nint = System.Int64;
using nuint = System.UInt64;
#else
using nint = System.Int32;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Windows.cs
index 286ec0310d2ad..fe0c5adecd163 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Windows.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Windows.cs
@@ -27,7 +27,7 @@ private void Create(int maximumSignalCount)
Interop.Kernel32.CreateIoCompletionPort(new IntPtr(-1), IntPtr.Zero, UIntPtr.Zero, maximumSignalCount);
if (_completionPort == IntPtr.Zero)
{
- var error = Marshal.GetLastWin32Error();
+ int error = Marshal.GetLastWin32Error();
var exception = new OutOfMemoryException();
exception.HResult = error;
throw exception;
@@ -46,7 +46,7 @@ public bool WaitCore(int timeoutMs)
{
Debug.Assert(timeoutMs >= -1);
- bool success = Interop.Kernel32.GetQueuedCompletionStatus(_completionPort, out var numberOfBytes, out var completionKey, out var pointerToOverlapped, timeoutMs);
+ bool success = Interop.Kernel32.GetQueuedCompletionStatus(_completionPort, out int numberOfBytes, out UIntPtr completionKey, out IntPtr pointerToOverlapped, timeoutMs);
Debug.Assert(success || (Marshal.GetLastWin32Error() == WaitHandle.WaitTimeout));
return success;
}
@@ -59,7 +59,7 @@ public void ReleaseCore(int count)
{
if (!Interop.Kernel32.PostQueuedCompletionStatus(_completionPort, 1, UIntPtr.Zero, IntPtr.Zero))
{
- var lastError = Marshal.GetLastWin32Error();
+ int lastError = Marshal.GetLastWin32Error();
var exception = new OutOfMemoryException();
exception.HResult = lastError;
throw exception;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.cs
index 62affa80c3075..3cf328d2a40ae 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.cs
@@ -15,8 +15,8 @@ internal sealed partial class LowLevelLifoSemaphore : IDisposable
{
private CacheLineSeparatedCounts _separated;
- private int _maximumSignalCount;
- private int _spinCount;
+ private readonly int _maximumSignalCount;
+ private readonly int _spinCount;
private const int SpinSleep0Threshold = 10;
@@ -287,9 +287,9 @@ public override int GetHashCode()
[StructLayout(LayoutKind.Sequential)]
private struct CacheLineSeparatedCounts
{
- private Internal.PaddingFor32 _pad1;
+ private readonly Internal.PaddingFor32 _pad1;
public Counts _counts;
- private Internal.PaddingFor32 _pad2;
+ private readonly Internal.PaddingFor32 _pad2;
}
}
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.CpuUtilizationReader.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.CpuUtilizationReader.Windows.cs
index ee78997955279..50c841fe9503a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.CpuUtilizationReader.Windows.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.CpuUtilizationReader.Windows.cs
@@ -19,7 +19,7 @@ public int CurrentUtilization
{
get
{
- if (!Interop.Kernel32.GetSystemTimes(out var idleTime, out var kernelTime, out var userTime))
+ if (!Interop.Kernel32.GetSystemTimes(out long idleTime, out long kernelTime, out long userTime))
{
return 0;
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.HillClimbing.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.HillClimbing.cs
index b1eae812b4c80..0fa48e9d870fd 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.HillClimbing.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.HillClimbing.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Globalization;
namespace System.Threading
{
@@ -83,13 +82,13 @@ private struct LogEntry
private double _completionsSinceLastChange;
private int _accumulatedCompletionCount;
private double _accumulatedSampleDurationSeconds;
- private double[] _samples;
- private double[] _threadCounts;
+ private readonly double[] _samples;
+ private readonly double[] _threadCounts;
private int _currentSampleMs;
- private Random _randomIntervalGenerator = new Random();
+ private readonly Random _randomIntervalGenerator = new Random();
- private LogEntry[] _log = new LogEntry[LogCapacity];
+ private readonly LogEntry[] _log = new LogEntry[LogCapacity];
private int _logStart = 0;
private int _logSize = 0;
@@ -197,10 +196,10 @@ private struct LogEntry
//
// Set up defaults for our metrics
//
- Complex threadWaveComponent = default(Complex);
- Complex throughputWaveComponent = default(Complex);
+ Complex threadWaveComponent = default;
+ Complex throughputWaveComponent = default;
double throughputErrorEstimate = 0;
- Complex ratio = default(Complex);
+ Complex ratio = default;
double confidence = 0;
StateOrTransition state = StateOrTransition.Warmup;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WaitThread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WaitThread.cs
index 593429973b0f2..e30253f900b75 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WaitThread.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WaitThread.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Runtime.InteropServices;
namespace System.Threading
{
@@ -13,9 +12,8 @@ internal partial class PortableThreadPool
/// A linked list of s.
///
private WaitThreadNode _waitThreadsHead;
- private WaitThreadNode _waitThreadsTail;
- private LowLevelLock _waitThreadLock = new LowLevelLock();
+ private readonly LowLevelLock _waitThreadLock = new LowLevelLock();
///
/// Register a wait handle on a .
@@ -28,7 +26,7 @@ internal void RegisterWaitHandle(RegisteredWaitHandle handle)
{
if (_waitThreadsHead == null) // Lazily create the first wait thread.
{
- _waitThreadsTail = _waitThreadsHead = new WaitThreadNode
+ _waitThreadsHead = new WaitThreadNode
{
Thread = new WaitThread()
};
@@ -48,7 +46,7 @@ internal void RegisterWaitHandle(RegisteredWaitHandle handle)
} while (current != null);
// If all wait threads are full, create a new one.
- prev.Next = _waitThreadsTail = new WaitThreadNode
+ prev.Next = new WaitThreadNode
{
Thread = new WaitThread()
};
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs
index 3fdf1f65767af..b120265a05336 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Globalization;
-
namespace System.Threading
{
internal partial class PortableThreadPool
@@ -16,7 +14,7 @@ private static class WorkerThread
///
/// Semaphore for controlling how many threads are currently working.
///
- private static LowLevelLifoSemaphore s_semaphore = new LowLevelLifoSemaphore(0, MaxPossibleThreadCount, SemaphoreSpinCount);
+ private static readonly LowLevelLifoSemaphore s_semaphore = new LowLevelLifoSemaphore(0, MaxPossibleThreadCount, SemaphoreSpinCount);
///
/// Maximum number of spins a thread pool worker thread performs before waiting for work
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.cs
index 3529148f53437..25f4349386772 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.cs
@@ -62,7 +62,7 @@ private struct CacheLineSeparated
private readonly ThreadInt64PersistentCounter _completionCounter = new ThreadInt64PersistentCounter();
private int _threadAdjustmentIntervalMs;
- private LowLevelLock _hillClimbingThreadAdjustmentLock = new LowLevelLock();
+ private readonly LowLevelLock _hillClimbingThreadAdjustmentLock = new LowLevelLock();
private volatile int _numRequestedWorkers = 0;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.Unix.cs
index 902fcf2650e1d..35379f1f10283 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.Unix.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Runtime.ConstrainedExecution;
-
namespace System.Threading
{
public sealed partial class Thread
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs
index 85c9e0033e718..f56414a8a7ab1 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
namespace System.Threading
@@ -104,7 +103,7 @@ internal void RestartTimeout(int currentTimeMs)
///
private int _numRequestedCallbacks;
- private LowLevelLock _callbackLock = new LowLevelLock();
+ private readonly LowLevelLock _callbackLock = new LowLevelLock();
///
/// Notes if we need to signal the user's unregister event after all callbacks complete.
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.PlatformNotSupported.cs
index e97b1e9e82b3a..2442d71c4170a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.PlatformNotSupported.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.PlatformNotSupported.cs
@@ -2,11 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.Win32.SafeHandles;
-using System.Diagnostics;
using System.Runtime.InteropServices;
-using System.Threading;
-using System.IO;
namespace System.Threading
{
diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs
index 92d3130a6c764..ec137cdd87a1a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs
@@ -11,8 +11,6 @@
using System.Text;
using System.Threading;
using System.Security;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using Internal.IO;
@@ -175,20 +173,20 @@ public AdjustmentRule[] GetAdjustmentRules()
for (int i = 0; i < _adjustmentRules.Length; i++)
{
- var rule = _adjustmentRules[i];
- var start = rule.DateStart.Kind == DateTimeKind.Utc ?
+ AdjustmentRule? rule = _adjustmentRules[i];
+ DateTime start = rule.DateStart.Kind == DateTimeKind.Utc ?
// At the daylight start we didn't start the daylight saving yet then we convert to Local time
// by adding the _baseUtcOffset to the UTC time
new DateTime(rule.DateStart.Ticks + _baseUtcOffset.Ticks, DateTimeKind.Unspecified) :
rule.DateStart;
- var end = rule.DateEnd.Kind == DateTimeKind.Utc ?
+ DateTime end = rule.DateEnd.Kind == DateTimeKind.Utc ?
// At the daylight saving end, the UTC time is mapped to local time which is already shifted by the daylight delta
// we calculate the local time by adding _baseUtcOffset + DaylightDelta to the UTC time
new DateTime(rule.DateEnd.Ticks + _baseUtcOffset.Ticks + rule.DaylightDelta.Ticks, DateTimeKind.Unspecified) :
rule.DateEnd;
- var startTransition = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, start.Hour, start.Minute, start.Second), start.Month, start.Day);
- var endTransition = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, end.Hour, end.Minute, end.Second), end.Month, end.Day);
+ TransitionTime startTransition = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, start.Hour, start.Minute, start.Second), start.Month, start.Day);
+ TransitionTime endTransition = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, end.Hour, end.Minute, end.Second), end.Month, end.Day);
rules[i] = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(start.Date, end.Date, rule.DaylightDelta, startTransition, endTransition);
}
@@ -938,8 +936,8 @@ internal static TimeSpan GetDateTimeNowUtcOffsetFromUtc(DateTime time, out bool
DateTime.MinValue,
endTransitionDate.AddTicks(-1),
daylightDelta,
- default(TransitionTime),
- default(TransitionTime),
+ default,
+ default,
baseUtcDelta,
noDaylightTransitions: true);
@@ -974,7 +972,7 @@ internal static TimeSpan GetDateTimeNowUtcOffsetFromUtc(DateTime time, out bool
}
else
{
- dstStart = default(TransitionTime);
+ dstStart = default;
}
AdjustmentRule r = AdjustmentRule.CreateAdjustmentRule(
@@ -982,7 +980,7 @@ internal static TimeSpan GetDateTimeNowUtcOffsetFromUtc(DateTime time, out bool
endTransitionDate.AddTicks(-1),
daylightDelta,
dstStart,
- default(TransitionTime),
+ default,
baseUtcDelta,
noDaylightTransitions: true);
@@ -1144,8 +1142,8 @@ private static TZifType TZif_GetEarlyDateTransitionType(TZifType[] transitionTyp
startTransitionDate,
DateTime.MaxValue,
TimeSpan.Zero,
- default(TransitionTime),
- default(TransitionTime),
+ default,
+ default,
baseOffset,
noDaylightTransitions: true);
}
@@ -1359,7 +1357,7 @@ private static bool TZif_ParseMDateRule(ReadOnlySpan dateRule, out int mon
month = 0;
week = 0;
- dayOfWeek = default(DayOfWeek);
+ dayOfWeek = default;
return false;
}
diff --git a/src/mono/netcore/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.Unix.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.Unix.Mono.cs
index 007b126965790..5a0247cd4635d 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.Unix.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.Unix.Mono.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Threading;
using System.Runtime.CompilerServices;
namespace Microsoft.Win32.SafeHandles
diff --git a/src/mono/netcore/System.Private.CoreLib/src/Mono/MonoDomain.cs b/src/mono/netcore/System.Private.CoreLib/src/Mono/MonoDomain.cs
index e74ce9fbe0ef5..ca4d98404c986 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/Mono/MonoDomain.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/Mono/MonoDomain.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Reflection;
using System.Runtime.InteropServices;
namespace Mono
diff --git a/src/mono/netcore/System.Private.CoreLib/src/Mono/RuntimeHandles.cs b/src/mono/netcore/System.Private.CoreLib/src/Mono/RuntimeHandles.cs
index 1d05876ce99a3..7e2afa4972840 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/Mono/RuntimeHandles.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/Mono/RuntimeHandles.cs
@@ -10,7 +10,7 @@ namespace Mono
{
internal unsafe struct RuntimeClassHandle
{
- private RuntimeStructs.MonoClass* value;
+ private readonly RuntimeStructs.MonoClass* value;
internal RuntimeClassHandle(RuntimeStructs.MonoClass* value)
{
@@ -60,14 +60,14 @@ public bool Equals(RuntimeClassHandle handle)
}
[MethodImpl(MethodImplOptions.InternalCall)]
- internal static unsafe extern IntPtr GetTypeFromClass(RuntimeStructs.MonoClass* klass);
+ internal static extern unsafe IntPtr GetTypeFromClass(RuntimeStructs.MonoClass* klass);
internal RuntimeTypeHandle GetTypeHandle() => new RuntimeTypeHandle(GetTypeFromClass(value));
}
internal unsafe struct RuntimeRemoteClassHandle
{
- private RuntimeStructs.RemoteClass* value;
+ private readonly RuntimeStructs.RemoteClass* value;
internal RuntimeRemoteClassHandle(RuntimeStructs.RemoteClass* value)
{
@@ -85,7 +85,7 @@ internal RuntimeClassHandle ProxyClass
internal unsafe struct RuntimeGenericParamInfoHandle
{
- private RuntimeStructs.GenericParamInfo* value;
+ private readonly RuntimeStructs.GenericParamInfo* value;
internal RuntimeGenericParamInfoHandle(RuntimeStructs.GenericParamInfo* value)
{
@@ -128,7 +128,7 @@ private int GetConstraintsCount()
internal struct RuntimeEventHandle
{
- private IntPtr value;
+ private readonly IntPtr value;
internal RuntimeEventHandle(IntPtr v)
{
@@ -168,7 +168,7 @@ public override int GetHashCode()
internal struct RuntimePropertyHandle
{
- private IntPtr value;
+ private readonly IntPtr value;
internal RuntimePropertyHandle(IntPtr v)
{
diff --git a/src/mono/netcore/System.Private.CoreLib/src/Mono/SafeGPtrArrayHandle.cs b/src/mono/netcore/System.Private.CoreLib/src/Mono/SafeGPtrArrayHandle.cs
index 2f8a550049284..a0c394dab8568 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/Mono/SafeGPtrArrayHandle.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/Mono/SafeGPtrArrayHandle.cs
@@ -10,7 +10,6 @@
//
using System;
-using System.Runtime.CompilerServices;
namespace Mono
{
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs
index bfbed4dd48925..f6c23ac0cbe69 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Array.Mono.cs
@@ -3,12 +3,10 @@
// See the LICENSE file in the project root for more information.
using Internal.Runtime.CompilerServices;
-using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using Mono;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
#if TARGET_64BIT
@@ -143,7 +141,7 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
Type src_type = sourceArray.GetType().GetElementType()!;
Type dst_type = destinationArray.GetType().GetElementType()!;
- var dst_type_vt = dst_type.IsValueType && Nullable.GetUnderlyingType(dst_type) == null;
+ bool dst_type_vt = dst_type.IsValueType && Nullable.GetUnderlyingType(dst_type) == null;
bool src_is_enum = src_type.IsEnum;
bool dst_is_enum = dst_type.IsEnum;
@@ -381,7 +379,7 @@ public object GetValue(int index)
if (Rank != 1)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray);
- var lb = GetLowerBound(0);
+ int lb = GetLowerBound(0);
if (index < lb || index > GetUpperBound(0))
throw new IndexOutOfRangeException("Index has to be between upper and lower bound of the array.");
@@ -428,7 +426,7 @@ public void SetValue(object? value, int index)
if (Rank != 1)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray);
- var lb = GetLowerBound(0);
+ int lb = GetLowerBound(0);
if (index < lb || index > GetUpperBound(0))
throw new IndexOutOfRangeException("Index has to be >= lower bound and <= upper bound of the array.");
@@ -524,14 +522,14 @@ public int GetUpperBound(int dimension)
[Intrinsic]
private void GetGenericValueImpl(int pos, out T value)
{
- var self = this;
+ Array self = this;
GetGenericValue_icall(ref self, pos, out value);
}
[Intrinsic]
private void SetGenericValueImpl(int pos, ref T value)
{
- var self = this;
+ Array self = this;
SetGenericValue_icall(ref self, pos, ref value);
}
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Attribute.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Attribute.Mono.cs
index 4fe6b1181ac10..bf2177509d96c 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Attribute.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Attribute.Mono.cs
@@ -16,7 +16,7 @@ public partial class Attribute
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute) && attributeType != typeof(CustomAttribute))
throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass + " " + attributeType.FullName);
- var attrs = CustomAttribute.GetCustomAttributes(element, attributeType, inherit);
+ object[] attrs = CustomAttribute.GetCustomAttributes(element, attributeType, inherit);
if (attrs == null || attrs.Length == 0)
return null;
if (attrs.Length != 1)
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Delegate.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Delegate.Mono.cs
index 13500a5594d99..596c2c77ca8d3 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Delegate.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Delegate.Mono.cs
@@ -32,7 +32,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
namespace System
{
@@ -436,7 +435,7 @@ private static bool IsArgumentTypeMatchWithThis(Type delArgType, Type argType, b
#nullable restore
}
- var target = _target;
+ object? target = _target;
if (data is null)
data = CreateDelegateData();
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs
index 74e401f1a943b..48e7376c046c7 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs
@@ -31,7 +31,7 @@ private void BuildStackFrame(int skipFrames, bool needFileInfo)
{
const int SystemDiagnosticsStackDepth = 3;
- if (skipFrames + SystemDiagnosticsStackDepth < 0 || !get_frame_info(skipFrames + SystemDiagnosticsStackDepth, needFileInfo, out var method, out var ilOffset, out var nativeOffset, out var fileName, out var line, out var column))
+ if (skipFrames + SystemDiagnosticsStackDepth < 0 || !get_frame_info(skipFrames + SystemDiagnosticsStackDepth, needFileInfo, out MethodBase? method, out int ilOffset, out int nativeOffset, out string? fileName, out int line, out int column))
return;
_method = method;
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/StackTrace.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/StackTrace.Mono.cs
index 79e8b48270de4..6b9be66ec6cf6 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/StackTrace.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/StackTrace.Mono.cs
@@ -60,7 +60,7 @@ private void InitializeForCurrentThread(int skipFrames, bool needFileInfo)
private void InitializeForException(Exception e, int skipFrames, bool needFileInfo)
{
- var frames = get_trace(e, skipFrames, needFileInfo);
+ MonoStackFrame[] frames = get_trace(e, skipFrames, needFileInfo);
_numOfFrames = frames.Length;
int foreignFrames;
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.Mono.cs
index de832fa5d0447..1d1d02fb042ba 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.Mono.cs
@@ -1,8 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
#if FEATURE_PERFTRACING
@@ -13,7 +13,7 @@ internal static partial class EventPipeInternal
// These ICalls are used by the configuration APIs to interact with EventPipe.
//
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static unsafe extern ulong Enable(char* outputFile, EventPipeSerializationFormat format, uint circularBufferSizeInMB, EventPipeProviderConfigurationNative* providers, uint numProviders);
+ private static extern unsafe ulong Enable(char* outputFile, EventPipeSerializationFormat format, uint circularBufferSizeInMB, EventPipeProviderConfigurationNative* providers, uint numProviders);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void Disable(ulong sessionID);
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Enum.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Enum.Mono.cs
index 88bb891eb2662..0c7da0c2ccc68 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Enum.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Enum.Mono.cs
@@ -95,11 +95,11 @@ internal static string[] InternalGetNames(RuntimeType enumType)
private static EnumInfo GetEnumInfo(RuntimeType enumType, bool getNames = true)
{
- var entry = enumType.Cache.EnumInfo;
+ EnumInfo? entry = enumType.Cache.EnumInfo;
if (entry == null || (getNames && entry.Names == null))
{
- if (!GetEnumValuesAndNames(enumType, out var values, out var names))
+ if (!GetEnumValuesAndNames(enumType, out ulong[]? values, out string[]? names))
Array.Sort(values, names, Collections.Generic.Comparer.Default);
bool hasFlagsAttribute = enumType.IsDefined(typeof(FlagsAttribute), inherit: false);
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Environment.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Environment.Mono.cs
index 9a18526a9ad6d..86a5b14b8ab6c 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Environment.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Environment.Mono.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Collections;
using System.Globalization;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/GC.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/GC.Mono.cs
index dd0a348821261..1276b759bf809 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/GC.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/GC.Mono.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Runtime.CompilerServices;
-using System.Diagnostics;
namespace System
{
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs
index 706c3a92a3372..911499ea842e3 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Runtime.CompilerServices;
namespace System.Globalization
{
@@ -11,7 +10,7 @@ internal static partial class GlobalizationMode
private static bool GetInvariantSwitchValue()
{
- var val = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT");
+ string? val = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT");
if (val != null)
return bool.IsTrueStringIgnoreCase(val) || val.Equals("1");
return false;
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/IO/MonoIOError.cs b/src/mono/netcore/System.Private.CoreLib/src/System/IO/MonoIOError.cs
index 6f27c713ddf6e..0bf59a99146bd 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/IO/MonoIOError.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/IO/MonoIOError.cs
@@ -30,8 +30,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-
namespace System.IO
{
internal enum MonoIOError : int
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/ModuleHandle.cs b/src/mono/netcore/System.Private.CoreLib/src/System/ModuleHandle.cs
index 2ef76dbdbc79f..f3b741f866736 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/ModuleHandle.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/ModuleHandle.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Reflection;
-using System.Runtime.CompilerServices;
namespace System
{
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/mono/netcore/System.Private.CoreLib/src/System/MulticastDelegate.cs
index 553ee17c1a70f..da9981a4cc43e 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/MulticastDelegate.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/MulticastDelegate.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
@@ -212,7 +211,7 @@ protected sealed override Delegate RemoveImpl(Delegate value)
}
else if (delegates == null)
{
- foreach (var d in other.delegates)
+ foreach (Delegate? d in other.delegates)
{
if (this.Equals(d))
return null;
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Assembly.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Assembly.Mono.cs
index 97ca9ad6e6697..36545f49626cb 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Assembly.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Assembly.Mono.cs
@@ -82,7 +82,7 @@ public static Assembly Load(AssemblyName assemblyRef)
internal static Assembly Load(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext assemblyLoadContext)
{
// TODO: pass AssemblyName
- var assembly = InternalLoad(assemblyRef.FullName, ref stackMark, assemblyLoadContext != null ? assemblyLoadContext.NativeALC : IntPtr.Zero);
+ Assembly? assembly = InternalLoad(assemblyRef.FullName, ref stackMark, assemblyLoadContext != null ? assemblyLoadContext.NativeALC : IntPtr.Zero);
if (assembly == null)
throw new FileNotFoundException(null, assemblyRef.Name);
return assembly;
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/AssemblyName.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/AssemblyName.Mono.cs
index 718a1e2436d9e..2291184c4ebf9 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/AssemblyName.Mono.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/AssemblyName.Mono.cs
@@ -21,10 +21,10 @@ public AssemblyName(string assemblyName)
if (assemblyName.Length == 0 || assemblyName[0] == '\0')
throw new ArgumentException(SR.Format_StringZeroLength);
- using (var name = RuntimeMarshal.MarshalString(assemblyName))
+ using (SafeStringMarshal name = RuntimeMarshal.MarshalString(assemblyName))
{
// TODO: Should use CoreRT AssemblyNameParser
- if (!ParseAssemblyName(name.Value, out var nativeName, out var isVersionDefined, out var isTokenDefined))
+ if (!ParseAssemblyName(name.Value, out MonoAssemblyName nativeName, out bool isVersionDefined, out bool isTokenDefined))
throw new FileLoadException("The assembly name is invalid.");
try
@@ -78,8 +78,8 @@ internal unsafe void FillName(MonoAssemblyName* native, string codeBase, bool ad
if (addVersion)
{
- var build = native->build == 65535 ? -1 : native->build;
- var revision = native->revision == 65535 ? -1 : native->revision;
+ int build = native->build == 65535 ? -1 : native->build;
+ int revision = native->revision == 65535 ? -1 : native->revision;
if (build == -1)
_version = new Version(native->major, native->minor);
@@ -126,7 +126,7 @@ private static AssemblyName GetFileInformationCore(string assemblyFile)
{
unsafe
{
- Assembly.InternalGetAssemblyName(Path.GetFullPath(assemblyFile), out var nativeName, out var codebase);
+ Assembly.InternalGetAssemblyName(Path.GetFullPath(assemblyFile), out MonoAssemblyName nativeName, out string? codebase);
var aname = new AssemblyName();
try
diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs
index cc141613b5e11..1e3882d8ed445 100644
--- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs
+++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs
@@ -23,9 +23,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-using System.Reflection;
-using System.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -85,7 +82,7 @@ internal static object[] GetPseudoCustomAttributes(ICustomAttributeProvider obj,
private static object[] GetPseudoCustomAttributes(Type type)
{
int count = 0;
- var Attributes = type.Attributes;
+ TypeAttributes Attributes = type.Attributes;
/* IsSerializable returns true for delegates/enums as well */
if ((Attributes & TypeAttributes.Serializable) != 0)
@@ -192,7 +189,7 @@ internal static object[] GetCustomAttributes(ICustomAttributeProvider obj, Type
inherit = false;
}
- var initialSize = Math.Max(res.Length, 16);
+ int initialSize = Math.Max(res.Length, 16);
List