From bbb4a8659e73accfebb1b4b617cca04816a2c4e9 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 09:24:23 -0400 Subject: [PATCH 01/11] Use explicit type --- .../src/System/Numerics/Matrix4x4.cs | 24 +++++------ .../Runtime/Loader/AssemblyLoadContext.cs | 2 +- .../LowLevelLifoSemaphore.Windows.cs | 6 +-- ...ThreadPool.CpuUtilizationReader.Windows.cs | 2 +- .../src/System/TimeZoneInfo.Unix.cs | 10 ++--- .../src/System/Array.Mono.cs | 10 ++--- .../src/System/Attribute.Mono.cs | 2 +- .../src/System/Delegate.Mono.cs | 2 +- .../src/System/Diagnostics/StackFrame.Mono.cs | 2 +- .../src/System/Diagnostics/StackTrace.Mono.cs | 2 +- .../src/System/Enum.Mono.cs | 4 +- .../Globalization/GlobalizationMode.Mono.cs | 2 +- .../src/System/MulticastDelegate.cs | 2 +- .../src/System/Reflection/Assembly.Mono.cs | 2 +- .../System/Reflection/AssemblyName.Mono.cs | 10 ++--- .../src/System/Reflection/CustomAttribute.cs | 12 +++--- .../Reflection/Emit/AssemblyBuilder.Mono.cs | 6 +-- .../Emit/ConstructorBuilder.Mono.cs | 4 +- .../Emit/ConstructorOnTypeBuilderInst.cs | 2 +- .../Emit/CustomAttributeBuilder.Mono.cs | 2 +- .../Reflection/Emit/FieldOnTypeBuilderInst.cs | 2 +- .../Reflection/Emit/MethodBuilder.Mono.cs | 6 +-- .../Emit/MethodOnTypeBuilderInst.cs | 4 +- .../Reflection/Emit/ModuleBuilder.Mono.cs | 10 ++--- .../Reflection/Emit/TypeBuilder.Mono.cs | 10 ++--- .../Emit/TypeBuilderInstantiation.cs | 4 +- .../src/System/Reflection/RuntimeAssembly.cs | 4 +- .../System/Reflection/RuntimeMethodInfo.cs | 10 ++--- .../System/Reflection/RuntimePropertyInfo.cs | 2 +- .../Runtime/InteropServices/Marshal.Mono.cs | 4 +- .../src/System/RuntimeMethodHandle.cs | 2 +- .../src/System/RuntimeType.Mono.cs | 40 +++++++++---------- .../src/System/RuntimeTypeHandle.cs | 2 +- .../src/System/Threading/Thread.Mono.cs | 8 ++-- .../src/System/TypeNameParser.cs | 8 ++-- .../src/System/TypeSpec.cs | 12 +++--- .../src/System/ValueType.cs | 2 +- 37 files changed, 119 insertions(+), 119 deletions(-) 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 e5cd43201d4622..c49c02c18dd203 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/Runtime/Loader/AssemblyLoadContext.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs index 9629fa4286abbf..3795a5b4515770 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/Threading/LowLevelLifoSemaphore.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Windows.cs index 286ec0310d2ad0..fe0c5adecd163d 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/PortableThreadPool.CpuUtilizationReader.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.CpuUtilizationReader.Windows.cs index ee789979552792..50c841fe9503af 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/TimeZoneInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs index 92d3130a6c764d..ba7d466b29dcd7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs @@ -175,20 +175,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); } 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 bfbed4dd489258..565e7cbf860a1f 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 @@ -143,7 +143,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 +381,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 +428,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 +524,14 @@ internal ref byte GetRawArrayData() [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 4fe6b1181ac102..bf2177509d96c6 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 13500a5594d998..6f9cd832813340 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 @@ -436,7 +436,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 74e401f1a943b4..48e7376c046c72 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 79e8b48270de4e..9c020f58dcaea7 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/Enum.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Enum.Mono.cs index 88bb891eb26623..0c7da0c2ccc68e 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/Globalization/GlobalizationMode.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs index 706c3a92a3372e..88fcc05e750762 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 @@ -11,7 +11,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/MulticastDelegate.cs b/src/mono/netcore/System.Private.CoreLib/src/System/MulticastDelegate.cs index 553ee17c1a70f1..0d0bdc64866331 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -212,7 +212,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 97ca9ad6e6697f..36545f49626cb0 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 718a1e2436d9e1..2291184c4ebf98 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 cc141613b5e115..c0b5a37a110933 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 @@ -85,7 +85,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 +192,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 a = null; ICustomAttributeProvider btype = obj; object[] array; @@ -362,12 +362,12 @@ internal static IList GetCustomAttributesData(ICustomAttrib // there's no use in scanning base types if ((attributeType != null && attributeType.IsSealed) && inherit) { - var usageAttribute = RetrieveAttributeUsage(attributeType); + AttributeUsageAttribute? usageAttribute = RetrieveAttributeUsage(attributeType); if (!usageAttribute.Inherited) inherit = false; } - var initialSize = Math.Max(res.Count, 16); + int initialSize = Math.Max(res.Count, 16); List a = null; ICustomAttributeProvider btype = obj; @@ -527,7 +527,7 @@ internal static CustomAttributeData[] GetPseudoCustomAttributesData(ICustomAttri private static CustomAttributeData[] GetPseudoCustomAttributesData(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) @@ -661,7 +661,7 @@ private static ICustomAttributeProvider GetBase(ICustomAttributeProvider obj) method = (MethodInfo)obj; if (obj is RuntimeParameterInfo parinfo) { - var member = parinfo.Member; + MemberInfo? member = parinfo.Member; if (member is MethodInfo) { method = (MethodInfo)member; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs index 6fad5aa52ce3e1..88a1727cced3ca 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs @@ -301,10 +301,10 @@ public static AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyB public static AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, IEnumerable assemblyAttributes) { - var ab = DefineDynamicAssembly(name, access); + AssemblyBuilder ab = DefineDynamicAssembly(name, access); if (assemblyAttributes != null) { - foreach (var attr in assemblyAttributes) + foreach (CustomAttributeBuilder attr in assemblyAttributes) ab.SetCustomAttribute(attr); } @@ -497,7 +497,7 @@ public override Type GetType(string name, bool throwOnError, bool ignoreCase) if (name.Length == 0) throw new ArgumentException("Name cannot be empty", nameof(name)); - var res = InternalGetType(null, name, throwOnError, ignoreCase); + Type res = InternalGetType(null, name, throwOnError, ignoreCase); if (res is TypeBuilder) { if (throwOnError) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs index 3d55f212e7e535..6783ab497ea2a8 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs @@ -355,12 +355,12 @@ internal void ResolveUserTypes() TypeBuilder.ResolveUserTypes(parameters); if (paramModReq != null) { - foreach (var types in paramModReq) + foreach (Type[] types in paramModReq) TypeBuilder.ResolveUserTypes(types); } if (paramModOpt != null) { - foreach (var types in paramModOpt) + foreach (Type[] types in paramModOpt) TypeBuilder.ResolveUserTypes(types); } } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs index 1dbccc9b6d7bbe..3c8f4bba66a67d 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs @@ -169,7 +169,7 @@ internal override Type[] GetParameterTypes() // Called from the runtime to return the corresponding finished ConstructorInfo object internal ConstructorInfo RuntimeResolve() { - var type = instantiation.InternalResolve(); + Type type = instantiation.InternalResolve(); return type.GetConstructor(cb); } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs index 6f9c751d1da7bb..762ad36eb534d3 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs @@ -151,7 +151,7 @@ private static bool IsValidValue(Type type, object value) return false; if (type.IsArray && type.GetElementType().IsValueType) { - foreach (var v in (Array)value) + foreach (object v in (Array)value) { if (v == null) return false; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs index ec2a5b580c2097..50b66e0311d1d5 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs @@ -149,7 +149,7 @@ public override void SetValue(object obj, object value, BindingFlags invokeAttr, // Called from the runtime to return the corresponding finished FieldInfo object internal FieldInfo RuntimeResolve() { - var type = instantiation.RuntimeResolve(); + Type type = instantiation.RuntimeResolve(); return type.GetField(fb); } } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs index f9fe0b33632ed0..30045d36c88f22 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs @@ -358,7 +358,7 @@ internal void check_override() { if (override_methods != null) { - foreach (var m in override_methods) + foreach (MethodInfo m in override_methods) { if (m.IsVirtual && !IsVirtual) throw new TypeLoadException(string.Format("Method '{0}' override '{1}' but it is not virtual", name, m)); @@ -388,12 +388,12 @@ internal void ResolveUserTypes() TypeBuilder.ResolveUserTypes(returnModOpt); if (paramModReq != null) { - foreach (var types in paramModReq) + foreach (Type[] types in paramModReq) TypeBuilder.ResolveUserTypes(types); } if (paramModOpt != null) { - foreach (var types in paramModOpt) + foreach (Type[] types in paramModOpt) TypeBuilder.ResolveUserTypes(types); } } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs index ff11c1e69ce5a6..43e0242ce9de72 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs @@ -104,8 +104,8 @@ internal Type[] GetTypeArgs() // Called from the runtime to return the corresponding finished MethodInfo object internal MethodInfo RuntimeResolve() { - var type = instantiation.InternalResolve(); - var m = type.GetMethod(base_method); + Type type = instantiation.InternalResolve(); + MethodInfo m = type.GetMethod(base_method); if (method_arguments != null) { var args = new Type[method_arguments.Length]; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs index 75eb11e19b7f1a..3fbd2a4ee98c12 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs @@ -143,7 +143,7 @@ public FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttribu if (data == null) throw new ArgumentNullException(nameof(data)); - var maskedAttributes = attributes & ~FieldAttributes.ReservedMask; + FieldAttributes maskedAttributes = attributes & ~FieldAttributes.ReservedMask; FieldBuilder fb = DefineDataImpl(name, data.Length, maskedAttributes | FieldAttributes.HasFieldRVA); fb.SetRVAData(data); @@ -426,7 +426,7 @@ public override Type GetType(string className, bool throwOnError, bool ignoreCas if (!ignoreCase) { - var displayNestedName = ts.TypeNameWithoutModifiers(); + ITypeName displayNestedName = ts.TypeNameWithoutModifiers(); name_cache.TryGetValue(displayNestedName, out result); } else @@ -449,7 +449,7 @@ public override Type GetType(string className, bool throwOnError, bool ignoreCas if (tb.is_created) mt = tb.CreateType(); } - foreach (var mod in ts.Modifiers) + foreach (IModifierSpec mod in ts.Modifiers) { if (mod is PointerSpec) mt = mt.MakePointerType(); @@ -487,7 +487,7 @@ internal int get_next_table_index(object obj, int table, int count) table_indexes[0x02] = 2; } // Console.WriteLine ("getindex for table "+table.ToString()+" got "+table_indexes [table].ToString()); - var index = table_indexes[table]; + int index = table_indexes[table]; table_indexes[table] += count; return index; } @@ -647,7 +647,7 @@ internal int GetToken(string str) private int GetPseudoToken(MemberInfo member, bool create_open_instance) { int token; - var dict = create_open_instance ? inst_tokens_open : inst_tokens; + Dictionary dict = create_open_instance ? inst_tokens_open : inst_tokens; if (dict == null) { dict = new Dictionary(ReferenceEqualityComparer.Instance); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs index 573f1619d02283..fe0729e7a9cd27 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs @@ -842,7 +842,7 @@ TypeInfo CreateTypeInfo() throw new TypeLoadException("Could not load type '" + FullName + "' from assembly '" + Assembly + "' because it is an enum with methods."); if (interfaces != null) { - foreach (var iface in interfaces) + foreach (Type iface in interfaces) { if (iface.IsNestedPrivate && iface.Assembly != Assembly) throw new TypeLoadException("Could not load type '" + FullName + "' from assembly '" + Assembly + "' because it is implements the inaccessible interface '" + iface.FullName + "'."); @@ -899,7 +899,7 @@ private void ResolveUserTypes() ResolveUserTypes(interfaces); if (fields != null) { - foreach (var fb in fields) + foreach (FieldBuilder fb in fields) { if (fb != null) fb.ResolveUserTypes(); @@ -907,7 +907,7 @@ private void ResolveUserTypes() } if (methods != null) { - foreach (var mb in methods) + foreach (MethodBuilder mb in methods) { if (mb != null) mb.ResolveUserTypes(); @@ -915,7 +915,7 @@ private void ResolveUserTypes() } if (ctors != null) { - foreach (var cb in ctors) + foreach (ConstructorBuilder cb in ctors) { if (cb != null) cb.ResolveUserTypes(); @@ -1437,7 +1437,7 @@ public void SetCustomAttribute(CustomAttributeBuilder customBuilder) throw new Exception("Error in customattr"); } - var ctor_type = customBuilder.Ctor is ConstructorBuilder ? ((ConstructorBuilder)customBuilder.Ctor).parameters[0] : customBuilder.Ctor.GetParametersInternal()[0].ParameterType; + Type ctor_type = customBuilder.Ctor is ConstructorBuilder ? ((ConstructorBuilder)customBuilder.Ctor).parameters[0] : customBuilder.Ctor.GetParametersInternal()[0].ParameterType; int pos = 6; if (ctor_type.FullName == "System.Int16") pos = 4; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs index a5cc6e15cd565c..543ec4ba6bebe2 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs @@ -88,7 +88,7 @@ internal override Type RuntimeResolve() throw new NotImplementedException(); for (int i = 0; i < type_arguments.Length; ++i) { - var t = type_arguments[i]; + Type t = type_arguments[i]; if (t is TypeBuilder && !(t as TypeBuilder).IsCreated()) throw new NotImplementedException(); } @@ -509,7 +509,7 @@ internal override bool IsUserType { get { - foreach (var t in type_arguments) + foreach (Type t in type_arguments) { if (t.IsUserType) return true; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index 3d1d81df47375a..1f97907499c7dc 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -319,7 +319,7 @@ public override AssemblyName[] GetReferencedAssemblies() { using (var nativeNames = new Mono.SafeGPtrArrayHandle(InternalGetReferencedAssemblies(this))) { - var numAssemblies = nativeNames.Length; + int numAssemblies = nativeNames.Length; try { AssemblyName[] result = new AssemblyName[numAssemblies]; @@ -368,7 +368,7 @@ public override Assembly GetSatelliteAssembly(CultureInfo culture, Version versi [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod internal Assembly InternalGetSatelliteAssembly(CultureInfo culture, Version version, bool throwOnFileNotFound) { - var aname = GetName(); + AssemblyName aname = GetName(); var an = new AssemblyName(); if (version == null) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs index 3bb9184855866c..6372cfcb9dcd79 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs @@ -296,7 +296,7 @@ public override MethodImplAttributes GetMethodImplementationFlags() public override ParameterInfo[] GetParameters() { - var src = MonoMethodInfo.GetParametersInfo(mhandle, this); + ParameterInfo[] src = MonoMethodInfo.GetParametersInfo(mhandle, this); if (src.Length == 0) return src; @@ -404,8 +404,8 @@ internal static void ConvertValues(Binder binder, object[] args, ParameterInfo[] for (int i = 0; i < args.Length; ++i) { - var arg = args[i]; - var pi = pinfo[i]; + object arg = args[i]; + ParameterInfo pi = pinfo[i]; if (arg == Type.Missing) { if (pi.DefaultValue == DBNull.Value) @@ -658,7 +658,7 @@ private CustomAttributeData GetDllImportAttributeData() new CustomAttributeTypedArgument (typeof(string), dllName), }; - var attrType = typeof(DllImportAttribute); + Type attrType = typeof(DllImportAttribute); var namedArgs = new CustomAttributeNamedArgument[] { new CustomAttributeNamedArgument (attrType.GetField ("EntryPoint"), entryPoint), @@ -824,7 +824,7 @@ internal override ParameterInfo[] GetParametersInternal() internal override int GetParametersCount() { - var pi = MonoMethodInfo.GetParametersInfo(mhandle, this); + ParameterInfo[] pi = MonoMethodInfo.GetParametersInfo(mhandle, this); return pi == null ? 0 : pi.Length; } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs index 9eca88b3d7d43f..5d14b5aa0f7e19 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs @@ -154,7 +154,7 @@ private string FormatNameAndSig() sbName.Append(" "); sbName.Append(Name); - var pi = GetIndexParameters(); + ParameterInfo[] pi = GetIndexParameters(); if (pi.Length > 0) { sbName.Append(" ["); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs index 12bf24216cc0b8..11902e0f7fa2b1 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs @@ -317,7 +317,7 @@ private static void PtrToStructureHelper(IntPtr ptr, object structure, bool allo private static object PtrToStructureHelper(IntPtr ptr, Type structureType) { - var obj = Activator.CreateInstance(structureType); + object? obj = Activator.CreateInstance(structureType); PtrToStructureHelper(ptr, obj, true); return obj; } @@ -341,7 +341,7 @@ public static IntPtr GetExceptionPointers() internal static unsafe IntPtr AllocBSTR(int length) { - var res = BufferToBSTR((char*)IntPtr.Zero, length); + IntPtr res = BufferToBSTR((char*)IntPtr.Zero, length); if (res == IntPtr.Zero) throw new OutOfMemoryException(); return res; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs index c1119fcbcdc744..5b4027c831df96 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs @@ -71,7 +71,7 @@ public override int GetHashCode() internal static string ConstructInstantiation(RuntimeMethodInfo method, TypeNameFormatFlags format) { var sb = new StringBuilder(); - var gen_params = method.GetGenericArguments(); + Type[]? gen_params = method.GetGenericArguments(); sb.Append("["); for (int j = 0; j < gen_params.Length; j++) { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs index a7d1bd3fc23e80..7e984d60c3fbd7 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs @@ -601,7 +601,7 @@ private ListBuilder GetMethodCandidates( continue; else if (genericParamCount > 0 && !is_generic) continue; - var args = methodInfo.GetGenericArguments(); + Type[]? args = methodInfo.GetGenericArguments(); if (args.Length != genericParamCount) continue; } @@ -999,7 +999,7 @@ public override Type GetInterface(string fullname, bool ignoreCase) FilterHelper(bindingAttr, ref name, out ignoreCase, out listType); List list = null; - var nameComparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; + StringComparison nameComparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; foreach (RuntimeType t in GetInterfaces()) { @@ -1017,7 +1017,7 @@ public override Type GetInterface(string fullname, bool ignoreCase) if (list == null) return null; - var cache = list.ToArray(); + RuntimeType[]? cache = list.ToArray(); RuntimeType match = null; for (int i = 0; i < cache.Length; i++) @@ -1872,13 +1872,13 @@ internal RuntimeType(object obj) internal RuntimeConstructorInfo GetDefaultConstructor() { - var cache = Cache; + TypeCache? cache = Cache; RuntimeConstructorInfo ctor = null; if (Volatile.Read(ref cache.default_ctor_cached)) return cache.default_ctor; - var ctors = GetConstructorCandidates( + ListBuilder ctors = GetConstructorCandidates( null, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly, CallingConventions.Any, Array.Empty(), false); @@ -1961,7 +1961,7 @@ internal object CreateInstanceSlow(bool publicOnly, bool wrapExceptions, bool sk private object CreateInstanceMono(bool nonPublic, bool wrapExceptions) { - var ctor = GetDefaultConstructor(); + RuntimeConstructorInfo? ctor = GetDefaultConstructor(); if (!nonPublic && ctor != null && !ctor.IsPublic) { throw new MissingMethodException(SR.Format(SR.Arg_NoDefCTor, FullName)); @@ -1991,7 +1991,7 @@ private object CreateInstanceMono(bool nonPublic, bool wrapExceptions) internal object CheckValue(object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr) { bool failed = false; - var res = TryConvertToType(value, ref failed); + object? res = TryConvertToType(value, ref failed); if (!failed) return res; @@ -2013,7 +2013,7 @@ private object TryConvertToType(object value, ref bool failed) if (IsByRef) { - var elementType = GetElementType(); + Type? elementType = GetElementType(); if (value == null || elementType.IsInstanceOfType(value)) { return value; @@ -2025,22 +2025,22 @@ private object TryConvertToType(object value, ref bool failed) if (IsEnum) { - var type = Enum.GetUnderlyingType(this); + Type? type = Enum.GetUnderlyingType(this); if (type == value.GetType()) return value; - var res = IsConvertibleToPrimitiveType(value, this); + object? res = IsConvertibleToPrimitiveType(value, this); if (res != null) return res; } else if (IsPrimitive) { - var res = IsConvertibleToPrimitiveType(value, this); + object? res = IsConvertibleToPrimitiveType(value, this); if (res != null) return res; } else if (IsPointer) { - var vtype = value.GetType(); + Type? vtype = value.GetType(); if (vtype == typeof(IntPtr) || vtype == typeof(UIntPtr)) return value; if (value is Pointer pointer) @@ -2061,7 +2061,7 @@ private object TryConvertToType(object value, ref bool failed) // long value can be used with int based enum private static object IsConvertibleToPrimitiveType(object value, Type targetType) { - var type = value.GetType(); + Type? type = value.GetType(); if (type.IsEnum) { type = Enum.GetUnderlyingType(type); @@ -2069,8 +2069,8 @@ private static object IsConvertibleToPrimitiveType(object value, Type targetType return value; } - var from = GetTypeCode(type); - var to = GetTypeCode(targetType); + TypeCode from = GetTypeCode(type); + TypeCode to = GetTypeCode(targetType); switch (to) { @@ -2302,7 +2302,7 @@ public override Type[] GetGenericParameterConstraints() internal static object CreateInstanceForAnotherGenericParameter(Type genericType, RuntimeType genericArgument) { var gt = (RuntimeType)MakeGenericType(genericType, new Type[] { genericArgument }); - var ctor = gt.GetDefaultConstructor(); + RuntimeConstructorInfo? ctor = gt.GetDefaultConstructor(); return ctor.InternalInvoke(null, null, wrapExceptions: true); } @@ -2318,7 +2318,7 @@ internal RuntimeMethodInfo[] GetMethodsByName(string name, BindingFlags bindingA using (var namePtr = new Mono.SafeStringMarshal(name)) using (var h = new Mono.SafeGPtrArrayHandle(GetMethodsByName_native(namePtr.Value, bindingAttr, listType))) { - var n = h.Length; + int n = h.Length; var a = new RuntimeMethodInfo[n]; for (int i = 0; i < n; i++) { @@ -2340,7 +2340,7 @@ private RuntimeConstructorInfo[] GetConstructors_internal(BindingFlags bindingAt var refh = new RuntimeTypeHandle(reflectedType); using (var h = new Mono.SafeGPtrArrayHandle(GetConstructors_native(bindingAttr))) { - var n = h.Length; + int n = h.Length; var a = new RuntimeConstructorInfo[n]; for (int i = 0; i < n; i++) { @@ -2357,7 +2357,7 @@ private RuntimePropertyInfo[] GetPropertiesByName(string name, BindingFlags bind using (var namePtr = new Mono.SafeStringMarshal(name)) using (var h = new Mono.SafeGPtrArrayHandle(GetPropertiesByName_native(namePtr.Value, bindingAttr, listType))) { - var n = h.Length; + int n = h.Length; var a = new RuntimePropertyInfo[n]; for (int i = 0; i < n; i++) { @@ -2541,7 +2541,7 @@ public override string? FullName return null; string fullName; - var cache = Cache; + TypeCache? cache = Cache; if ((fullName = cache.full_name) == null) fullName = cache.full_name = getFullName(true, false); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs index 11d957c040e92c..507a42854ffb66 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs @@ -314,7 +314,7 @@ internal static RuntimeType GetTypeByName(string typeName, bool throwOnError, bo return (RuntimeType)a.GetType(typeName.Substring(0, idx), throwOnError, ignoreCase); } - var t = internal_from_name(typeName, ref stackMark, null, throwOnError, ignoreCase, false); + RuntimeType? t = internal_from_name(typeName, ref stackMark, null, throwOnError, ignoreCase, false); if (throwOnError && t == null) throw new TypeLoadException("Error loading '" + typeName + "'"); return t; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs index 9c1823323372f3..3cbd81933d259a 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs @@ -100,7 +100,7 @@ public bool IsAlive { get { - var state = GetState(this); + ThreadState state = GetState(this); return (state & (ThreadState.Unstarted | ThreadState.Stopped | ThreadState.Aborted)) == 0; } } @@ -109,7 +109,7 @@ public bool IsBackground { get { - var state = ValidateThreadState(); + ThreadState state = ValidateThreadState(); return (state & ThreadState.Background) != 0; } set @@ -280,7 +280,7 @@ internal void StartCallback() else { var pdel = (ParameterizedThreadStart)m_start; - var arg = m_start_arg; + object? arg = m_start_arg; m_start = null; m_start_arg = null; pdel(arg); @@ -302,7 +302,7 @@ public static bool Yield() private ThreadState ValidateThreadState() { - var state = GetState(this); + ThreadState state = GetState(this); if ((state & ThreadState.Stopped) != 0) throw new ThreadStateException("Thread is dead; state can not be accessed."); return state; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/TypeNameParser.cs b/src/mono/netcore/System.Private.CoreLib/src/System/TypeNameParser.cs index ee37ec8b3ee7e3..04a83e865ebb8f 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/TypeNameParser.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/TypeNameParser.cs @@ -55,7 +55,7 @@ private static Type ConstructType( } // Resolve base type - var type = ResolveType(assembly, pname.Names, typeResolver, throwOnError, ignoreCase, ref stackMark); + Type? type = ResolveType(assembly, pname.Names, typeResolver, throwOnError, ignoreCase, ref stackMark); if (type == null) return null; @@ -76,7 +76,7 @@ private static Type ConstructType( if (pname.Modifiers != null) { bool bounded = false; - foreach (var mod in pname.Modifiers) + foreach (int mod in pname.Modifiers) { switch (mod) { @@ -130,7 +130,7 @@ private static Assembly ResolveAssembly(string name, Func assemblyResolver, Func assemblyResolver, Func assemblyResolver, Func Date: Wed, 25 Mar 2020 09:33:17 -0400 Subject: [PATCH 02/11] Use pattern matching --- .../src/System/Environment.Unix.cs | 4 ++-- .../Emit/ConstructorOnTypeBuilderInst.cs | 3 +-- .../src/System/Reflection/Emit/DynamicMethod.cs | 3 +-- .../src/System/Reflection/Emit/TypeBuilder.Mono.cs | 11 +++++------ .../Reflection/Emit/TypeBuilderInstantiation.cs | 6 ++---- .../src/System/Reflection/RuntimeParameterInfo.cs | 7 ++----- .../src/System/RuntimeType.Mono.cs | 14 ++------------ 7 files changed, 15 insertions(+), 33 deletions(-) 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 8e7982e9992bed..9e26bd8b9ce563 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.Unix.cs @@ -454,8 +454,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/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs index 3c8f4bba66a67d..a34d5920dbc923 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs @@ -125,9 +125,8 @@ public override ParameterInfo[] GetParameters() internal override ParameterInfo[] GetParametersInternal() { ParameterInfo[] res; - if (cb is ConstructorBuilder) + if (cb is ConstructorBuilder cbuilder) { - ConstructorBuilder cbuilder = (ConstructorBuilder)cb; res = new ParameterInfo[cbuilder.parameters.Length]; for (int i = 0; i < cbuilder.parameters.Length; i++) { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs index 3625b488b930d4..9cb69d73dbd37e 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs @@ -167,9 +167,8 @@ private void CreateDynMethod() { for (int i = 0; i < refs.Length; ++i) { - if (refs[i] is DynamicMethod) + if (refs[i] is DynamicMethod m) { - DynamicMethod m = (DynamicMethod)refs[i]; if (!m.creating) m.CreateDynMethod(); } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs index fe0729e7a9cd27..86cead2073149c 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs @@ -651,9 +651,8 @@ public void DefineMethodOverride(MethodInfo methodInfoBody, MethodInfo methodInf if (methodInfoBody.DeclaringType != this) throw new ArgumentException("method body must belong to this type"); - if (methodInfoBody is MethodBuilder) + if (methodInfoBody is MethodBuilder mb) { - MethodBuilder mb = (MethodBuilder)methodInfoBody; mb.set_override(methodInfoDeclaration); } } @@ -802,9 +801,9 @@ TypeInfo CreateTypeInfo() if (fb == null) continue; Type ft = fb.FieldType; - if (!fb.IsStatic && (ft is TypeBuilder) && ft.IsValueType && (ft != this) && is_nested_in(ft)) + if (!fb.IsStatic && (ft is TypeBuilder builder) && ft.IsValueType && (ft != this) && is_nested_in(ft)) { - TypeBuilder tb = (TypeBuilder)ft; + TypeBuilder tb = builder; if (!tb.is_created) { throw new NotImplementedException(); @@ -850,7 +849,7 @@ TypeInfo CreateTypeInfo() throw new BadImageFormatException(); if (!iface.IsInterface) throw new TypeLoadException(); - if (iface is TypeBuilder && !((TypeBuilder)iface).is_created) + if (iface is TypeBuilder builder && !builder.is_created) throw new TypeLoadException(); } } @@ -1437,7 +1436,7 @@ public void SetCustomAttribute(CustomAttributeBuilder customBuilder) throw new Exception("Error in customattr"); } - Type ctor_type = customBuilder.Ctor is ConstructorBuilder ? ((ConstructorBuilder)customBuilder.Ctor).parameters[0] : customBuilder.Ctor.GetParametersInternal()[0].ParameterType; + Type ctor_type = customBuilder.Ctor is ConstructorBuilder builder ? builder.parameters[0] : customBuilder.Ctor.GetParametersInternal()[0].ParameterType; int pos = 6; if (ctor_type.FullName == "System.Int16") pos = 4; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs index 543ec4ba6bebe2..9ed7e44a4dd32d 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs @@ -99,13 +99,11 @@ internal bool IsCreated { get { - TypeBuilder tb = generic_type as TypeBuilder; - return tb != null ? tb.is_created : true; + return generic_type is TypeBuilder tb ? tb.is_created : true; } } - private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | - BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly; + private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly; private Type GetParentType() { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs index c7df70df12ef73..c5dfc61868e96e 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs @@ -164,12 +164,9 @@ int MetadataToken { get { - if (MemberImpl is PropertyInfo) + if (MemberImpl is PropertyInfo prop) { - PropertyInfo prop = (PropertyInfo)MemberImpl; - MethodInfo mi = prop.GetGetMethod(true); - if (mi == null) - mi = prop.GetSetMethod(true); + MethodInfo mi = prop.GetGetMethod(true) ?? prop.GetSetMethod(true); return mi.GetParametersInternal()[PositionImpl].MetadataToken; } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs index 7e984d60c3fbd7..9dd96be197d107 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs @@ -1568,12 +1568,7 @@ public override object InvokeMember( } else { - if (results == null) - { - results = new List(semiFinalists.Length); - results.Add(finalist); - } - + results ??= new List(semiFinalists.Length) { finalist }; results.Add(semiFinalist); } } @@ -1622,12 +1617,7 @@ public override object InvokeMember( } else { - if (results == null) - { - results = new List(semiFinalists.Length); - results.Add(finalist); - } - + results ??= new List(semiFinalists.Length) { finalist }; results.Add(semiFinalist); } } From 3dda1887014ecd6bd96b785a09d9c71aa2b37cf3 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 09:34:32 -0400 Subject: [PATCH 03/11] Use null propagation --- .../src/System/Reflection/Emit/DynamicMethod.cs | 2 +- .../src/System/Reflection/Emit/SignatureHelper.cs | 4 +--- .../src/System/Reflection/RuntimeModule.cs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs index 9cb69d73dbd37e..7042ca8940fd78 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs @@ -91,7 +91,7 @@ public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Type o { } - public DynamicMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility) : this(name, attributes, callingConvention, returnType, parameterTypes, owner, owner != null ? owner.Module : null, skipVisibility, false, true) + public DynamicMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility) : this(name, attributes, callingConvention, returnType, parameterTypes, owner, owner?.Module, skipVisibility, false, true) { } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs index 2768f392258ec7..29b5c2e0ce085a 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs @@ -238,9 +238,7 @@ public void AddArguments(Type[] arguments, Type[][] requiredCustomModifiers, Typ for (int i = 0; i < arguments.Length; i++) { - AddArgument(arguments[i], - requiredCustomModifiers != null ? requiredCustomModifiers[i] : null, - optionalCustomModifiers != null ? optionalCustomModifiers[i] : null); + AddArgument(arguments[i], requiredCustomModifiers?[i], optionalCustomModifiers?[i]); } } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs index 42dd0e2f2cf384..0485d368915ca2 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs @@ -141,7 +141,7 @@ FieldInfo GetField(string name, BindingFlags bindingAttr) return null; Type globalType = GetGlobalType(_impl); - return (globalType != null) ? globalType.GetField(name, bindingAttr) : null; + return globalType?.GetField(name, bindingAttr); } public override From d5ad4792ae212799029092adc20fd31a0d02198e Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 09:40:35 -0400 Subject: [PATCH 04/11] Simplify null checks --- .../System.Private.CoreLib/src/System/RuntimeType.Mono.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs index 9dd96be197d107..a90d14b77071f2 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs @@ -897,7 +897,7 @@ protected override PropertyInfo GetPropertyImpl( } else { - if ((object)returnType == null) + if (returnType is null) // if we are here we have no args or property type to select over and we have more than one property with that name throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); } @@ -1155,7 +1155,7 @@ public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFla public override bool IsEquivalentTo(Type? other) { RuntimeType otherRtType = other as RuntimeType; - if ((object)otherRtType == null) + if (otherRtType is null) return false; if (otherRtType == this) @@ -2363,7 +2363,7 @@ public override InterfaceMapping GetInterfaceMap(Type ifaceType) if (IsGenericParameter) throw new InvalidOperationException(Environment.GetResourceString("Arg_GenericParameter")); - if ((object)ifaceType == null) + if (ifaceType is null) throw new ArgumentNullException(nameof(ifaceType)); RuntimeType ifaceRtType = ifaceType as RuntimeType; @@ -2559,7 +2559,7 @@ internal override bool IsUserType public override bool IsSubclassOf(Type type) { - if ((object)type == null) + if (type is null) throw new ArgumentNullException(nameof(type)); RuntimeType rtType = type as RuntimeType; From 6c94c465204d4e815855639e98f11ea5ead19b9e Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 09:35:52 -0400 Subject: [PATCH 05/11] Simplify default expressions --- .../System/Globalization/JapaneseCalendar.Unix.cs | 2 +- .../src/System/IO/BufferedStream.cs | 4 ++-- .../src/System/IO/FileStream.Unix.cs | 6 +++--- .../Permissions/CodeAccessSecurityAttribute.cs | 2 +- .../Permissions/SecurityPermissionAttribute.cs | 2 +- .../Threading/PortableThreadPool.HillClimbing.cs | 6 +++--- .../src/System/TimeZoneInfo.Unix.cs | 14 +++++++------- 7 files changed, 18 insertions(+), 18 deletions(-) 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 0bbebba7742845..ed4e20de104472 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/IO/BufferedStream.cs b/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs index 61acd65b589d8d..88c89be5155339 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) { @@ -1074,7 +1074,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/FileStream.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs index 2a8e277c35e639..855397ce0dc2ed 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/Security/Permissions/CodeAccessSecurityAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Security/Permissions/CodeAccessSecurityAttribute.cs index a816f1d0162a27..1a27b3b39da681 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 e1e74c4166a005..2ec3057bb91a7f 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/Threading/PortableThreadPool.HillClimbing.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.HillClimbing.cs index b1eae812b4c806..48fd65b5399be8 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 @@ -197,10 +197,10 @@ public HillClimbing(int wavePeriod, int maxWaveMagnitude, double waveMagnitudeMu // // 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/TimeZoneInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs index ba7d466b29dcd7..d8822233f71690 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs @@ -938,8 +938,8 @@ private static void TZif_GenerateAdjustmentRule(ref int index, TimeSpan timeZone DateTime.MinValue, endTransitionDate.AddTicks(-1), daylightDelta, - default(TransitionTime), - default(TransitionTime), + default, + default, baseUtcDelta, noDaylightTransitions: true); @@ -974,7 +974,7 @@ private static void TZif_GenerateAdjustmentRule(ref int index, TimeSpan timeZone } else { - dstStart = default(TransitionTime); + dstStart = default; } AdjustmentRule r = AdjustmentRule.CreateAdjustmentRule( @@ -982,7 +982,7 @@ private static void TZif_GenerateAdjustmentRule(ref int index, TimeSpan timeZone endTransitionDate.AddTicks(-1), daylightDelta, dstStart, - default(TransitionTime), + default, baseUtcDelta, noDaylightTransitions: true); @@ -1144,8 +1144,8 @@ private static TZifType TZif_GetEarlyDateTransitionType(TZifType[] transitionTyp startTransitionDate, DateTime.MaxValue, TimeSpan.Zero, - default(TransitionTime), - default(TransitionTime), + default, + default, baseOffset, noDaylightTransitions: true); } @@ -1359,7 +1359,7 @@ private static bool TZif_ParseMDateRule(ReadOnlySpan dateRule, out int mon month = 0; week = 0; - dayOfWeek = default(DayOfWeek); + dayOfWeek = default; return false; } From 0261a093f3144bf132bc85e5610f59f7d5552ad1 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 09:37:22 -0400 Subject: [PATCH 06/11] Order modifiers --- .../InteropServices/ComWrappers.PlatformNotSupported.cs | 4 ++-- .../System.Private.CoreLib/src/Mono/RuntimeHandles.cs | 2 +- .../src/System/Diagnostics/Tracing/EventPipe.Mono.cs | 2 +- .../src/System/Reflection/RuntimeAssembly.cs | 6 +++--- .../src/System/Reflection/RuntimeFieldInfo.cs | 6 +++--- .../src/System/Reflection/RuntimeMethodInfo.cs | 6 +++--- .../System.Private.CoreLib/src/System/RuntimeFieldHandle.cs | 4 ++-- .../src/System/Threading/EventWaitHandle.Unix.Mono.cs | 2 +- .../src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs | 2 +- .../src/System/Threading/Mutex.Unix.Mono.cs | 4 ++-- .../src/System/Threading/Overlapped.cs | 2 +- .../src/System/Threading/Semaphore.Unix.Mono.cs | 4 ++-- .../src/System/Threading/Thread.Mono.cs | 2 +- .../src/System/Threading/WaitHandle.Mono.cs | 2 +- .../System.Private.CoreLib/src/System/TypedReference.cs | 4 ++-- 15 files changed, 26 insertions(+), 26 deletions(-) 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 77e8b35baae469..83a8cd76b0adfa 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 @@ -47,7 +47,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 +73,4 @@ protected static void GetIUnknownImpl(out IntPtr fpQueryInterface, out IntPtr fp throw new PlatformNotSupportedException(); } } -} \ No newline at end of file +} 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 1d05876ce99a33..6815ffad13b38a 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/Mono/RuntimeHandles.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/Mono/RuntimeHandles.cs @@ -60,7 +60,7 @@ 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)); } 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 de832fa5d04477..9f33a03ec0b5ab 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 @@ -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/Reflection/RuntimeAssembly.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index 1f97907499c7dc..c23f978d7404aa 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -61,7 +61,7 @@ public unsafe UnmanagedMemoryStreamForModule(byte* pointer, long length, Module private ResolveEventHolder resolve_event_holder; - public override extern MethodInfo? EntryPoint + public extern override MethodInfo? EntryPoint { [MethodImplAttribute(MethodImplOptions.InternalCall)] get; @@ -144,10 +144,10 @@ internal static AssemblyName CreateAssemblyName(string assemblyString, out Runti } [MethodImplAttribute(MethodImplOptions.InternalCall)] - public override extern string[] GetManifestResourceNames(); + public extern override string[] GetManifestResourceNames(); [MethodImplAttribute(MethodImplOptions.InternalCall)] - public override extern Type[] GetExportedTypes(); + public extern override Type[] GetExportedTypes(); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal extern Type[] GetTopLevelForwardedTypes(); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs index 1ad52ff27b9796..29c401bd291a2c 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs @@ -83,7 +83,7 @@ internal RuntimeModule GetRuntimeModule() } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal override extern object UnsafeGetValue(object obj); + internal extern override object UnsafeGetValue(object obj); internal override void CheckConsistency(object target) { @@ -211,7 +211,7 @@ public override object[] GetCustomAttributes(Type attributeType, bool inherit) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal override extern int GetFieldOffset(); + internal extern override int GetFieldOffset(); [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern object GetValueInternal(object obj); @@ -279,7 +279,7 @@ internal RuntimeFieldInfo Clone(string newName) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - public override extern object GetRawConstantValue(); + public extern override object GetRawConstantValue(); public override IList GetCustomAttributesData() { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs index 6372cfcb9dcd79..aff17e11ccbdc5 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs @@ -716,7 +716,7 @@ public override MethodInfo MakeGenericMethod(Type[] methodInstantiation) private extern MethodInfo MakeGenericMethod_impl(Type[] types); [MethodImplAttribute(MethodImplOptions.InternalCall)] - public override extern Type[] GetGenericArguments(); + public extern override Type[] GetGenericArguments(); [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern MethodInfo GetGenericMethodDefinition_impl(); @@ -730,13 +730,13 @@ public override MethodInfo GetGenericMethodDefinition() return res; } - public override extern bool IsGenericMethodDefinition + public extern override bool IsGenericMethodDefinition { [MethodImplAttribute(MethodImplOptions.InternalCall)] get; } - public override extern bool IsGenericMethod + public extern override bool IsGenericMethod { [MethodImplAttribute(MethodImplOptions.InternalCall)] get; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs index 159ffbdec78b56..fd1d24ff6a4862 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs @@ -78,10 +78,10 @@ internal static void SetValue(RuntimeFieldInfo field, object obj, object value, } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static unsafe extern object GetValueDirect(RuntimeFieldInfo field, RuntimeType fieldType, void* pTypedRef, RuntimeType contextType); + internal static extern unsafe object GetValueDirect(RuntimeFieldInfo field, RuntimeType fieldType, void* pTypedRef, RuntimeType contextType); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static unsafe extern void SetValueDirect(RuntimeFieldInfo field, RuntimeType fieldType, void* pTypedRef, object value, RuntimeType contextType); + internal static extern unsafe void SetValueDirect(RuntimeFieldInfo field, RuntimeType fieldType, void* pTypedRef, object value, RuntimeType contextType); } } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.Mono.cs index 7a776ee3232fda..1426b9ca14a038 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.Mono.cs @@ -88,7 +88,7 @@ private SafeWaitHandle ValidateHandle(out bool success) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern IntPtr CreateEventInternal(bool manual, bool initialState, char* name, int name_length, out int errorCode); + private static extern unsafe IntPtr CreateEventInternal(bool manual, bool initialState, char* name, int name_length, out int errorCode); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool ResetEventInternal(IntPtr handle); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs index cf664501d7e7fb..5b1d59a46f8f88 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs @@ -6,7 +6,7 @@ namespace System.Threading { - internal unsafe sealed partial class LowLevelLifoSemaphore : IDisposable + internal sealed unsafe partial class LowLevelLifoSemaphore : IDisposable { private IntPtr lifo_semaphore; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Mutex.Unix.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Mutex.Unix.Mono.cs index c12d39928c2b1f..b6174e93dab0f0 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Mutex.Unix.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Mutex.Unix.Mono.cs @@ -68,10 +68,10 @@ private static unsafe IntPtr OpenMutex_internal(string name, out MonoIOError err } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern IntPtr CreateMutex_icall(bool initiallyOwned, char* name, int name_length, out bool created); + private static extern unsafe IntPtr CreateMutex_icall(bool initiallyOwned, char* name, int name_length, out bool created); [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern IntPtr OpenMutex_icall(char* name, int name_length, int rights, out MonoIOError error); + private static extern unsafe IntPtr OpenMutex_icall(char* name, int name_length, int rights, out MonoIOError error); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool ReleaseMutex_internal(IntPtr handle); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Overlapped.cs index ff37e273e4976b..8c3225725d81dc 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -65,7 +65,7 @@ internal static unsafe void PerformIOCompletionCallback(uint errorCode, uint num #region class OverlappedData - internal unsafe sealed class OverlappedData + internal sealed unsafe class OverlappedData { internal IAsyncResult _asyncResult; internal object _callback; // IOCompletionCallback or _IOCompletionCallback diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.Mono.cs index c9f5b56240c829..a4d5d026ec405e 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.Mono.cs @@ -94,10 +94,10 @@ private static unsafe IntPtr OpenSemaphore_internal(string name, int rights, out } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern IntPtr CreateSemaphore_icall(int initialCount, int maximumCount, char* name, int nameLength, out MonoIOError errorCode); + private static extern unsafe IntPtr CreateSemaphore_icall(int initialCount, int maximumCount, char* name, int nameLength, out MonoIOError errorCode); [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern IntPtr OpenSemaphore_icall(char* name, int nameLength, int rights, out MonoIOError errorCode); + private static extern unsafe IntPtr OpenSemaphore_icall(char* name, int nameLength, int rights, out MonoIOError errorCode); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool ReleaseSemaphore_internal(IntPtr handle, int releaseCount, out int previousCount); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs index 3cbd81933d259a..6c8e336c3ef0c8 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs @@ -341,7 +341,7 @@ private static Thread InitializeCurrentThread() private static extern string GetName(Thread thread); [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern void SetName_icall(Thread thread, char* name, int nameLength); + private static extern unsafe void SetName_icall(Thread thread, char* name, int nameLength); private static unsafe void SetName(Thread thread, string name) { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/WaitHandle.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/WaitHandle.Mono.cs index b9ae29c95b2ebb..82466de8ae990a 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/WaitHandle.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/WaitHandle.Mono.cs @@ -10,7 +10,7 @@ namespace System.Threading public partial class WaitHandle { [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern int Wait_internal(IntPtr* handles, int numHandles, bool waitAll, int ms); + private static extern unsafe int Wait_internal(IntPtr* handles, int numHandles, bool waitAll, int ms); private static int WaitOneCore(IntPtr waitHandle, int millisecondsTimeout) { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/TypedReference.cs b/src/mono/netcore/System.Private.CoreLib/src/System/TypedReference.cs index 07dc8103b3fab8..b54dca95915167 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/TypedReference.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/TypedReference.cs @@ -60,7 +60,7 @@ public static TypedReference MakeTypedReference(object target, FieldInfo[] flds) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern void InternalMakeTypedReference(void* result, object target, IntPtr[] flds, RuntimeType lastFieldType); + private static extern unsafe void InternalMakeTypedReference(void* result, object target, IntPtr[] flds, RuntimeType lastFieldType); public override int GetHashCode() { @@ -81,7 +81,7 @@ public static unsafe object ToObject(TypedReference value) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static unsafe extern object InternalToObject(void* value); + private static extern unsafe object InternalToObject(void* value); internal bool IsNull { From 6e9516a8149958eb6ad0f9af398fb3164a21afd8 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 09:57:15 -0400 Subject: [PATCH 07/11] Make fields readonly --- .../Common/src/Interop/Unix/Interop.Errors.cs | 2 +- .../src/System/Threading/LowLevelLifoSemaphore.cs | 8 ++++---- .../Threading/PortableThreadPool.HillClimbing.cs | 8 ++++---- .../System/Threading/PortableThreadPool.WaitThread.cs | 2 +- .../Threading/PortableThreadPool.WorkerThread.cs | 2 +- .../src/System/Threading/PortableThreadPool.cs | 2 +- .../src/System/Threading/ThreadPool.Portable.cs | 2 +- .../System.Private.CoreLib/src/Mono/RuntimeHandles.cs | 10 +++++----- .../src/System/Threading/Overlapped.cs | 6 +++--- .../src/System/TypeIdentifier.cs | 8 ++++---- .../System.Private.CoreLib/src/System/TypeSpec.cs | 10 +++++----- .../src/System/WeakReference.T.Mono.cs | 2 +- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs b/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs index 49cc830e00e820..dad796280e71aa 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/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.cs index 62affa80c30758..3cf328d2a40ae7 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.HillClimbing.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.HillClimbing.cs index 48fd65b5399be8..2e50906c0bb96f 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 @@ -83,13 +83,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; 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 593429973b0f2a..3f524a39510e5f 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 @@ -15,7 +15,7 @@ internal partial class PortableThreadPool private WaitThreadNode _waitThreadsHead; private WaitThreadNode _waitThreadsTail; - private LowLevelLock _waitThreadLock = new LowLevelLock(); + private readonly LowLevelLock _waitThreadLock = new LowLevelLock(); /// /// Register a wait handle on a . 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 3fdf1f65767af4..7e70f3fe034676 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 @@ -16,7 +16,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 3529148f534378..25f43493867721 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/ThreadPool.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs index 85c9e0033e718c..234b12bae50b23 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 @@ -104,7 +104,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/mono/netcore/System.Private.CoreLib/src/Mono/RuntimeHandles.cs b/src/mono/netcore/System.Private.CoreLib/src/Mono/RuntimeHandles.cs index 6815ffad13b38a..7e2afa49728408 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) { @@ -67,7 +67,7 @@ public bool Equals(RuntimeClassHandle handle) 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/System/Threading/Overlapped.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 8c3225725d81dc..54a403e16646bd 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -11,8 +11,8 @@ namespace System.Threading internal unsafe class _IOCompletionCallback { - private IOCompletionCallback _ioCompletionCallback; - private ExecutionContext _executionContext; + private readonly IOCompletionCallback _ioCompletionCallback; + private readonly ExecutionContext _executionContext; private uint _errorCode; // Error code private uint _numBytes; // No. of bytes transferred private NativeOverlapped* _pNativeOverlapped; @@ -317,4 +317,4 @@ public static unsafe void Free(NativeOverlapped* nativeOverlappedPtr) } #endregion class Overlapped -} \ No newline at end of file +} diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/TypeIdentifier.cs b/src/mono/netcore/System.Private.CoreLib/src/System/TypeIdentifier.cs index 8448b0d82eb11e..2f55edecfc67c1 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/TypeIdentifier.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/TypeIdentifier.cs @@ -90,7 +90,7 @@ public override bool Equals(object? other) private class Display : ATypeName { - private string displayName; + private readonly string displayName; internal Display(string displayName) { @@ -134,7 +134,7 @@ internal static ITypeIdentifier WithoutEscape(string simpleName) private class Display : TypeNames.ATypeName, ITypeIdentifier { - private string displayName; + private readonly string displayName; private string internal_name; //cached internal Display(string displayName) @@ -171,7 +171,7 @@ public override ITypeName NestedName(ITypeIdentifier innerName) private class Internal : TypeNames.ATypeName, ITypeIdentifier { - private string internalName; + private readonly string internalName; private string display_name; //cached internal Internal(string internalName) @@ -213,7 +213,7 @@ public override ITypeName NestedName(ITypeIdentifier innerName) private class NoEscape : TypeNames.ATypeName, ITypeIdentifier { - private string simpleName; + private readonly string simpleName; internal NoEscape(string simpleName) { this.simpleName = simpleName; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/TypeSpec.cs b/src/mono/netcore/System.Private.CoreLib/src/System/TypeSpec.cs index eaf5b290a7d806..755b0472f30009 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/TypeSpec.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/TypeSpec.cs @@ -42,8 +42,8 @@ internal interface IModifierSpec internal class IArraySpec : IModifierSpec { // dimensions == 1 and bound, or dimensions > 1 and !bound - private int dimensions; - private bool bound; + private readonly int dimensions; + private readonly bool bound; internal IArraySpec(int dimensions, bool bound) { @@ -93,7 +93,7 @@ public bool IsBound internal class PointerSpec : IModifierSpec { - private int pointer_level; + private readonly int pointer_level; internal PointerSpec(int pointer_level) { @@ -651,8 +651,8 @@ internal ITypeName TypeName private class TypeSpecTypeName : TypeNames.ATypeName, ITypeName { - private TypeSpec ts; - private bool want_modifiers; + private readonly TypeSpec ts; + private readonly bool want_modifiers; internal TypeSpecTypeName(TypeSpec ts, bool wantModifiers) { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/WeakReference.T.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/WeakReference.T.Mono.cs index 0c9332baa1f25e..18f92c8db49234 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/WeakReference.T.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/WeakReference.T.Mono.cs @@ -29,7 +29,7 @@ private void Create(T target, bool trackResurrection) { if (trackResurrection) { - trackResurrection = true; + this.trackResurrection = true; handle = GCHandle.Alloc(target, GCHandleType.WeakTrackResurrection); } else From 3c81e79859832ba7e2cad9d7324bfbc27d4ad596 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 10:00:20 -0400 Subject: [PATCH 08/11] Delete dead members --- .../src/System/IO/BufferedStream.cs | 13 ------------- .../Threading/PortableThreadPool.WaitThread.cs | 5 ++--- .../src/System/RuntimeType.Mono.cs | 11 ----------- 3 files changed, 2 insertions(+), 27 deletions(-) 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 88c89be5155339..6ab6272fed463c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs @@ -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) 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 3f524a39510e5f..6edf3dbd2b7105 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 @@ -13,7 +13,6 @@ internal partial class PortableThreadPool /// A linked list of s. /// private WaitThreadNode _waitThreadsHead; - private WaitThreadNode _waitThreadsTail; private readonly LowLevelLock _waitThreadLock = new LowLevelLock(); @@ -28,7 +27,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 +47,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/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs index a90d14b77071f2..b6e032e1c533b9 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs @@ -2203,17 +2203,6 @@ private static object IsConvertibleToPrimitiveType(object value, Type targetType return null; } - private string GetCachedName(TypeNameKind kind) - { - switch (kind) - { - case TypeNameKind.SerializationName: - return ToString(); - default: - throw new NotImplementedException(); - } - } - [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern Type make_array_type(int rank); From 993d8649c699058f5f29b021caf8c075058404d9 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 10:38:45 -0400 Subject: [PATCH 09/11] Use switch expressions --- .../Emit/CustomAttributeBuilder.Mono.cs | 50 ++++++----------- .../System/Reflection/Emit/SignatureHelper.cs | 13 ++--- .../Reflection/Emit/TypeBuilder.Mono.cs | 40 ++++--------- .../System/Reflection/RuntimeMethodInfo.cs | 56 +++++-------------- 4 files changed, 49 insertions(+), 110 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs index 762ad36eb534d3..eb8ba3849275b4 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs @@ -436,41 +436,25 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild } } - private static Type elementTypeToType(int elementType) - { + private static Type elementTypeToType(int elementType) => /* Partition II, section 23.1.16 */ - switch (elementType) + elementType switch { - case 0x02: - return typeof(bool); - case 0x03: - return typeof(char); - case 0x04: - return typeof(sbyte); - case 0x05: - return typeof(byte); - case 0x06: - return typeof(short); - case 0x07: - return typeof(ushort); - case 0x08: - return typeof(int); - case 0x09: - return typeof(uint); - case 0x0a: - return typeof(long); - case 0x0b: - return typeof(ulong); - case 0x0c: - return typeof(float); - case 0x0d: - return typeof(double); - case 0x0e: - return typeof(string); - default: - throw new Exception("Unknown element type '" + elementType + "'"); - } - } + 0x02 => typeof(bool), + 0x03 => typeof(char), + 0x04 => typeof(sbyte), + 0x05 => typeof(byte), + 0x06 => typeof(short), + 0x07 => typeof(ushort), + 0x08 => typeof(int), + 0x09 => typeof(uint), + 0x0a => typeof(long), + 0x0b => typeof(ulong), + 0x0c => typeof(float), + 0x0d => typeof(double), + 0x0e => typeof(string), + _ => throw new Exception("Unknown element type '" + elementType + "'"), + }; private static object decode_cattr_value(Type t, byte[] data, int pos, out int rpos) { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs index 29b5c2e0ce085a..f4a8bcbe2d1820 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs @@ -376,15 +376,12 @@ public byte[] GetSignature() { TypeBuilder.ResolveUserTypes(arguments); - switch (type) + return type switch { - case SignatureHelperType.HELPER_LOCAL: - return get_signature_local(); - case SignatureHelperType.HELPER_FIELD: - return get_signature_field(); - default: - throw new NotImplementedException(); - } + SignatureHelperType.HELPER_LOCAL => get_signature_local(), + SignatureHelperType.HELPER_FIELD => get_signature_field(), + _ => throw new NotImplementedException(), + }; } public override string ToString() diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs index 86cead2073149c..0e17ff33fc2b8b 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs @@ -1116,21 +1116,13 @@ private MethodInfo[] GetMethodsByName(string name, BindingFlags bindingAttr, boo if (m.IsStatic && !flatten) continue; - switch (mattrs & MethodAttributes.MemberAccessMask) + match = (mattrs & MethodAttributes.MemberAccessMask) switch { - case MethodAttributes.Public: - match = (bindingAttr & BindingFlags.Public) != 0; - break; - case MethodAttributes.Assembly: - match = (bindingAttr & BindingFlags.NonPublic) != 0; - break; - case MethodAttributes.Private: - match = false; - break; - default: - match = (bindingAttr & BindingFlags.NonPublic) != 0; - break; - } + MethodAttributes.Public => (bindingAttr & BindingFlags.Public) != 0, + MethodAttributes.Assembly => (bindingAttr & BindingFlags.NonPublic) != 0, + MethodAttributes.Private => false, + _ => (bindingAttr & BindingFlags.NonPublic) != 0, + }; if (match) parent_candidates.Add(m); @@ -1420,21 +1412,13 @@ public void SetCustomAttribute(CustomAttributeBuilder customBuilder) layout_kind = (int)data[2]; layout_kind |= ((int)data[3]) << 8; attrs &= ~TypeAttributes.LayoutMask; - switch ((LayoutKind)layout_kind) + attrs |= ((LayoutKind)layout_kind) switch { - case LayoutKind.Auto: - attrs |= TypeAttributes.AutoLayout; - break; - case LayoutKind.Explicit: - attrs |= TypeAttributes.ExplicitLayout; - break; - case LayoutKind.Sequential: - attrs |= TypeAttributes.SequentialLayout; - break; - default: - // we should ignore it since it can be any value anyway... - throw new Exception("Error in customattr"); - } + LayoutKind.Auto => TypeAttributes.AutoLayout, + LayoutKind.Explicit => TypeAttributes.ExplicitLayout, + LayoutKind.Sequential => TypeAttributes.SequentialLayout, + _ => throw new Exception("Error in customattr"), // we should ignore it since it can be any value anyway... + }; Type ctor_type = customBuilder.Ctor is ConstructorBuilder builder ? builder.parameters[0] : customBuilder.Ctor.GetParametersInternal()[0].ParameterType; int pos = 6; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs index aff17e11ccbdc5..27a619be3b0004 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs @@ -601,52 +601,26 @@ private CustomAttributeData GetDllImportAttributeData() GetPInvoke(out flags, out entryPoint, out dllName); - CharSet charSet; - - switch (flags & PInvokeAttributes.CharSetMask) + CharSet charSet = (flags & PInvokeAttributes.CharSetMask) switch { - case PInvokeAttributes.CharSetNotSpec: - charSet = CharSet.None; - break; - case PInvokeAttributes.CharSetAnsi: - charSet = CharSet.Ansi; - break; - case PInvokeAttributes.CharSetUnicode: - charSet = CharSet.Unicode; - break; - case PInvokeAttributes.CharSetAuto: - charSet = CharSet.Auto; - break; + PInvokeAttributes.CharSetNotSpec => CharSet.None, + PInvokeAttributes.CharSetAnsi => CharSet.Ansi, + PInvokeAttributes.CharSetUnicode => CharSet.Unicode, + PInvokeAttributes.CharSetAuto => CharSet.Auto, // Invalid: default to CharSet.None - default: - charSet = CharSet.None; - break; - } - - InteropServicesCallingConvention callingConvention; + _ => CharSet.None, + }; - switch (flags & PInvokeAttributes.CallConvMask) + InteropServicesCallingConvention callingConvention = (flags & PInvokeAttributes.CallConvMask) switch { - case PInvokeAttributes.CallConvWinapi: - callingConvention = InteropServicesCallingConvention.Winapi; - break; - case PInvokeAttributes.CallConvCdecl: - callingConvention = InteropServicesCallingConvention.Cdecl; - break; - case PInvokeAttributes.CallConvStdcall: - callingConvention = InteropServicesCallingConvention.StdCall; - break; - case PInvokeAttributes.CallConvThiscall: - callingConvention = InteropServicesCallingConvention.ThisCall; - break; - case PInvokeAttributes.CallConvFastcall: - callingConvention = InteropServicesCallingConvention.FastCall; - break; + PInvokeAttributes.CallConvWinapi => InteropServicesCallingConvention.Winapi, + PInvokeAttributes.CallConvCdecl => InteropServicesCallingConvention.Cdecl, + PInvokeAttributes.CallConvStdcall => InteropServicesCallingConvention.StdCall, + PInvokeAttributes.CallConvThiscall => InteropServicesCallingConvention.ThisCall, + PInvokeAttributes.CallConvFastcall => InteropServicesCallingConvention.FastCall, // Invalid: default to CallingConvention.Cdecl - default: - callingConvention = InteropServicesCallingConvention.Cdecl; - break; - } + _ => InteropServicesCallingConvention.Cdecl, + }; bool exactSpelling = (flags & PInvokeAttributes.NoMangle) != 0; bool setLastError = (flags & PInvokeAttributes.SupportsLastError) != 0; From 493a3f3771775357a72bdc55878e704799052bac Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 25 Mar 2020 10:56:54 -0400 Subject: [PATCH 10/11] Remove unnecessary usings --- .../Unix/System.Globalization.Native/Interop.Calendar.cs | 1 - .../Unix/System.Globalization.Native/Interop.Casing.cs | 3 --- .../Unix/System.Globalization.Native/Interop.Collation.cs | 1 - .../Unix/System.Globalization.Native/Interop.ICU.cs | 2 -- .../Unix/System.Globalization.Native/Interop.Idna.cs | 1 - .../Unix/System.Globalization.Native/Interop.Locale.cs | 1 - .../System.Globalization.Native/Interop.Normalization.cs | 1 - .../System.Globalization.Native/Interop.TimeZoneInfo.cs | 1 - .../Unix/System.Globalization.Native/Interop.Utils.cs | 2 -- .../src/Interop/Unix/System.Native/Interop.Access.cs | 1 - .../Common/src/Interop/Unix/System.Native/Interop.ChDir.cs | 1 - .../Unix/System.Native/Interop.GetCpuUtilization.cs | 2 -- .../src/Interop/Unix/System.Native/Interop.GetEUid.cs | 1 - .../src/Interop/Unix/System.Native/Interop.GetPid.cs | 1 - .../src/Interop/Unix/System.Native/Interop.GetPwUid.cs | 1 - .../Interop/Unix/System.Native/Interop.GetRandomBytes.cs | 2 -- .../Interop/Unix/System.Native/Interop.LockFileRegion.cs | 1 - .../src/Interop/Unix/System.Native/Interop.MountPoints.cs | 1 - .../src/Interop/Unix/System.Native/Interop.PathConf.cs | 1 - .../Common/src/Interop/Unix/System.Native/Interop.Read.cs | 1 - .../Common/src/Interop/Unix/System.Native/Interop.Write.cs | 1 - .../src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs | 1 - .../src/System/Collections/Generic/ISet.cs | 2 -- .../src/System/Diagnostics/DebugProvider.Unix.cs | 2 -- .../src/System/Diagnostics/Tracing/EventPipe.cs | 2 +- .../Diagnostics/Tracing/RuntimeEventSourceHelper.Unix.cs | 2 -- .../src/System/Environment.NoRegistry.cs | 2 -- .../System.Private.CoreLib/src/System/Environment.Unix.cs | 2 -- .../src/System/Globalization/CalendarData.Unix.cs | 1 - .../src/System/Globalization/CompareInfo.Unix.cs | 5 ----- .../src/System/Globalization/CultureData.Unix.cs | 4 ---- .../src/System/Globalization/TextInfo.Unix.cs | 3 --- .../System.Private.CoreLib/src/System/Guid.Unix.cs | 3 --- .../src/System/IO/DriveInfoInternal.Unix.cs | 3 --- .../System.Private.CoreLib/src/System/IO/FileAttributes.cs | 2 -- .../src/System/IO/FileStream.Linux.cs | 5 ----- .../System.Private.CoreLib/src/System/IO/Path.Unix.cs | 1 - .../src/System/IO/PathInternal.Unix.cs | 1 - .../src/System/PasteArguments.Unix.cs | 1 - .../Runtime/InteropServices/ComEventsHelpers.NoCom.cs | 2 -- .../InteropServices/ComWrappers.PlatformNotSupported.cs | 1 - .../System/Security/Principal/TokenImpersonationLevel.cs | 2 -- .../src/System/Security/SecureString.Unix.cs | 5 ----- .../System.Private.CoreLib/src/System/SpanHelpers.T.cs | 1 - .../src/System/Text/Unicode/Utf16Utility.Validation.cs | 1 - .../System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs | 1 - .../src/System/Text/Unicode/Utf8Utility.Transcoding.cs | 2 -- .../src/System/Text/Unicode/Utf8Utility.Validation.cs | 1 - .../System/Text/Unicode/Utf8Utility.WhiteSpace.CoreLib.cs | 1 - .../System/Threading/PortableThreadPool.HillClimbing.cs | 1 - .../src/System/Threading/PortableThreadPool.WaitThread.cs | 1 - .../System/Threading/PortableThreadPool.WorkerThread.cs | 2 -- .../src/System/Threading/Thread.Unix.cs | 2 -- .../src/System/Threading/ThreadPool.Portable.cs | 1 - .../ThreadPoolBoundHandle.PlatformNotSupported.cs | 4 ---- .../System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs | 2 -- .../Win32/SafeHandles/SafeWaitHandle.Unix.Mono.cs | 1 - .../netcore/System.Private.CoreLib/src/Mono/MonoDomain.cs | 1 - .../System.Private.CoreLib/src/Mono/SafeGPtrArrayHandle.cs | 1 - .../System.Private.CoreLib/src/System/Array.Mono.cs | 2 -- .../System.Private.CoreLib/src/System/Delegate.Mono.cs | 1 - .../src/System/Diagnostics/Tracing/EventPipe.Mono.cs | 2 +- .../System.Private.CoreLib/src/System/Environment.Mono.cs | 1 - .../netcore/System.Private.CoreLib/src/System/GC.Mono.cs | 1 - .../src/System/Globalization/GlobalizationMode.Mono.cs | 1 - .../System.Private.CoreLib/src/System/IO/MonoIOError.cs | 2 -- .../System.Private.CoreLib/src/System/ModuleHandle.cs | 1 - .../System.Private.CoreLib/src/System/MulticastDelegate.cs | 1 - .../src/System/Reflection/CustomAttribute.cs | 3 --- .../src/System/Reflection/CustomAttributeData.cs | 1 - .../src/System/Reflection/Emit/AssemblyBuilder.Mono.cs | 7 ------- .../src/System/Reflection/Emit/ConstructorBuilder.Mono.cs | 5 ----- .../System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs | 2 -- .../System/Reflection/Emit/CustomAttributeBuilder.Mono.cs | 3 --- .../src/System/Reflection/Emit/DerivedTypes.Mono.cs | 5 ----- .../src/System/Reflection/Emit/DynamicILInfo.cs | 2 -- .../src/System/Reflection/Emit/DynamicMethod.cs | 3 --- .../src/System/Reflection/Emit/EnumBuilder.Mono.cs | 3 --- .../src/System/Reflection/Emit/EventBuilder.Mono.cs | 5 ----- .../src/System/Reflection/Emit/EventOnTypeBuilderInst.cs | 3 --- .../src/System/Reflection/Emit/FieldBuilder.Mono.cs | 4 ---- .../src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs | 2 -- .../System/Reflection/Emit/GenericTypeParameterBuilder.cs | 5 ----- .../src/System/Reflection/Emit/ILGenerator.Mono.cs | 1 - .../src/System/Reflection/Emit/LocalBuilder.Mono.cs | 5 ----- .../src/System/Reflection/Emit/MethodBuilder.Mono.cs | 6 ------ .../src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs | 2 -- .../src/System/Reflection/Emit/ModuleBuilder.Mono.cs | 4 ---- .../src/System/Reflection/Emit/MonoArrayMethod.cs | 2 -- .../src/System/Reflection/Emit/ParameterBuilder.Mono.cs | 5 ----- .../src/System/Reflection/Emit/PropertyBuilder.Mono.cs | 4 ---- .../System/Reflection/Emit/PropertyOnTypeBuilderInst.cs | 2 -- .../src/System/Reflection/Emit/SignatureHelper.cs | 4 ---- .../src/System/Reflection/Emit/TypeBuilder.Mono.cs | 6 ------ .../src/System/Reflection/Emit/TypeBuilderInstantiation.cs | 4 ---- .../src/System/Reflection/Emit/UnmanagedMarshal.cs | 2 -- .../src/System/Reflection/MethodBase.Mono.cs | 1 - .../src/System/Reflection/RuntimeLocalVariableInfo.cs | 2 -- .../src/System/Reflection/RuntimeMethodBody.cs | 3 --- .../src/System/Reflection/RuntimeModule.cs | 1 - .../src/System/Runtime/InteropServices/Marshal.Mono.cs | 1 - .../System/Runtime/InteropServices/NativeLibrary.Mono.cs | 1 - .../src/System/Runtime/InteropServices/SafeHandle.Mono.cs | 2 -- .../src/System/RuntimeMethodHandle.cs | 1 - .../src/System/Security/DynamicSecurityMethodAttribute.cs | 2 -- .../System.Private.CoreLib/src/System/String.Mono.cs | 1 - .../System.Private.CoreLib/src/System/Text/Utf8Span.cs | 4 ---- .../netcore/System.Private.CoreLib/src/System/Type.Mono.cs | 4 ---- .../System.Private.CoreLib/src/System/Utf8String.cs | 4 ---- .../netcore/System.Private.CoreLib/src/System/ValueType.cs | 1 - 110 files changed, 2 insertions(+), 240 deletions(-) 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 764bdaf85afeed..0b9e2c283f0f89 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 503a864d693c6c..499f9445d89ceb 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 7d0175473d7941..a59292e0fca1df 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 f24c2607848b91..0dce072958a7fa 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 89b6c3cebec0a6..e9014da1e5d9e6 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 d9a300fd156dc9..a6517185ce0632 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 d442da0ea137fd..09307d22545f6a 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 df488b6ffa1c46..f60b81f0da8cf6 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 627ab56c9187c2..11534cbdee7562 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 a723f572a5b0a1..b9750fa108330e 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 3c66995182acaa..8979d10f4cd8cf 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 a630a3e82c34ab..509fef8272df23 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 8b525fa3272942..c964dec144e1b0 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 02d259db7d18cf..b93f0895360e07 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 28b2309d03ec9f..5a9a23f87e06f6 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 858506935aef3c..fcc9b8db944a56 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 1deb9a4313208b..5f92357e8f81e7 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 134dcb920375f4..21479bca65cc90 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 7213cb02640fff..e2c127772020b7 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 233feabdbb6958..e37a2ae6c1d7e3 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 fb06d463beb762..c80f1041fd9623 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 ad9e3eaba0c52e..4a3b2cee465604 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 657adf787afa49..ce71acba6258bb 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 9259c4fbe66ce9..55dcaffa0ea3bf 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 88c1434b0cce3e..308c19ada6281b 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 da952d12b4c8a8..7b6e43f9ffb4f5 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 6e699b1f38616f..06e35e387f22ac 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 9e26bd8b9ce563..993b23a89fc68d 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; 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 d8ed0072f37796..e62a707684cc09 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 a8eb8dfdeb00e0..4158890e959e46 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 f3c3e5d4a329f7..67ad489e47adf2 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/TextInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs index 02e7c5f50b9693..ef6cff420b9d23 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 5a1364d032d2e2..3ee426d23a4016 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/DriveInfoInternal.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/DriveInfoInternal.Unix.cs index 78ef95704fe9be..20e2cf9b9ab41c 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 90351282f6ce5c..5f53a5d99579a3 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 873c4eb5599d8b..6cc56e6acf00e4 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/Path.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs index 288cc12ec82376..23c35de1d521f3 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 4d652b6417f592..77dab304e15669 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/PasteArguments.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/PasteArguments.Unix.cs index 1a4d92850f8901..ccb810a6de860e 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 7b29d6f9ad0e40..422698ce088ab9 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 83a8cd76b0adfa..05764b08bac53c 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 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 406342ba268cc5..25b0e977e1143b 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 d3fbd9b2bddc9a..ca17a89876c425 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 978f3cebb61ad9..0b354c3b89d350 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 8d23f74cfe89b6..65f64536454663 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 @@ -5,7 +5,6 @@ using System.Diagnostics; 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/Utf8.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs index 7992cd52a0f79c..884dcf612c6e7d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs @@ -4,7 +4,6 @@ using System.Buffers; using System.Diagnostics; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #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 a1288394d70453..b147d9f23df324 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,10 +3,8 @@ // 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; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; 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 137b6775c89442..c6bca0f8af6dd9 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 @@ -5,7 +5,6 @@ using System.Diagnostics; using System.Numerics; using System.Runtime.Intrinsics.X86; -using System.Runtime.CompilerServices; #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 373f764efd7d0e..cf656bc1dc2d1c 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/PortableThreadPool.HillClimbing.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.HillClimbing.cs index 2e50906c0bb96f..0fa48e9d870fdc 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 { 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 6edf3dbd2b7105..e30253f900b756 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 { 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 7e70f3fe034676..b120265a05336b 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 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 902fcf2650e1da..35379f1f10283d 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 234b12bae50b23..f56414a8a7ab19 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 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 e97b1e9e82b3a4..2442d71c4170a1 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 d8822233f71690..ec137cdd87a1a1 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; 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 007b1269657900..5a0247cd4635d0 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 e74ce9fbe0ef58..ca4d98404c986f 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/SafeGPtrArrayHandle.cs b/src/mono/netcore/System.Private.CoreLib/src/Mono/SafeGPtrArrayHandle.cs index 2f8a550049284f..a0c394dab8568c 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 565e7cbf860a1f..10ac40a1a7ee53 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 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 6f9cd832813340..596c2c77ca8d3b 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 { 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 9f33a03ec0b5ab..1d1d02fb042ba1 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 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 9a18526a9ad6df..86a5b14b8ab6ca 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 dd0a3488212612..1276b759bf809e 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 88fcc05e750762..911499ea842e37 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 { 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 6f27c713ddf6e6..0bf59a99146bdf 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 2ef76dbdbc79f3..f3b741f8667367 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 0d0bdc64866331..da9981a4cc43e9 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; 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 c0b5a37a110933..1e3882d8ed4459 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; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs index 6b011450235d8f..0a28c73709420b 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs @@ -27,7 +27,6 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Text; namespace System.Reflection diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs index 88a1727cced3ca..45bd19b250551f 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs @@ -32,18 +32,11 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; using System.IO; -using System.Runtime.Serialization; using System.Globalization; using System.Runtime.CompilerServices; -using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Security; -using System.Security.Cryptography; -using System.Threading; namespace System.Reflection.Emit { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs index 6783ab497ea2a8..ac5c2874650977 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs @@ -32,13 +32,8 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Reflection.Emit; using System.Globalization; using System.Runtime.InteropServices; -using System.Diagnostics.SymbolStore; namespace System.Reflection.Emit { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs index a34d5920dbc923..2cf4fe9f7b7535 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorOnTypeBuilderInst.cs @@ -29,9 +29,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; using System.Globalization; -using System.Reflection; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs index eb8ba3849275b4..3b7921596eeef7 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs @@ -32,9 +32,6 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DerivedTypes.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DerivedTypes.Mono.cs index 7be3181fc7b1a2..a0d54a683420ac 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DerivedTypes.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DerivedTypes.Mono.cs @@ -29,13 +29,8 @@ #nullable disable #if MONO_FEATURE_SRE -using System.Reflection; -using System.Reflection.Emit; -using System.Collections; -using System.Runtime.CompilerServices; using System.Globalization; using System.Runtime.InteropServices; -using System.Runtime.Serialization; using System.Text; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILInfo.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILInfo.cs index e2cf318f7b309b..ef5e71476e3438 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILInfo.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILInfo.cs @@ -28,8 +28,6 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs index 7042ca8940fd78..6d3efae7843863 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs @@ -34,10 +34,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; using System.Text; -using System.Reflection; -using System.Reflection.Emit; using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.Mono.cs index 507f4c302ae16d..510473f4935d29 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.Mono.cs @@ -32,9 +32,6 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Reflection.Emit; using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.Mono.cs index 96c9d2cd9a2841..edfb3cde0fb89b 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.Mono.cs @@ -32,11 +32,6 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Reflection.Emit; -using System.Globalization; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EventOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EventOnTypeBuilderInst.cs index 44014905f44b8f..8eca4ede14b0e0 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EventOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EventOnTypeBuilderInst.cs @@ -29,10 +29,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; using System.Collections; -using System.Globalization; -using System.Reflection; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.Mono.cs index 17ef8ec60eb7c9..9622bc879ea880 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.Mono.cs @@ -32,11 +32,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Reflection.Emit; using System.Globalization; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs index 50b66e0311d1d5..2d3f08d155153e 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/FieldOnTypeBuilderInst.cs @@ -29,9 +29,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; using System.Globalization; -using System.Reflection; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs index ff90c6bc82e133..2bde022d239bf5 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs @@ -31,13 +31,8 @@ #nullable disable #if MONO_FEATURE_SRE -using System.Reflection; -using System.Reflection.Emit; -using System.Collections; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Globalization; -using System.Runtime.Serialization; namespace System.Reflection.Emit { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.Mono.cs index cbf4cf3aec8293..af881e07363c34 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.Mono.cs @@ -32,7 +32,6 @@ #nullable disable #if MONO_FEATURE_SRE -using System; using System.Collections.Generic; using System.Diagnostics.SymbolStore; using System.Runtime.InteropServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.Mono.cs index f15eaf10e2ced2..94bdf1d26881a6 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.Mono.cs @@ -33,12 +33,7 @@ // #nullable disable -using System; -using System.Reflection; -using System.Globalization; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Diagnostics.SymbolStore; namespace System.Reflection.Emit { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs index 30045d36c88f22..76a577a4129511 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs @@ -32,14 +32,8 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Reflection.Emit; using System.Globalization; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Diagnostics.SymbolStore; -using System.Collections.Generic; namespace System.Reflection.Emit { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs index 43e0242ce9de72..0ef9a73e99d896 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MethodOnTypeBuilderInst.cs @@ -29,9 +29,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; using System.Globalization; -using System.Reflection; using System.Text; using System.Runtime.InteropServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs index 3fbd2a4ee98c12..c9e6f1f7e4461f 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs @@ -32,13 +32,9 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Diagnostics.SymbolStore; using System.IO; using System.Globalization; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs index 812d0472dd272f..ce3dfe77f16390 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs @@ -33,9 +33,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; using System.Globalization; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Reflection diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.Mono.cs index f08aef59e1c020..3b0dbd164d5181 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.Mono.cs @@ -33,11 +33,6 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Reflection.Emit; -using System.Globalization; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.Mono.cs index a51afbbf79d8b2..78d9c6be13ac43 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.Mono.cs @@ -32,11 +32,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Reflection.Emit; using System.Globalization; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/PropertyOnTypeBuilderInst.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/PropertyOnTypeBuilderInst.cs index 3a02bca556d664..da83ae6087ba0b 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/PropertyOnTypeBuilderInst.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/PropertyOnTypeBuilderInst.cs @@ -29,9 +29,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System; using System.Globalization; -using System.Reflection; using System.Runtime.InteropServices; namespace System.Reflection.Emit diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs index f4a8bcbe2d1820..11831136454d9e 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs @@ -32,10 +32,6 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Reflection; -using System.Reflection.Emit; -using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs index 0e17ff33fc2b8b..be4c117f434ce6 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs @@ -33,16 +33,10 @@ #nullable disable #if MONO_FEATURE_SRE -using System; -using System.Text; -using System.Reflection; -using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Globalization; using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.SymbolStore; namespace System.Reflection.Emit { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs index 9ed7e44a4dd32d..5ac123dff05c95 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs @@ -33,12 +33,8 @@ #nullable disable #if MONO_FEATURE_SRE -using System.Reflection; -using System.Reflection.Emit; using System.Collections; -using System.Runtime.CompilerServices; using System.Globalization; -using System.Runtime.Serialization; using System.Text; using System.Runtime.InteropServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/UnmanagedMarshal.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/UnmanagedMarshal.cs index 8e979856ad4ca4..cf6bd60fa64643 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/UnmanagedMarshal.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/UnmanagedMarshal.cs @@ -32,9 +32,7 @@ #nullable disable #if MONO_FEATURE_SRE -using System.Reflection.Emit; using System.Runtime.InteropServices; -using System; namespace System.Reflection.Emit { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/MethodBase.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/MethodBase.Mono.cs index 7db4d6d3e1523e..325f7ab099099b 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/MethodBase.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/MethodBase.Mono.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; -using System.Reflection.Emit; namespace System.Reflection { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs index 1f955d6735f1fc..a7fff4fb28c84f 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.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; namespace System.Reflection diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.cs index 97c20ed88b2b79..627d4cae5791a9 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.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.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; namespace System.Reflection { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs index 0485d368915ca2..b6a58015e12f14 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs @@ -22,7 +22,6 @@ // #nullable disable -using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs index 11902e0f7fa2b1..063809177c8310 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.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.Generic; using System.Reflection; using System.Runtime.CompilerServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.Mono.cs index bfd7ce58d34c11..aad31f3620b8b1 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.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.IO; using System.Reflection; using System.Runtime.CompilerServices; diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.Mono.cs index b36730f7901fab..f3a3999778897f 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.Mono.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.Runtime.InteropServices { // Mono runtime relies on exact layout diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs index 5b4027c831df96..62c5110f1a378d 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs @@ -5,7 +5,6 @@ using System.Reflection; using System.Runtime.Serialization; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Text; namespace System diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs index 99484859696697..140bfcf50e83b7 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Security/DynamicSecurityMethodAttribute.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; - namespace System.Security { // DynamicSecurityMethodAttribute: diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/String.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/String.Mono.cs index 393efec176a24a..93be8996335861 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/String.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/String.Mono.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; -using Internal.Runtime.CompilerServices; namespace System { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Text/Utf8Span.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Text/Utf8Span.cs index f3b37c2e952d1f..e13bfe7350e09d 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Text/Utf8Span.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Text/Utf8Span.cs @@ -2,13 +2,9 @@ // 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.Buffers; using System.ComponentModel; -using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Text.Unicode; -using Internal.Runtime.CompilerServices; #pragma warning disable 0809 //warning CS0809: Obsolete member 'Utf8Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Type.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Type.Mono.cs index 67a34d1522660b..606d79a8061790 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Type.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Type.Mono.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.Text; -using System.IO; using System.Reflection; -using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Threading; namespace System diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Utf8String.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Utf8String.cs index 48a7caecb81b63..33d7709ea8dc7a 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Utf8String.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Utf8String.cs @@ -2,14 +2,10 @@ // 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.Buffers; using System.ComponentModel; -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Text; -using System.Text.Unicode; -using Internal.Runtime.CompilerServices; namespace System { diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/ValueType.cs b/src/mono/netcore/System.Private.CoreLib/src/System/ValueType.cs index 6218237cb20c66..82e2dd8ad16732 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/ValueType.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/ValueType.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.Reflection; using System.Runtime.CompilerServices; namespace System From b84f1624772da868a2cb780007a9eafaaf541364 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 26 Mar 2020 18:12:57 -0400 Subject: [PATCH 11/11] Fix a few issues --- .../src/System/Text/Unicode/Utf16Utility.Validation.cs | 1 + .../System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs | 1 + .../src/System/Text/Unicode/Utf8Utility.Transcoding.cs | 1 + .../src/System/Text/Unicode/Utf8Utility.Validation.cs | 1 + .../netcore/System.Private.CoreLib/src/System/Array.Mono.cs | 4 ++-- .../src/System/Diagnostics/StackTrace.Mono.cs | 2 +- 6 files changed, 7 insertions(+), 3 deletions(-) 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 65f64536454663..73bfa603f92528 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,6 +3,7 @@ // 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.Numerics; diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs index 884dcf612c6e7d..7992cd52a0f79c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs @@ -4,6 +4,7 @@ using System.Buffers; using System.Diagnostics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #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 b147d9f23df324..64f76fec691474 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 @@ -5,6 +5,7 @@ using System.Buffers; using System.Diagnostics; using System.Numerics; +using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; 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 c6bca0f8af6dd9..2d250e7d0ce714 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,6 +4,7 @@ using System.Diagnostics; using System.Numerics; +using System.Runtime.CompilerServices; using System.Runtime.Intrinsics.X86; #if SYSTEM_PRIVATE_CORELIB 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 10ac40a1a7ee53..f6c23ac0cbe695 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 @@ -522,14 +522,14 @@ internal ref byte GetRawArrayData() [Intrinsic] private void GetGenericValueImpl(int pos, out T value) { - Array? self = this; + Array self = this; GetGenericValue_icall(ref self, pos, out value); } [Intrinsic] private void SetGenericValueImpl(int pos, ref T value) { - Array? self = this; + Array self = this; SetGenericValue_icall(ref self, pos, ref value); } 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 9c020f58dcaea7..6b9be66ec6cf67 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) { - MonoStackFrame[]? frames = get_trace(e, skipFrames, needFileInfo); + MonoStackFrame[] frames = get_trace(e, skipFrames, needFileInfo); _numOfFrames = frames.Length; int foreignFrames;