From 19f03850cafa68cf396ecadf86e19df714b0a280 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 17 Jul 2024 06:44:53 -0400 Subject: [PATCH] Replace most corelib uses of Unsafe.SizeOf with sizeof(T) (#104923) Also suppress CS8500 globally rather than in hundreds of files individually and fix NoWarns that weren't inheriting global NoWarns. --- Directory.Build.props | 2 +- .../src/System/ArgIterator.cs | 1 - .../src/System/GC.CoreCLR.cs | 4 -- .../src/System/Reflection/RtFieldInfo.cs | 4 -- .../src/System/Runtime/DependentHandle.cs | 2 - .../ExceptionServices/InternalCalls.cs | 2 - .../InteropServices/GCHandle.CoreCLR.cs | 2 - .../CompilerHelpers/StartupCodeHelpers.cs | 2 - .../System/Runtime/CachedInterfaceDispatch.cs | 2 - .../src/System/Runtime/ExceptionHandling.cs | 9 +--- .../src/System/GC.NativeAot.cs | 8 --- .../System/Reflection/DynamicInvokeInfo.cs | 20 ++------ .../src/System/Reflection/EnumInfo.cs | 2 - .../InteropServices/ComWrappers.NativeAot.cs | 2 - .../InteropServices/Marshal.NativeAot.cs | 4 -- .../tools/Common/JitInterface/CorInfoImpl.cs | 2 - .../ILCompiler.Reflection.ReadyToRun.csproj | 2 +- src/coreclr/tools/r2rdump/R2RDump.csproj | 2 +- src/coreclr/tools/r2rtest/R2RTest.csproj | 2 +- .../Unix/System.Native/Interop.MountPoints.cs | 2 - .../Common/src/System/HexConverter.cs | 2 - .../src/System/IO/Archiving.Utils.Windows.cs | 2 - .../DotnetFuzzing/DotnetFuzzing.csproj | 2 +- .../src/LoggingEventSource.cs | 2 - .../System.Collections.Immutable.Tests.csproj | 2 +- .../src/System/Buffers/ArrayMemoryPool.cs | 2 - .../BsdIPv4GlobalStatistics.cs | 2 - .../BsdIpInterfaceProperties.cs | 2 - .../NetworkInformation/BsdNetworkInterface.cs | 2 - .../UnixIPGlobalProperties.cs | 2 - ...stem.Net.Primitives.UnitTests.Tests.csproj | 2 +- .../Net/Security/SslStreamPal.Windows.cs | 4 +- .../System.Net.Security.Unit.Tests.csproj | 2 +- .../ref/System.Numerics.Tensors.netcore.cs | 2 - .../Tensors/TensorPrimitives.Helpers.cs | 2 - .../TensorPrimitives.IAggregationOperator.cs | 50 +++++++++---------- .../TensorPrimitives.IBinaryOperator.cs | 10 ++-- .../TensorPrimitives.IIndexOfOperator.cs | 2 - ...TensorPrimitives.IStatefulUnaryOperator.cs | 2 - .../TensorPrimitives.ITernaryOperator.cs | 2 - ...ensorPrimitives.IUnaryOneToFourOperator.cs | 2 - ...TensorPrimitives.IUnaryOneToTwoOperator.cs | 2 - .../Common/TensorPrimitives.IUnaryOperator.cs | 8 ++- ...TensorPrimitives.IUnaryTwoToOneOperator.cs | 2 - .../Tensors/netcore/ReadOnlyTensorSpan.cs | 1 - .../Tensors/netcore/Tensor.Factory.cs | 1 - .../System/Numerics/Tensors/netcore/Tensor.cs | 1 - .../Tensors/netcore/TensorExtensions.cs | 1 - .../TensorPrimitives.ConvertHelpers.cs | 2 - .../netcore/TensorPrimitives.IndexOfMax.cs | 2 - .../TensorPrimitives.LeadingZeroCount.cs | 2 - .../netcore/TensorPrimitives.PopCount.cs | 2 - .../netcore/TensorPrimitives.Rotate.cs | 2 - .../TensorPrimitives.TrailingZeroCount.cs | 2 - .../Numerics/Tensors/netcore/TensorSpan.cs | 1 - .../Tensors/netcore/TensorSpanHelpers.T.cs | 3 -- .../Tensors/netcore/TensorSpanHelpers.cs | 2 - .../ref/System.Numerics.Vectors.cs | 4 -- .../src/System/Array.cs | 2 - .../src/System/Buffer.cs | 2 - .../Text/Base64Url/Base64UrlEncoder.cs | 2 - .../Collections/Generic/ArraySortHelper.cs | 3 +- .../System/Diagnostics/Tracing/EventSource.cs | 7 +-- .../src/System/Enum.EnumInfo.cs | 2 - .../System.Private.CoreLib/src/System/Enum.cs | 16 +++--- .../System/Globalization/CalendarData.Icu.cs | 10 ---- .../System/Globalization/CalendarData.Nls.cs | 2 - .../Globalization/CalendarData.Windows.cs | 2 - .../System/Globalization/CultureData.Nls.cs | 2 - .../src/System/IO/Path.cs | 2 - .../src/System/MemoryExtensions.cs | 12 ++--- .../src/System/Numerics/Vector.cs | 4 -- .../src/System/Numerics/Vector_1.cs | 6 --- .../src/System/ReadOnlySpan.cs | 1 - .../System/Reflection/ConstructorInvoker.cs | 6 --- .../MethodBaseInvoker.Constructor.cs | 2 - .../System/Reflection/MethodBaseInvoker.cs | 6 --- .../src/System/Reflection/MethodInvoker.cs | 6 --- .../System/Runtime/CompilerServices/Unsafe.cs | 4 -- .../System/Runtime/InteropServices/Marshal.cs | 2 - .../InteropServices/Marshalling/ComVariant.cs | 4 +- .../Runtime/InteropServices/MemoryMarshal.cs | 14 +++--- .../Runtime/InteropServices/SafeBuffer.cs | 2 - .../Runtime/Intrinsics/ISimdVector_2.cs | 4 -- .../Intrinsics/SimdVectorExtensions.cs | 2 - .../System/Runtime/Intrinsics/Vector128.cs | 4 -- .../System/Runtime/Intrinsics/Vector128_1.cs | 6 --- .../System/Runtime/Intrinsics/Vector256.cs | 4 -- .../System/Runtime/Intrinsics/Vector256_1.cs | 6 --- .../System/Runtime/Intrinsics/Vector512.cs | 4 -- .../System/Runtime/Intrinsics/Vector512_1.cs | 6 --- .../src/System/Runtime/Intrinsics/Vector64.cs | 4 -- .../System/Runtime/Intrinsics/Vector64_1.cs | 6 --- .../System/SearchValues/Any1SearchValues.cs | 6 +-- .../System/SearchValues/Any2SearchValues.cs | 6 +-- .../System/SearchValues/Any3SearchValues.cs | 6 +-- .../System/SearchValues/Any4SearchValues.cs | 6 +-- .../System/SearchValues/Any5SearchValues.cs | 6 +-- .../SearchValues/IndexOfAnyAsciiSearcher.cs | 2 - .../System/SearchValues/ProbabilisticMap.cs | 2 - .../SearchValues/ProbabilisticMapState.cs | 2 - .../System.Private.CoreLib/src/System/Span.cs | 1 - .../src/System/SpanHelpers.Packed.cs | 2 - .../src/System/SpanHelpers.T.cs | 10 ++-- .../src/System/SpanHelpers.cs | 2 - .../src/System/Threading/Tasks/Task.cs | 2 - .../src/System/TypedReference.cs | 2 - .../src/System/Xml/XmlBinaryWriter.cs | 20 ++++---- .../src/System/Xml/XmlBufferReader.cs | 2 - .../System.Private.Uri.Unit.Tests.csproj | 4 +- .../JSImportGenerator.csproj | 2 +- .../ComInterfaceGenerator.csproj | 2 +- .../LibraryImportGenerator.csproj | 2 +- .../ref/System.Runtime.Intrinsics.cs | 16 ------ .../System.Dynamic.Runtime.Tests.csproj | 4 +- .../UnsafeTests.cs | 2 - .../System.Runtime.Tests/System/GCTests.cs | 2 +- .../Security/Cryptography/PemEncoding.cs | 2 - .../OpenSslX509ChainProcessor.cs | 2 - .../StorePal.Android.AndroidKeyStore.cs | 4 -- .../StorePal.Android.TrustedStore.cs | 2 - .../Text/RegularExpressions/Regex.Replace.cs | 2 - .../Text/RegularExpressions/RegexCharClass.cs | 2 - .../RegularExpressions/RegexReplacement.cs | 2 - .../Threading/Tasks/Parallel.ForEachAsync.cs | 2 - .../src/System/ArgIterator.cs | 4 -- .../src/System/Buffer.Mono.cs | 2 - .../src/System/Enum.Mono.cs | 2 - .../src/System/Reflection/RuntimeFieldInfo.cs | 4 -- .../Runtime/InteropServices/Marshal.Mono.cs | 2 - .../src/System/TypedReference.Mono.cs | 2 - .../BrowserDebugProxy/MonoSDBHelper.cs | 8 +-- .../tests/debugger-test/debugger-test.csproj | 2 +- .../AspNetCoreServer/AspNetCoreServer.csproj | 2 +- .../BlazorClient/BlazorClient.csproj | 4 +- .../WasmOnAspNetCore/Shared/Shared.csproj | 2 +- .../WasmBrowserClient.csproj | 2 +- .../Android.Device_Emulator.gRPC.Test.csproj | 2 +- .../InteropTestsWebsite.csproj | 4 +- ...icrosoft.Diagnostics.NETCore.Client.csproj | 2 +- 140 files changed, 112 insertions(+), 442 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 61edda987ed..821b777a6d2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -388,7 +388,7 @@ strict;nullablePublicOnly true - $(NoWarn),CS8969 + $(NoWarn);CS8500;CS8969 portable true diff --git a/src/coreclr/System.Private.CoreLib/src/System/ArgIterator.cs b/src/coreclr/System.Private.CoreLib/src/System/ArgIterator.cs index d49d1dcb270..608412751f8 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/ArgIterator.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/ArgIterator.cs @@ -58,7 +58,6 @@ namespace System [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ArgIterator_Init2")] private static partial void Init(ArgIterator* thisPtr, IntPtr cookie, void* ptr); -#pragma warning disable CS8500 // Takes a pointer to a managed type // Fetch an argument as a typed referece, advance the iterator. // Throws an exception if past end of argument list [CLSCompliant(false)] diff --git a/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs index 998dcc8340c..9a970480fba 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs @@ -790,9 +790,7 @@ namespace System // for debug builds we always want to call AllocateNewArray to detect AllocateNewArray bugs #if !DEBUG // small arrays are allocated using `new[]` as that is generally faster. -#pragma warning disable 8500 // sizeof of managed types if (length < 2048 / sizeof(T)) -#pragma warning restore 8500 { return new T[length]; } @@ -892,9 +890,7 @@ namespace System Configurations = new Dictionary() }; -#pragma warning disable CS8500 // takes address of managed type _EnumerateConfigurationValues(&context, &ConfigCallback); -#pragma warning restore CS8500 return context.Configurations!; } diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs index 9bd2298eb93..7bddbfe81ce 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs @@ -93,9 +93,7 @@ namespace System.Reflection throw new ArgumentException(SR.Arg_TypedReference_Null); // Passing TypedReference by reference is easier to make correct in native code -#pragma warning disable CS8500 // Takes a pointer to a managed type return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, &obj, (RuntimeType?)DeclaringType); -#pragma warning restore CS8500 } [DebuggerStepThrough] @@ -111,9 +109,7 @@ namespace System.Reflection throw new ArgumentException(SR.Arg_TypedReference_Null); // Passing TypedReference by reference is easier to make correct in native code -#pragma warning disable CS8500 // Takes a pointer to a managed type RuntimeFieldHandle.SetValueDirect(this, (RuntimeType)FieldType, &obj, value, (RuntimeType?)DeclaringType); -#pragma warning restore CS8500 } public override RuntimeFieldHandle FieldHandle => new RuntimeFieldHandle(this); diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/DependentHandle.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/DependentHandle.cs index 53819b2cc59..8fb031b15a3 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/DependentHandle.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/DependentHandle.cs @@ -253,9 +253,7 @@ namespace System.Runtime // This optimization is the same that is used in GCHandle in RELEASE mode. // This is not used in DEBUG builds as the runtime performs additional checks. // The logic below is the inlined copy of ObjectFromHandle in the unmanaged runtime. -#pragma warning disable 8500 // address of managed types private static unsafe object? InternalGetTarget(IntPtr dependentHandle) => *(object*)dependentHandle; -#pragma warning restore 8500 #endif [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/InternalCalls.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/InternalCalls.cs index 228f58c0ea4..1dc4d91c396 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/InternalCalls.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/InternalCalls.cs @@ -23,7 +23,6 @@ namespace System.Runtime.ExceptionServices [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ResumeAtInterceptionLocation")] internal static unsafe partial void ResumeAtInterceptionLocation(void* pvRegDisplay); -#pragma warning disable CS8500 [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "CallCatchFunclet")] internal static unsafe partial IntPtr RhpCallCatchFunclet( ObjectHandleOnStack exceptionObj, byte* pHandlerIP, void* pvRegDisplay, EH.ExInfo* exInfo); @@ -38,7 +37,6 @@ namespace System.Runtime.ExceptionServices [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AppendExceptionStackFrame")] internal static unsafe partial void RhpAppendExceptionStackFrame(ObjectHandleOnStack exceptionObj, IntPtr ip, UIntPtr sp, int flags, EH.ExInfo* exInfo); -#pragma warning restore CS8500 [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "EHEnumInitFromStackFrameIterator")] [return: MarshalAs(UnmanagedType.Bool)] diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.CoreCLR.cs index 1238b029598..622cf863cf3 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.CoreCLR.cs @@ -46,9 +46,7 @@ namespace System.Runtime.InteropServices [MethodImpl(MethodImplOptions.InternalCall)] internal static extern object? InternalGet(IntPtr handle); #else -#pragma warning disable 8500 // address of managed types internal static unsafe object? InternalGet(IntPtr handle) => *(object*)handle; -#pragma warning restore 8500 #endif [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/src/coreclr/nativeaot/Common/src/Internal/Runtime/CompilerHelpers/StartupCodeHelpers.cs b/src/coreclr/nativeaot/Common/src/Internal/Runtime/CompilerHelpers/StartupCodeHelpers.cs index 6d9c043416f..039b586c01e 100644 --- a/src/coreclr/nativeaot/Common/src/Internal/Runtime/CompilerHelpers/StartupCodeHelpers.cs +++ b/src/coreclr/nativeaot/Common/src/Internal/Runtime/CompilerHelpers/StartupCodeHelpers.cs @@ -206,7 +206,6 @@ namespace Internal.Runtime.CompilerHelpers nint blockAddr = MethodTable.SupportsRelativePointers ? (nint)ReadRelPtr32(pBlock) : *pBlock; if ((blockAddr & GCStaticRegionConstants.Uninitialized) == GCStaticRegionConstants.Uninitialized) { -#pragma warning disable CS8500 // takes address of managed type object? obj = null; RuntimeImports.RhAllocateNewObject( new IntPtr(blockAddr & ~GCStaticRegionConstants.Mask), @@ -234,7 +233,6 @@ namespace Internal.Runtime.CompilerHelpers // Update the base pointer to point to the pinned object *pBlock = *(IntPtr*)&obj; -#pragma warning restore CS8500 } currentBase++; diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs index afb4c9a509f..7a242497f30 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs @@ -15,9 +15,7 @@ namespace System.Runtime private static unsafe IntPtr RhpCidResolve(IntPtr callerTransitionBlockParam, IntPtr pCell) { IntPtr locationOfThisPointer = callerTransitionBlockParam + TransitionBlock.GetThisOffset(); -#pragma warning disable 8500 // address of managed types object pObject = *(object*)locationOfThisPointer; -#pragma warning restore 8500 IntPtr dispatchResolveTarget = RhpCidResolve_Worker(pObject, pCell); return dispatchResolveTarget; } diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs index 42401da222e..f74e394df85 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs @@ -279,12 +279,11 @@ namespace System.Runtime isFirstFrame = false; } #else -#pragma warning disable CS8500 fixed (EH.ExInfo* pExInfo = &exInfo) { InternalCalls.RhpAppendExceptionStackFrame(ObjectHandleOnStack.Create(ref exception), ip, sp, flags, pExInfo); } -#pragma warning restore CS8500 + // Clear flags only if we called the function isFirstRethrowFrame = false; isFirstFrame = false; @@ -686,13 +685,11 @@ namespace System.Runtime if (unwoundReversePInvoke) { object exceptionObj = exInfo.ThrownException; -#pragma warning disable CS8500 fixed (EH.ExInfo* pExInfo = &exInfo) { InternalCalls.RhpCallCatchFunclet( ObjectHandleOnStack.Create(ref exceptionObj), null, exInfo._frameIter.RegisterSet, pExInfo); } -#pragma warning restore CS8500 } else { @@ -922,13 +919,11 @@ namespace System.Runtime InternalCalls.RhpCallCatchFunclet( exceptionObj, pCatchHandler, frameIter.RegisterSet, ref exInfo); #else // NATIVEAOT -#pragma warning disable CS8500 fixed (EH.ExInfo* pExInfo = &exInfo) { InternalCalls.RhpCallCatchFunclet( ObjectHandleOnStack.Create(ref exceptionObj), pCatchHandler, frameIter.RegisterSet, pExInfo); } -#pragma warning restore CS8500 #endif // NATIVEAOT // currently, RhpCallCatchFunclet will resume after the catch Debug.Assert(false, "unreachable"); @@ -1209,12 +1204,10 @@ namespace System.Runtime #if NATIVEAOT InternalCalls.RhpCallFinallyFunclet(pFinallyHandler, exInfo._frameIter.RegisterSet); #else // NATIVEAOT -#pragma warning disable CS8500 fixed (EH.ExInfo* pExInfo = &exInfo) { InternalCalls.RhpCallFinallyFunclet(pFinallyHandler, exInfo._frameIter.RegisterSet, pExInfo); } -#pragma warning restore CS8500 #endif // NATIVEAOT exInfo._idxCurClause = MaxTryRegionIdx; } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/GC.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/GC.NativeAot.cs index 0ee16609157..7f49242cc5f 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/GC.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/GC.NativeAot.cs @@ -695,9 +695,7 @@ namespace System Configurations = new Dictionary() }; -#pragma warning disable CS8500 // takes address of managed type RuntimeImports.RhEnumerateConfigurationValues(&context, &ConfigCallback); -#pragma warning restore CS8500 return context.Configurations!; } @@ -810,9 +808,7 @@ namespace System // for debug builds we always want to call AllocateNewArray to detect AllocateNewArray bugs #if !DEBUG // small arrays are allocated using `new[]` as that is generally faster. -#pragma warning disable 8500 // sizeof of managed types if (length < 2048 / sizeof(T)) -#pragma warning restore 8500 { return new T[length]; } @@ -832,9 +828,7 @@ namespace System throw new OverflowException(); T[]? array = null; -#pragma warning disable CS8500 // takes address of managed type RuntimeImports.RhAllocateNewArray(MethodTable.Of(), (uint)length, (uint)flags, &array); -#pragma warning restore CS8500 if (array == null) throw new OutOfMemoryException(); @@ -861,9 +855,7 @@ namespace System throw new OverflowException(); T[]? array = null; -#pragma warning disable CS8500 // takes address of managed type RuntimeImports.RhAllocateNewArray(MethodTable.Of(), (uint)length, (uint)flags, &array); -#pragma warning restore CS8500 if (array == null) throw new OutOfMemoryException(); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs index 6ddac7c3d3d..45bc2f9e199 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs @@ -365,9 +365,7 @@ namespace System.Reflection else if (argCount == 1) { ByReference br = ByReference.Create(ref parameters[0]); -#pragma warning disable CS8500 void* pByrefStorage = &br; -#pragma warning restore CS8500 // Since no copy of args is required, pass 'parameters' for both arguments. CheckArguments(parameters, pByrefStorage, parameters); @@ -410,9 +408,7 @@ namespace System.Reflection IntPtr* pStorage = stackalloc IntPtr[2 * argCount]; NativeMemory.Clear(pStorage, (nuint)(2 * argCount) * (nuint)sizeof(IntPtr)); -#pragma warning disable 8500 void* pByRefStorage = (ByReference*)(pStorage + argCount); -#pragma warning restore 8500 GCFrameRegistration regArgStorage = new((void**)pStorage, (uint)argCount, areByRefs: false); GCFrameRegistration regByRefStorage = new((void**)pByRefStorage, (uint)argCount, areByRefs: true); @@ -461,9 +457,7 @@ namespace System.Reflection IntPtr* pStorage = stackalloc IntPtr[2 * argCount]; NativeMemory.Clear(pStorage, (nuint)(2 * argCount) * (nuint)sizeof(IntPtr)); -#pragma warning disable 8500 void* pByRefStorage = (ByReference*)(pStorage + argCount); -#pragma warning restore 8500 GCFrameRegistration regArgStorage = new((void**)pStorage, (uint)argCount, areByRefs: false); GCFrameRegistration regByRefStorage = new((void**)pByRefStorage, (uint)argCount, areByRefs: true); @@ -501,9 +495,7 @@ namespace System.Reflection StackAllocatedArguments argStorage = default; Span copyOfParameters = ((Span)argStorage._args).Slice(0, _argumentCount); StackAllocatedByRefs byrefStorage = default; -#pragma warning disable CS8500 void* pByRefStorage = (ByReference*)&byrefStorage; -#pragma warning restore CS8500 CheckArguments(copyOfParameters, pByRefStorage, parameters, binderBundle); @@ -535,9 +527,7 @@ namespace System.Reflection StackAllocatedArguments argStorage = default; Span copyOfParameters = ((Span)argStorage._args).Slice(0, _argumentCount); StackAllocatedByRefs byrefStorage = default; -#pragma warning disable CS8500 void* pByRefStorage = (ByReference*)&byrefStorage; -#pragma warning restore CS8500 CheckArguments(copyOfParameters, pByRefStorage, parameters); @@ -562,9 +552,7 @@ namespace System.Reflection Debug.Assert(_argumentCount <= MaxStackAllocArgCount); StackAllocatedByRefs byrefStorage = default; -#pragma warning disable CS8500 void* pByRefStorage = (ByReference*)&byrefStorage; -#pragma warning restore CS8500 // Since no copy of args is required, pass 'parameters' for both arguments. CheckArguments(parameters, pByRefStorage, parameters); @@ -686,10 +674,10 @@ namespace System.Reflection copyOfParameters[i] = arg!; -#pragma warning disable 8500, 9094 +#pragma warning disable 9094 ((ByReference*)byrefParameters)[i] = new ByReference(ref (argumentInfo.Transform & Transform.Reference) != 0 ? ref Unsafe.As(ref copyOfParameters[i]) : ref arg.GetRawData()); -#pragma warning restore 8500, 9094 +#pragma warning restore 9094 } } @@ -763,10 +751,10 @@ namespace System.Reflection copyOfParameters[i] = arg; -#pragma warning disable 8500, 9094 +#pragma warning disable 9094 ((ByReference*)byrefParameters)[i] = new ByReference(ref (argumentInfo.Transform & Transform.Reference) != 0 ? ref Unsafe.As(ref copyOfParameters[i]) : ref arg.GetRawData()); -#pragma warning restore 8500, 9094 +#pragma warning restore 9094 } } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/EnumInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/EnumInfo.cs index 59d2c53ae95..71f1c69ffe5 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/EnumInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/EnumInfo.cs @@ -9,8 +9,6 @@ using System.Runtime; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Reflection { public abstract class EnumInfo diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs index 374ad0d8cd0..f8547cb408f 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs @@ -429,10 +429,8 @@ namespace System.Runtime.InteropServices private static bool IsRootedCallback(IntPtr pObj) { // We are paused in the GC, so this is safe. -#pragma warning disable CS8500 // Takes a pointer to a managed type ManagedObjectWrapperHolder* holder = (ManagedObjectWrapperHolder*)&pObj; return holder->_wrapper->IsRooted; -#pragma warning restore CS8500 } private readonly ManagedObjectWrapper* _wrapper; diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs index 117756b6633..ff98d77ee09 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs @@ -260,9 +260,7 @@ namespace System.Runtime.InteropServices // Compat note: CLR wouldn't bother with a range check. If someone does this, // they're likely taking dependency on some CLR implementation detail quirk. -#pragma warning disable 8500 // sizeof of managed types ArgumentOutOfRangeException.ThrowIfGreaterThan(checked(ofs + sizeof(T)), size, nameof(ofs)); -#pragma warning restore 8500 IntPtr nativeBytes = AllocCoTaskMem(size); NativeMemory.Clear((void*)nativeBytes, (nuint)size); @@ -340,9 +338,7 @@ namespace System.Runtime.InteropServices // Compat note: CLR wouldn't bother with a range check. If someone does this, // they're likely taking dependency on some CLR implementation detail quirk. -#pragma warning disable 8500 // sizeof of managed types ArgumentOutOfRangeException.ThrowIfGreaterThan(checked(ofs + sizeof(T)), size, nameof(ofs)); -#pragma warning restore 8500 IntPtr nativeBytes = AllocCoTaskMem(size); NativeMemory.Clear((void*)nativeBytes, (nuint)size); diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 974f5b5a87d..89cc55191d5 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -350,11 +350,9 @@ namespace Internal.JitInterface IntPtr exception; IntPtr nativeEntry; uint codeSize; -#pragma warning disable CS8500 // takes address of managed type var result = JitCompileMethod(out exception, _jit, (IntPtr)(&_this), _unmanagedCallbacks, ref methodInfo, (uint)CorJitFlag.CORJIT_FLAG_CALL_GETJITFLAGS, out nativeEntry, out codeSize); -#pragma warning restore CS8500 if (exception != IntPtr.Zero) { if (_lastException != null) diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ILCompiler.Reflection.ReadyToRun.csproj b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ILCompiler.Reflection.ReadyToRun.csproj index 34a1cfed346..f60794a8abf 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ILCompiler.Reflection.ReadyToRun.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ILCompiler.Reflection.ReadyToRun.csproj @@ -10,7 +10,7 @@ netstandard2.0 false - 8002,NU1701 + $(NoWarn);8002;NU1701 win-x64;win-x86 $(RuntimeBinDir) AnyCPU;x64 diff --git a/src/coreclr/tools/r2rdump/R2RDump.csproj b/src/coreclr/tools/r2rdump/R2RDump.csproj index 9459b4d8769..225f74285cd 100644 --- a/src/coreclr/tools/r2rdump/R2RDump.csproj +++ b/src/coreclr/tools/r2rdump/R2RDump.csproj @@ -9,7 +9,7 @@ true $(NetCoreAppToolCurrent) false - 8002,NU1701 + $(NoWarn);8002;NU1701 win-x64;win-x86 $(RuntimeBinDir)/R2RDump false diff --git a/src/coreclr/tools/r2rtest/R2RTest.csproj b/src/coreclr/tools/r2rtest/R2RTest.csproj index c304c492e66..361dd3d4590 100644 --- a/src/coreclr/tools/r2rtest/R2RTest.csproj +++ b/src/coreclr/tools/r2rtest/R2RTest.csproj @@ -4,7 +4,7 @@ true Exe $(NetCoreAppToolCurrent) - 8002,NU1701 + $(NoWarn);8002;NU1701 AnyCPU $(RuntimeBinDir)\R2RTest false 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 7a7a537a71c..3ac98d62f74 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 @@ -7,8 +7,6 @@ using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // takes address of managed type - internal static partial class Interop { internal static partial class Sys diff --git a/src/libraries/Common/src/System/HexConverter.cs b/src/libraries/Common/src/System/HexConverter.cs index 10ef243c631..bcc64dcf1a7 100644 --- a/src/libraries/Common/src/System/HexConverter.cs +++ b/src/libraries/Common/src/System/HexConverter.cs @@ -193,10 +193,8 @@ namespace System } return result.ToString(); #else -#pragma warning disable CS8500 // takes address of managed type return string.Create(bytes.Length * 2, (RosPtr: (IntPtr)(&bytes), casing), static (chars, args) => EncodeToUtf16(*(ReadOnlySpan*)args.RosPtr, chars, args.casing)); -#pragma warning restore CS8500 #endif } diff --git a/src/libraries/Common/src/System/IO/Archiving.Utils.Windows.cs b/src/libraries/Common/src/System/IO/Archiving.Utils.Windows.cs index e3d69185a7c..d11a9eb856f 100644 --- a/src/libraries/Common/src/System/IO/Archiving.Utils.Windows.cs +++ b/src/libraries/Common/src/System/IO/Archiving.Utils.Windows.cs @@ -69,7 +69,6 @@ namespace System.IO string.Empty; } -#pragma warning disable CS8500 // takes address of managed type ReadOnlySpan tmpPath = path; // avoid address exposing the span and impacting the other code in the method that uses it return string.Create(appendPathSeparator ? tmpPath.Length + 1 : tmpPath.Length, (appendPathSeparator, RosPtr: (IntPtr)(&tmpPath)), static (dest, state) => { @@ -84,7 +83,6 @@ namespace System.IO // all slashes should be forward slashes. dest.Replace('\\', '/'); }); -#pragma warning restore CS8500 } } } diff --git a/src/libraries/Fuzzing/DotnetFuzzing/DotnetFuzzing.csproj b/src/libraries/Fuzzing/DotnetFuzzing/DotnetFuzzing.csproj index fa571fbbf96..6db5eb5a9ed 100644 --- a/src/libraries/Fuzzing/DotnetFuzzing/DotnetFuzzing.csproj +++ b/src/libraries/Fuzzing/DotnetFuzzing/DotnetFuzzing.csproj @@ -7,7 +7,7 @@ enable enable True - CA2252 + $(NoWarn);CA2252 true diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs index 66a95042e84..62100ee9723 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs @@ -569,9 +569,7 @@ namespace Microsoft.Extensions.Logging.EventSource else { eventData.DataPointer = (IntPtr)Unsafe.AsPointer(ref value); -#pragma warning disable 8500 // sizeof of managed types eventData.Size = sizeof(T); -#pragma warning restore 8500 } } } diff --git a/src/libraries/System.Collections.Immutable/tests/System.Collections.Immutable.Tests.csproj b/src/libraries/System.Collections.Immutable/tests/System.Collections.Immutable.Tests.csproj index cd83bd88de7..cc324a605ee 100644 --- a/src/libraries/System.Collections.Immutable/tests/System.Collections.Immutable.Tests.csproj +++ b/src/libraries/System.Collections.Immutable/tests/System.Collections.Immutable.Tests.csproj @@ -1,6 +1,6 @@ - 0436 + $(NoWarn);0436 $(NetCoreAppCurrent);$(NetFrameworkMinimum) true diff --git a/src/libraries/System.Memory/src/System/Buffers/ArrayMemoryPool.cs b/src/libraries/System.Memory/src/System/Buffers/ArrayMemoryPool.cs index aa0fb4de26b..0ceca4f5d70 100644 --- a/src/libraries/System.Memory/src/System/Buffers/ArrayMemoryPool.cs +++ b/src/libraries/System.Memory/src/System/Buffers/ArrayMemoryPool.cs @@ -11,12 +11,10 @@ namespace System.Buffers public sealed override unsafe IMemoryOwner Rent(int minimumBufferSize = -1) { -#pragma warning disable 8500 // sizeof of managed types if (minimumBufferSize == -1) minimumBufferSize = 1 + (4095 / sizeof(T)); else if (((uint)minimumBufferSize) > Array.MaxLength) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.minimumBufferSize); -#pragma warning restore 8500 return new ArrayMemoryPoolBuffer(minimumBufferSize); } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs index fc77f10c6cc..b38825b3e67 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; -#pragma warning disable 8500 // taking address of managed types - namespace System.Net.NetworkInformation { internal sealed class BsdIPv4GlobalStatistics : IPGlobalStatistics diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.cs index 6f0ef7f4a26..8ce6f541bf0 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; -#pragma warning disable 8500 // taking address of managed types - namespace System.Net.NetworkInformation { internal sealed class BsdIpInterfaceProperties : UnixIPInterfaceProperties diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdNetworkInterface.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdNetworkInterface.cs index 643c847c40c..a2742c035ce 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdNetworkInterface.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdNetworkInterface.cs @@ -5,8 +5,6 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // taking address of managed types - namespace System.Net.NetworkInformation { internal sealed class BsdNetworkInterface : UnixNetworkInterface diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixIPGlobalProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixIPGlobalProperties.cs index f26aa577aa9..2ab82486ec9 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixIPGlobalProperties.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixIPGlobalProperties.cs @@ -8,8 +8,6 @@ using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; -#pragma warning disable 8500 // taking address of managed types - namespace System.Net.NetworkInformation { internal abstract class UnixIPGlobalProperties : IPGlobalProperties diff --git a/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj b/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj index aaf31e99cbe..411c86ffecc 100644 --- a/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj +++ b/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj @@ -1,7 +1,7 @@ true - 169,649 + $(NoWarn);169;649 ../../src/Resources/Strings.resx $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs index c0dca1dc3a0..02458d63779 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs @@ -63,7 +63,7 @@ namespace System.Net.Security SSPIWrapper.GetVerifyPackageInfo(GlobalSSPI.SSPISecureChannel, SecurityPackage, true); } - private static void SetAlpn(ref InputSecurityBuffers inputBuffers, List alpn, Span localBuffer) + private static unsafe void SetAlpn(ref InputSecurityBuffers inputBuffers, List alpn, Span localBuffer) { if (alpn.Count == 1 && alpn[0] == SslApplicationProtocol.Http11) { @@ -84,7 +84,7 @@ namespace System.Net.Security else { int protocolLength = Interop.Sec_Application_Protocols.GetProtocolLength(alpn); - int bufferLength = Unsafe.SizeOf() + protocolLength; + int bufferLength = sizeof(Interop.Sec_Application_Protocols) + protocolLength; Span alpnBuffer = bufferLength <= localBuffer.Length ? localBuffer : new byte[bufferLength]; Interop.Sec_Application_Protocols.SetProtocols(alpnBuffer, alpn, protocolLength); diff --git a/src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj b/src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj index 261b61f16d6..d6a5bc1eb22 100644 --- a/src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj +++ b/src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj @@ -7,7 +7,7 @@ Dependencies are broken via Fakes. Since we are referencing netstandard, the real types can conflict with the ones imported. We are disabling the "Type conflicts with the imported type CS0436 warning" for these types of projects. --> - 436 + $(NoWarn);436 $(NoWarn);3021;SYSLIB0057 $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-android diff --git a/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.netcore.cs b/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.netcore.cs index 7bb347b333d..cd0397b4c50 100644 --- a/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.netcore.cs +++ b/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.netcore.cs @@ -4,8 +4,6 @@ // Changes to this file must follow the https://aka.ms/api-review process. // ------------------------------------------------------------------------------ -#pragma warning disable 8500 // address / sizeof of managed types - namespace System.Buffers { public readonly partial struct NIndex : System.IEquatable diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.Helpers.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.Helpers.cs index 5e4e89b6174..3547fdcfdfc 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.Helpers.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.Helpers.cs @@ -6,8 +6,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { /// Performs primitive tensor operations over spans of memory. diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IAggregationOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IAggregationOperator.cs index b91d9d2038f..df03ad1634d 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IAggregationOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IAggregationOperator.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives @@ -2278,28 +2276,28 @@ namespace System.Numerics.Tensors [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128 CreateAlignmentMaskVector128(int count) { - if (Unsafe.SizeOf() == 1) + if (sizeof(T) == 1) { return Vector128.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), (uint)(count * 64)); } - if (Unsafe.SizeOf() == 2) + if (sizeof(T) == 2) { return Vector128.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), (uint)(count * 32)); } - if (Unsafe.SizeOf() == 4) + if (sizeof(T) == 4) { return Vector128.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), (uint)(count * 16)); } - Debug.Assert(Unsafe.SizeOf() == 8); + Debug.Assert(sizeof(T) == 8); { return Vector128.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), @@ -2314,28 +2312,28 @@ namespace System.Numerics.Tensors [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256 CreateAlignmentMaskVector256(int count) { - if (Unsafe.SizeOf() == 1) + if (sizeof(T) == 1) { return Vector256.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), (uint)(count * 64)); } - if (Unsafe.SizeOf() == 2) + if (sizeof(T) == 2) { return Vector256.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), (uint)(count * 32)); } - if (Unsafe.SizeOf() == 4) + if (sizeof(T) == 4) { return Vector256.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), (uint)(count * 16)); } - Debug.Assert(Unsafe.SizeOf() == 8); + Debug.Assert(sizeof(T) == 8); { return Vector256.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), @@ -2350,28 +2348,28 @@ namespace System.Numerics.Tensors [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector512 CreateAlignmentMaskVector512(int count) { - if (Unsafe.SizeOf() == 1) + if (sizeof(T) == 1) { return Vector512.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), (uint)(count * 64)); } - if (Unsafe.SizeOf() == 2) + if (sizeof(T) == 2) { return Vector512.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), (uint)(count * 32)); } - if (Unsafe.SizeOf() == 4) + if (sizeof(T) == 4) { return Vector512.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), (uint)(count * 16)); } - Debug.Assert(Unsafe.SizeOf() == 8); + Debug.Assert(sizeof(T) == 8); { return Vector512.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), @@ -2386,28 +2384,28 @@ namespace System.Numerics.Tensors [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128 CreateRemainderMaskVector128(int count) { - if (Unsafe.SizeOf() == 1) + if (sizeof(T) == 1) { return Vector128.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), (uint)(count * 64) + 48); // last 16 bytes in the row } - if (Unsafe.SizeOf() == 2) + if (sizeof(T) == 2) { return Vector128.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), (uint)(count * 32) + 24); // last 8 shorts in the row } - if (Unsafe.SizeOf() == 4) + if (sizeof(T) == 4) { return Vector128.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), (uint)(count * 16) + 12); // last 4 ints in the row } - Debug.Assert(Unsafe.SizeOf() == 8); + Debug.Assert(sizeof(T) == 8); { return Vector128.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt64Mask_8x9)), @@ -2422,28 +2420,28 @@ namespace System.Numerics.Tensors [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256 CreateRemainderMaskVector256(int count) { - if (Unsafe.SizeOf() == 1) + if (sizeof(T) == 1) { return Vector256.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), (uint)(count * 64) + 32); // last 32 bytes in the row } - if (Unsafe.SizeOf() == 2) + if (sizeof(T) == 2) { return Vector256.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), (uint)(count * 32) + 16); // last 16 shorts in the row } - if (Unsafe.SizeOf() == 4) + if (sizeof(T) == 4) { return Vector256.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), (uint)(count * 16) + 8); // last 8 ints in the row } - Debug.Assert(Unsafe.SizeOf() == 8); + Debug.Assert(sizeof(T) == 8); { return Vector256.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt64Mask_8x9)), @@ -2458,28 +2456,28 @@ namespace System.Numerics.Tensors [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector512 CreateRemainderMaskVector512(int count) { - if (Unsafe.SizeOf() == 1) + if (sizeof(T) == 1) { return Vector512.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), (uint)(count * 64)); } - if (Unsafe.SizeOf() == 2) + if (sizeof(T) == 2) { return Vector512.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), (uint)(count * 32)); } - if (Unsafe.SizeOf() == 4) + if (sizeof(T) == 4) { return Vector512.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), (uint)(count * 16)); } - Debug.Assert(Unsafe.SizeOf() == 8); + Debug.Assert(sizeof(T) == 8); { return Vector512.LoadUnsafe( ref Unsafe.As(ref MemoryMarshal.GetReference(RemainderUInt64Mask_8x9)), diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IBinaryOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IBinaryOperator.cs index 0ec37a519ec..2d14ee18552 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IBinaryOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IBinaryOperator.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives @@ -2740,27 +2738,27 @@ namespace System.Numerics.Tensors { // We need to do log2(count) operations to compute the total sum - if (Unsafe.SizeOf() == 1) + if (sizeof(T) == 1) { x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsByte(), Vector128.Create((byte)8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7)).As()); x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsByte(), Vector128.Create((byte)4, 5, 6, 7, 0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15)).As()); x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsByte(), Vector128.Create((byte)2, 3, 0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)).As()); x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsByte(), Vector128.Create((byte)1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)).As()); } - else if (Unsafe.SizeOf() == 2) + else if (sizeof(T) == 2) { x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsInt16(), Vector128.Create(4, 5, 6, 7, 0, 1, 2, 3)).As()); x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsInt16(), Vector128.Create(2, 3, 0, 1, 4, 5, 6, 7)).As()); x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsInt16(), Vector128.Create(1, 0, 2, 3, 4, 5, 6, 7)).As()); } - else if (Unsafe.SizeOf() == 4) + else if (sizeof(T) == 4) { x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsInt32(), Vector128.Create(2, 3, 0, 1)).As()); x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsInt32(), Vector128.Create(1, 0, 3, 2)).As()); } else { - Debug.Assert(Unsafe.SizeOf() == 8); + Debug.Assert(sizeof(T) == 8); x = TAggregate.Invoke(x, Vector128.Shuffle(x.AsInt64(), Vector128.Create(1, 0)).As()); } diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IIndexOfOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IIndexOfOperator.cs index a90b8aaa2a3..09492ac64eb 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IIndexOfOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IIndexOfOperator.cs @@ -5,8 +5,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IStatefulUnaryOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IStatefulUnaryOperator.cs index fc77a63a4c7..dde2e4c8a0b 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IStatefulUnaryOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IStatefulUnaryOperator.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.ITernaryOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.ITernaryOperator.cs index a36e52c108e..d868b106ce5 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.ITernaryOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.ITernaryOperator.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOneToFourOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOneToFourOperator.cs index 0fa883b2254..1be0a2304ec 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOneToFourOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOneToFourOperator.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOneToTwoOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOneToTwoOperator.cs index 4715ced3337..9d2805e5317 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOneToTwoOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOneToTwoOperator.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOperator.cs index c2c22950c57..86c99536a36 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryOperator.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives @@ -90,7 +88,7 @@ namespace System.Numerics.Tensors nuint remainder = (uint)x.Length; - if (Vector512.IsHardwareAccelerated && Vector512.IsSupported && Vector512.IsSupported && TUnaryOperator.Vectorizable && Unsafe.SizeOf() == Unsafe.SizeOf()) + if (Vector512.IsHardwareAccelerated && Vector512.IsSupported && Vector512.IsSupported && TUnaryOperator.Vectorizable && sizeof(TInput) == sizeof(TOutput)) { if (remainder >= (uint)Vector512.Count) { @@ -108,7 +106,7 @@ namespace System.Numerics.Tensors return; } - if (Vector256.IsHardwareAccelerated && Vector256.IsSupported && Vector256.IsSupported && TUnaryOperator.Vectorizable && Unsafe.SizeOf() == Unsafe.SizeOf()) + if (Vector256.IsHardwareAccelerated && Vector256.IsSupported && Vector256.IsSupported && TUnaryOperator.Vectorizable && sizeof(TInput) == sizeof(TOutput)) { if (remainder >= (uint)Vector256.Count) { @@ -126,7 +124,7 @@ namespace System.Numerics.Tensors return; } - if (Vector128.IsHardwareAccelerated && Vector128.IsSupported && Vector128.IsSupported && TUnaryOperator.Vectorizable && Unsafe.SizeOf() == Unsafe.SizeOf()) + if (Vector128.IsHardwareAccelerated && Vector128.IsSupported && Vector128.IsSupported && TUnaryOperator.Vectorizable && sizeof(TInput) == sizeof(TOutput)) { if (remainder >= (uint)Vector128.Count) { diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryTwoToOneOperator.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryTwoToOneOperator.cs index e16c4ebca3a..d33582328e3 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryTwoToOneOperator.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IUnaryTwoToOneOperator.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan.cs index 686cde6cf7b..7fd72d6e47a 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan.cs @@ -12,7 +12,6 @@ using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; #pragma warning disable 0809 //warning CS0809: Obsolete member 'ReadOnlyTensorSpan.Equals(object)' overrides non-obsolete member 'object.Equals(object)' -#pragma warning disable 8500 // address / sizeof of managed types namespace System.Numerics.Tensors { diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.Factory.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.Factory.cs index afb134a33d8..64fe3017133 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.Factory.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.Factory.cs @@ -8,7 +8,6 @@ using Microsoft.VisualBasic; #pragma warning disable CS8601 // Possible null reference assignment. #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. -#pragma warning disable 8500 // address / sizeof of managed types namespace System.Numerics.Tensors { diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs index 34311af8aa9..7dd06173c61 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs @@ -14,7 +14,6 @@ using static System.Runtime.InteropServices.JavaScript.JSType; #pragma warning disable CS8601 // Possible null reference assignment. #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. -#pragma warning disable 8500 // address / sizeof of managed types namespace System.Numerics.Tensors { diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorExtensions.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorExtensions.cs index 7c7c093a4fa..8abbb94ecab 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorExtensions.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorExtensions.cs @@ -14,7 +14,6 @@ using System.Runtime.Serialization; #pragma warning disable CS8601 // Possible null reference assignment. #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. -#pragma warning disable 8500 // address / sizeof of managed types namespace System.Numerics.Tensors { diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.ConvertHelpers.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.ConvertHelpers.cs index cd5bf6808e7..873293a2bef 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.ConvertHelpers.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.ConvertHelpers.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IndexOfMax.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IndexOfMax.cs index 1b584d05a53..a9f869fc2f5 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IndexOfMax.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IndexOfMax.cs @@ -7,8 +7,6 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.LeadingZeroCount.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.LeadingZeroCount.cs index ab51042925f..11018124a59 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.LeadingZeroCount.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.LeadingZeroCount.cs @@ -7,8 +7,6 @@ using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.PopCount.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.PopCount.cs index 1ea141baac4..3a68ce36029 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.PopCount.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.PopCount.cs @@ -7,8 +7,6 @@ using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.Wasm; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Rotate.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Rotate.cs index e22ee978c3a..9406c7977e7 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Rotate.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Rotate.cs @@ -3,8 +3,6 @@ using System.Runtime.Intrinsics; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.TrailingZeroCount.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.TrailingZeroCount.cs index 156bafd3697..ac4e7e4a4f5 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.TrailingZeroCount.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.TrailingZeroCount.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Numerics.Tensors { public static partial class TensorPrimitives diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs index ded02108289..66a7940256f 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs @@ -12,7 +12,6 @@ using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; #pragma warning disable 0809 //warning CS0809: Obsolete member 'TensorSpan.Equals(object)' overrides non-obsolete member 'object.Equals(object)' -#pragma warning disable 8500 // address / sizeof of managed types namespace System.Numerics.Tensors { diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpanHelpers.T.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpanHelpers.T.cs index 4e5103a0acd..f16e0c033d9 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpanHelpers.T.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpanHelpers.T.cs @@ -4,9 +4,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; - -#pragma warning disable 8500 // sizeof of managed types - namespace System.Numerics.Tensors { internal static partial class TensorSpanHelpers // .T diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpanHelpers.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpanHelpers.cs index b726ab37871..313f4556e5a 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpanHelpers.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpanHelpers.cs @@ -8,8 +8,6 @@ using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; -#pragma warning disable 8500 // sizeof of managed types - namespace System.Numerics.Tensors { internal static partial class TensorSpanHelpers diff --git a/src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs b/src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs index fba0c8dbcd4..a8f2b8e1b8f 100644 --- a/src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs +++ b/src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs @@ -321,14 +321,12 @@ namespace System.Numerics public static bool LessThanOrEqualAny(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector LessThanOrEqual(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector LessThan(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe System.Numerics.Vector Load(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Numerics.Vector LoadAligned(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Numerics.Vector LoadAlignedNonTemporal(T* source) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static System.Numerics.Vector LoadUnsafe(ref readonly T source) { throw null; } [System.CLSCompliantAttribute(false)] public static System.Numerics.Vector LoadUnsafe(ref readonly T source, nuint elementOffset) { throw null; } @@ -407,14 +405,12 @@ namespace System.Numerics [System.CLSCompliantAttribute(false)] public static System.Numerics.Vector ShiftRightLogical(System.Numerics.Vector value, int shiftCount) { throw null; } public static System.Numerics.Vector SquareRoot(System.Numerics.Vector value) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe void Store(this System.Numerics.Vector source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAligned(this System.Numerics.Vector source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAlignedNonTemporal(this System.Numerics.Vector source, T* destination) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static void StoreUnsafe(this System.Numerics.Vector source, ref T destination) { throw null; } [System.CLSCompliantAttribute(false)] public static void StoreUnsafe(this System.Numerics.Vector source, ref T destination, nuint elementOffset) { throw null; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Array.cs b/src/libraries/System.Private.CoreLib/src/System/Array.cs index 84bd5ed20ee..49e00054498 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Array.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Array.cs @@ -12,8 +12,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Internal.Runtime; -#pragma warning disable 8500 // sizeof of managed types - namespace System { [Serializable] diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffer.cs b/src/libraries/System.Private.CoreLib/src/System/Buffer.cs index 25b6965ee2d..2a1e2a02999 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffer.cs @@ -150,7 +150,6 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static unsafe void Memmove(ref T destination, ref T source, nuint elementCount) { -#pragma warning disable 8500 // sizeof of managed types if (!RuntimeHelpers.IsReferenceOrContainsReferences()) { // Blittable memmove @@ -167,7 +166,6 @@ namespace System ref Unsafe.As(ref source), elementCount * (nuint)sizeof(T)); } -#pragma warning restore 8500 } // The maximum block size to for __BulkMoveWithWriteBarrier FCall. This is required to avoid GC starvation. diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Url/Base64UrlEncoder.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Url/Base64UrlEncoder.cs index ef95097f206..a0ab9243810 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Url/Base64UrlEncoder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Url/Base64UrlEncoder.cs @@ -154,14 +154,12 @@ namespace System.Buffers.Text #if NET int encodedLength = GetEncodedLength(source.Length); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type return string.Create(encodedLength, (IntPtr)(&source), static (buffer, spanPtr) => { ReadOnlySpan source = *(ReadOnlySpan*)spanPtr; EncodeToChars(source, buffer, out _, out int charsWritten); Debug.Assert(buffer.Length == charsWritten, $"The source length: {source.Length}, bytes written: {charsWritten}"); }); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type #else char[] destination = new char[GetEncodedLength(source.Length)]; EncodeToChars(source, destination, out _, out int charsWritten); diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs index 14bbd3f3b35..9c336d924c7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs @@ -500,9 +500,8 @@ namespace System.Collections.Generic { Swap(ref leftRef, ref nextToLastRef); } -#pragma warning disable 8500 // sizeof of managed types + return (int)((nint)Unsafe.ByteOffset(ref zeroRef, ref leftRef) / sizeof(T)); -#pragma warning restore 8500 } private static void HeapSort(Span keys) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index 9ac5b97bc42..c48a86fe329 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -1121,12 +1121,7 @@ namespace System.Diagnostics.Tracing } // Returns the object as a IntPtr - safe when only used for logging - internal static unsafe nint ObjectIDForEvents(object? o) - { -#pragma warning disable CS8500 // takes address of managed type - return *(nint*)&o; -#pragma warning restore CS8500 - } + internal static unsafe nint ObjectIDForEvents(object? o) => *(nint*)&o; #pragma warning restore 1591 diff --git a/src/libraries/System.Private.CoreLib/src/System/Enum.EnumInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Enum.EnumInfo.cs index 2f349d8cb59..07a205ce301 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Enum.EnumInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Enum.EnumInfo.cs @@ -5,8 +5,6 @@ using System.Diagnostics; using System.Numerics; using System.Runtime.InteropServices; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System { public abstract partial class Enum diff --git a/src/libraries/System.Private.CoreLib/src/System/Enum.cs b/src/libraries/System.Private.CoreLib/src/System/Enum.cs index 2f1c5f47494..052b4b22c89 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Enum.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Enum.cs @@ -14,8 +14,6 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // Allow taking address of managed types - namespace System { /// Provides the base class for enumerations. @@ -172,7 +170,7 @@ namespace System /// The underlying value for which we're searching. /// The name of the value if found; otherwise, . [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static string? GetNameInlined(EnumInfo enumInfo, TStorage value) + private static unsafe string? GetNameInlined(EnumInfo enumInfo, TStorage value) where TStorage : struct, INumber { string[] names = enumInfo.Names; @@ -182,7 +180,7 @@ namespace System // in the array is where the corresponding name is stored. if (enumInfo.ValuesAreSequentialFromZero) { - if (Unsafe.SizeOf() <= sizeof(uint)) + if (sizeof(TStorage) <= sizeof(uint)) { // Special-case types types that are <= sizeof(int), as we can then eliminate a bounds check on the array. uint uint32Value = uint.CreateTruncating(value); @@ -1541,20 +1539,20 @@ namespace System { fixed (byte* ptr = &data) { - return string.Create(Unsafe.SizeOf() * 2, (IntPtr)ptr, (destination, intptr) => + return string.Create(sizeof(TStorage) * 2, (IntPtr)ptr, (destination, intptr) => { bool success = TryFormatNumberAsHex(ref *(byte*)intptr, destination, out int charsWritten); Debug.Assert(success); - Debug.Assert(charsWritten == Unsafe.SizeOf() * 2); + Debug.Assert(charsWritten == sizeof(TStorage) * 2); }); } } /// Tries to format the data for the underlying value as hex into the destination span. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool TryFormatNumberAsHex(ref byte data, Span destination, out int charsWritten) where TStorage : struct + private static unsafe bool TryFormatNumberAsHex(ref byte data, Span destination, out int charsWritten) where TStorage : struct { - if (Unsafe.SizeOf() * 2 <= destination.Length) + if (sizeof(TStorage) * 2 <= destination.Length) { if (typeof(TStorage) == typeof(byte) || typeof(TStorage) == typeof(sbyte)) @@ -1604,7 +1602,7 @@ namespace System throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } - charsWritten = Unsafe.SizeOf() * 2; + charsWritten = sizeof(TStorage) * 2; return true; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs index 7a3f8f3d894..22af9e6927d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs @@ -144,9 +144,7 @@ namespace System.Globalization IcuEnumCalendarsData callbackContext = default; callbackContext.Results = new List(); callbackContext.DisallowDuplicates = true; -#pragma warning disable CS8500 // takes address of managed type bool result = EnumCalendarInfo(localeName, calendarId, dataType, &callbackContext); -#pragma warning restore CS8500 if (result) { List datePatternsList = callbackContext.Results; @@ -372,9 +370,7 @@ namespace System.Globalization IcuEnumCalendarsData callbackContext = default; callbackContext.Results = new List(); -#pragma warning disable CS8500 // takes address of managed type bool result = EnumCalendarInfo(localeName, calendarId, dataType, &callbackContext); -#pragma warning restore CS8500 if (result) { // the month-name arrays are expected to have 13 elements. If ICU only returns 12, add an @@ -422,9 +418,7 @@ namespace System.Globalization IcuEnumCalendarsData callbackContext = default; callbackContext.Results = new List(); -#pragma warning disable CS8500 // takes address of managed type bool result = EnumCalendarInfo(localeName, calendarId, dataType, &callbackContext); -#pragma warning restore CS8500 if (result) { calendarData = callbackContext.Results.ToArray(); @@ -433,7 +427,6 @@ namespace System.Globalization return result; } -#pragma warning disable CS8500 // takes address of managed type private static unsafe bool EnumCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, IcuEnumCalendarsData* callbackContext) { #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS @@ -443,7 +436,6 @@ namespace System.Globalization return Interop.Globalization.EnumCalendarInfo(&EnumCalendarInfoCallback, localeName, calendarId, dataType, (IntPtr)callbackContext); #endif } -#pragma warning restore CS8500 [UnmanagedCallersOnly] private static unsafe void EnumCalendarInfoCallback(char* calendarStringPtr, IntPtr context) @@ -451,9 +443,7 @@ namespace System.Globalization try { ReadOnlySpan calendarStringSpan = MemoryMarshal.CreateReadOnlySpanFromNullTerminated(calendarStringPtr); -#pragma warning disable 8500 IcuEnumCalendarsData* callbackContext = (IcuEnumCalendarsData*)context; -#pragma warning restore 8500 if (callbackContext->DisallowDuplicates) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs index 54677a079b6..d277773ce96 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs @@ -6,8 +6,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // taking address of managed type - namespace System.Globalization { internal sealed partial class CalendarData diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Windows.cs index b1e8cefd6f4..64a284f231e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Windows.cs @@ -5,8 +5,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; -#pragma warning disable 8500 // taking address of managed type - namespace System.Globalization { internal sealed partial class CalendarData diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs index 5ac62150c3c..a69b67f87c5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs @@ -8,8 +8,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; -#pragma warning disable 8500 // taking address of managed type - namespace System.Globalization { internal sealed partial class CultureData diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Path.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.cs index 7b828df7720..eb619fc7d29 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Path.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Path.cs @@ -731,7 +731,6 @@ namespace System.IO { Debug.Assert(first.Length > 0 && second.Length > 0 && third.Length > 0 && fourth.Length > 0, "should have dealt with empty paths"); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type var state = new JoinInternalState { ReadOnlySpanPtr1 = (IntPtr)(&first), @@ -782,7 +781,6 @@ namespace System.IO Debug.Assert(fourth.Length == destination.Length); fourth.CopyTo(destination); }); -#pragma warning restore CS8500 } private struct JoinInternalState // used to avoid rooting ValueTuple`7 diff --git a/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs b/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs index cb5e969dd1c..dccae42b3ef 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs @@ -11,8 +11,6 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Text; -#pragma warning disable 8500 // sizeof of managed types - namespace System { /// @@ -3986,32 +3984,32 @@ namespace System /// The value for which to search. /// The number of times was found in the . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int Count(this ReadOnlySpan span, T value) where T : IEquatable? + public static unsafe int Count(this ReadOnlySpan span, T value) where T : IEquatable? { if (RuntimeHelpers.IsBitwiseEquatable()) { - if (Unsafe.SizeOf() == sizeof(byte)) + if (sizeof(T) == sizeof(byte)) { return SpanHelpers.CountValueType( ref Unsafe.As(ref MemoryMarshal.GetReference(span)), Unsafe.BitCast(value), span.Length); } - else if (Unsafe.SizeOf() == sizeof(short)) + else if (sizeof(T) == sizeof(short)) { return SpanHelpers.CountValueType( ref Unsafe.As(ref MemoryMarshal.GetReference(span)), Unsafe.BitCast(value), span.Length); } - else if (Unsafe.SizeOf() == sizeof(int)) + else if (sizeof(T) == sizeof(int)) { return SpanHelpers.CountValueType( ref Unsafe.As(ref MemoryMarshal.GetReference(span)), Unsafe.BitCast(value), span.Length); } - else if (Unsafe.SizeOf() == sizeof(long)) + else if (sizeof(T) == sizeof(long)) { return SpanHelpers.CountValueType( ref Unsafe.As(ref MemoryMarshal.GetReference(span)), diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs index c4fbc114dc9..f14756fe777 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs @@ -1501,7 +1501,6 @@ namespace System.Numerics return false; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. /// The source from which the vector will be loaded. @@ -1540,7 +1539,6 @@ namespace System.Numerics [Intrinsic] [CLSCompliant(false)] public static Vector LoadAlignedNonTemporal(T* source) => LoadAligned(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. @@ -2444,7 +2442,6 @@ namespace System.Numerics return result; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. /// The vector that will be stored. @@ -2483,7 +2480,6 @@ namespace System.Numerics [Intrinsic] [CLSCompliant(false)] public static void StoreAlignedNonTemporal(this Vector source, T* destination) => source.StoreAligned(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector_1.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector_1.cs index 0910caadcf3..e70943b53d8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector_1.cs @@ -136,7 +136,6 @@ namespace System.Numerics get => Vector.Create(Scalar.AllBitsSet); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets the number of that are in a . /// The type of the current instance () is not supported. public static int Count @@ -148,7 +147,6 @@ namespace System.Numerics return sizeof(Vector) / sizeof(T); } } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets a new with the elements set to their index. /// The type of the vector () is not supported. @@ -931,7 +929,6 @@ namespace System.Numerics /// static bool ISimdVector, T>.LessThanOrEqualAny(Vector left, Vector right) => Vector.LessThanOrEqualAny(left, right); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector ISimdVector, T>.Load(T* source) => Vector.Load(source); @@ -940,7 +937,6 @@ namespace System.Numerics /// static Vector ISimdVector, T>.LoadAlignedNonTemporal(T* source) => Vector.LoadAlignedNonTemporal(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector ISimdVector, T>.LoadUnsafe(ref readonly T source) => Vector.LoadUnsafe(in source); @@ -1008,7 +1004,6 @@ namespace System.Numerics /// static Vector ISimdVector, T>.Sqrt(Vector vector) => Vector.SquareRoot(vector); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.Store(Vector source, T* destination) => source.Store(destination); @@ -1017,7 +1012,6 @@ namespace System.Numerics /// static void ISimdVector, T>.StoreAlignedNonTemporal(Vector source, T* destination) => source.StoreAlignedNonTemporal(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.StoreUnsafe(Vector vector, ref T destination) => vector.StoreUnsafe(ref destination); diff --git a/src/libraries/System.Private.CoreLib/src/System/ReadOnlySpan.cs b/src/libraries/System.Private.CoreLib/src/System/ReadOnlySpan.cs index 0b029d02fe3..8ebb44f40bf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ReadOnlySpan.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ReadOnlySpan.cs @@ -11,7 +11,6 @@ using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; #pragma warning disable 0809 // Obsolete member 'Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' -#pragma warning disable 8500 // address / sizeof of managed types namespace System { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs index c70f5230c79..47766e9428f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs @@ -290,15 +290,11 @@ namespace System.Reflection } StackAllocatedByRefs byrefs = default; -#pragma warning disable CS8500 IntPtr* pByRefFixedStorage = (IntPtr*)&byrefs; -#pragma warning restore CS8500 for (int i = 0; i < _argCount; i++) { -#pragma warning disable CS8500 *(ByReference*)(pByRefFixedStorage + i) = (_invokerArgFlags[i] & InvokerArgFlags.IsValueType) != 0 ? -#pragma warning restore CS8500 ByReference.Create(ref copyOfArgs[i]!.GetRawData()) : ByReference.Create(ref copyOfArgs[i]); } @@ -370,9 +366,7 @@ namespace System.Reflection object? arg = arguments[i]; shouldCopyBack[i] = CheckArgument(ref arg, i); copyOfArgs[i] = arg; - #pragma warning disable CS8500 *(ByReference*)(pByRefStorage + i) = (_invokerArgFlags[i] & InvokerArgFlags.IsValueType) != 0 ? - #pragma warning restore CS8500 ByReference.Create(ref Unsafe.AsRef(pStorage + i).GetRawData()) : ByReference.Create(ref Unsafe.AsRef(pStorage + i)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.Constructor.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.Constructor.cs index 2202fabfdc8..61ce60ff5bd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.Constructor.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.Constructor.cs @@ -40,9 +40,7 @@ namespace System.Reflection for (int i = 0; i < argCount; i++) { -#pragma warning disable CS8500 *(ByReference*)(pByRefStorage + i) = (_invokerArgFlags[i] & InvokerArgFlags.IsValueType) != 0 ? -#pragma warning restore CS8500 ByReference.Create(ref Unsafe.AsRef(pStorage + i).GetRawData()) : ByReference.Create(ref Unsafe.AsRef(pStorage + i)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs index 6a1b94d5085..ecb353c8e6b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs @@ -160,15 +160,11 @@ namespace System.Reflection } StackAllocatedByRefs byrefs = default; -#pragma warning disable CS8500 IntPtr* pByRefFixedStorage = (IntPtr*)&byrefs; -#pragma warning restore CS8500 for (int i = 0; i < _argCount; i++) { -#pragma warning disable CS8500 *(ByReference*)(pByRefFixedStorage + i) = (_invokerArgFlags[i] & InvokerArgFlags.IsValueType) != 0 ? -#pragma warning restore CS8500 ByReference.Create(ref copyOfArgs[i]!.GetRawData()) : ByReference.Create(ref copyOfArgs[i]); } @@ -256,9 +252,7 @@ namespace System.Reflection for (int i = 0; i < _argCount; i++) { - #pragma warning disable CS8500 *(ByReference*)(pByRefStorage + i) = (_invokerArgFlags[i] & InvokerArgFlags.IsValueType) != 0 ? - #pragma warning restore CS8500 ByReference.Create(ref Unsafe.AsRef(pStorage + i).GetRawData()) : ByReference.Create(ref Unsafe.AsRef(pStorage + i)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs index 5b4b9048b23..d7d8ff6e01d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs @@ -343,15 +343,11 @@ namespace System.Reflection } StackAllocatedByRefs byrefs = default; -#pragma warning disable CS8500 IntPtr* pByRefFixedStorage = (IntPtr*)&byrefs; -#pragma warning restore CS8500 for (int i = 0; i < _argCount; i++) { -#pragma warning disable CS8500 *(ByReference*)(pByRefFixedStorage + i) = (_invokerArgFlags[i] & InvokerArgFlags.IsValueType) != 0 ? -#pragma warning restore CS8500 ByReference.Create(ref copyOfArgs[i]!.GetRawData()) : ByReference.Create(ref copyOfArgs[i]); } @@ -423,9 +419,7 @@ namespace System.Reflection object? arg = arguments[i]; shouldCopyBack[i] = CheckArgument(ref arg, i); copyOfArgs[i] = arg; - #pragma warning disable CS8500 *(ByReference*)(pByRefStorage + i) = (_invokerArgFlags[i] & InvokerArgFlags.IsValueType) != 0 ? - #pragma warning restore CS8500 ByReference.Create(ref Unsafe.AsRef(pStorage + i).GetRawData()) : ByReference.Create(ref Unsafe.AsRef(pStorage + i)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/Unsafe.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/Unsafe.cs index 286435be8cc..a19092f4a43 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/Unsafe.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/Unsafe.cs @@ -7,13 +7,9 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.Versioning; -// // The implementations of most the methods in this file are provided as intrinsics. // In CoreCLR, the body of the functions are replaced by the EE with unsafe code. See see getILIntrinsicImplementationForUnsafe for details. // In AOT compilers, see Internal.IL.Stubs.UnsafeIntrinsics for details. -// - -#pragma warning disable 8500 // address / sizeof of managed types namespace System.Runtime.CompilerServices { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index b22cc78e6ed..862a8bae43c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -176,9 +176,7 @@ namespace System.Runtime.InteropServices // Unsafe.AsPointer is safe since array must be pinned void* pRawData = Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(arr)); -#pragma warning disable 8500 // sizeof of managed types return (IntPtr)((byte*)pRawData + (uint)index * (nuint)sizeof(T)); -#pragma warning restore 8500 } public static IntPtr OffsetOf(string fieldName) => OffsetOf(typeof(T), fieldName); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs index 3b9640e285a..1abac3537a1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs @@ -379,7 +379,7 @@ namespace System.Runtime.InteropServices.Marshalling public static unsafe ComVariant CreateRaw(VarEnum vt, T rawValue) where T : unmanaged { - ArgumentOutOfRangeException.ThrowIfGreaterThan(Unsafe.SizeOf(), sizeof(UnionTypes), nameof(T)); + ArgumentOutOfRangeException.ThrowIfGreaterThan(sizeof(T), sizeof(UnionTypes), nameof(T)); if (vt == VarEnum.VT_DECIMAL) { throw new ArgumentException(SR.ComVariant_VT_DECIMAL_NotSupported_CreateRaw, nameof(vt)); @@ -571,7 +571,7 @@ namespace System.Runtime.InteropServices.Marshalling public unsafe ref T GetRawDataRef() where T : unmanaged { - ArgumentOutOfRangeException.ThrowIfGreaterThan(Unsafe.SizeOf(), sizeof(UnionTypes), nameof(T)); + ArgumentOutOfRangeException.ThrowIfGreaterThan(sizeof(T), sizeof(UnionTypes), nameof(T)); if (typeof(T) == typeof(decimal)) { throw new ArgumentException(SR.ComVariant_VT_DECIMAL_NotSupported_RawDataRef, nameof(T)); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs index 0b0da448e4e..d849a0d58c7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs @@ -7,8 +7,6 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; -#pragma warning disable 8500 // sizeof of managed types - namespace System.Runtime.InteropServices { /// @@ -113,7 +111,7 @@ namespace System.Runtime.InteropServices /// Thrown when or contains pointers. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Span Cast(Span span) + public static unsafe Span Cast(Span span) where TFrom : struct where TTo : struct { @@ -124,8 +122,8 @@ namespace System.Runtime.InteropServices // Use unsigned integers - unsigned division by constant (especially by power of 2) // and checked casts are faster and smaller. - uint fromSize = (uint)Unsafe.SizeOf(); - uint toSize = (uint)Unsafe.SizeOf(); + uint fromSize = (uint)sizeof(TFrom); + uint toSize = (uint)sizeof(TTo); uint fromLength = (uint)span.Length; int toLength; if (fromSize == toSize) @@ -168,7 +166,7 @@ namespace System.Runtime.InteropServices /// Thrown when or contains pointers. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan Cast(ReadOnlySpan span) + public static unsafe ReadOnlySpan Cast(ReadOnlySpan span) where TFrom : struct where TTo : struct { @@ -179,8 +177,8 @@ namespace System.Runtime.InteropServices // Use unsigned integers - unsigned division by constant (especially by power of 2) // and checked casts are faster and smaller. - uint fromSize = (uint)Unsafe.SizeOf(); - uint toSize = (uint)Unsafe.SizeOf(); + uint fromSize = (uint)sizeof(TFrom); + uint toSize = (uint)sizeof(TTo); uint fromLength = (uint)span.Length; int toLength; if (fromSize == toSize) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeBuffer.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeBuffer.cs index 76858298feb..afb120d07f7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeBuffer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeBuffer.cs @@ -405,9 +405,7 @@ namespace System.Runtime.InteropServices if (RuntimeHelpers.IsReferenceOrContainsReferences()) throw new ArgumentException(SR.Argument_NeedStructWithNoRefs); -#pragma warning disable 8500 // sizeof of managed types return (uint)sizeof(T); -#pragma warning restore 8500 } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs index eaa9a524be1..520f854a9c3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs @@ -399,7 +399,6 @@ namespace System.Runtime.Intrinsics /// The type of the elements in the vector () is not supported. static abstract bool LessThanOrEqualAny(TSelf left, TSelf right); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The source from which the vector will be loaded. /// The vector loaded from . @@ -425,7 +424,6 @@ namespace System.Runtime.Intrinsics /// This method may bypass the cache on certain platforms. /// The type of () is not supported. static virtual TSelf LoadAlignedNonTemporal(T* source) => TSelf.LoadAligned(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The source from which the vector will be loaded. @@ -584,7 +582,6 @@ namespace System.Runtime.Intrinsics /// The type of () is not supported. static abstract TSelf Sqrt(TSelf vector); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The vector that will be stored. /// The destination at which will be stored. @@ -610,7 +607,6 @@ namespace System.Runtime.Intrinsics /// This method may bypass the cache on certain platforms. /// The type of () is not supported. static virtual void StoreAlignedNonTemporal(TSelf source, T* destination) => TSelf.StoreAligned(source, destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The vector that will be stored. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/SimdVectorExtensions.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/SimdVectorExtensions.cs index f483b9ccb6d..74b3e7729a5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/SimdVectorExtensions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/SimdVectorExtensions.cs @@ -64,7 +64,6 @@ namespace System.Runtime.Intrinsics return TVector.GetElement(vector, index); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the vector. /// The type of the elements in the vector. @@ -101,7 +100,6 @@ namespace System.Runtime.Intrinsics { TVector.StoreAlignedNonTemporal(source, destination); } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the vector. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs index 2011025c045..5328f6ce296 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs @@ -2077,7 +2077,6 @@ namespace System.Runtime.Intrinsics || Vector64.LessThanOrEqualAny(left._upper, right._upper); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. /// The source from which the vector will be loaded. @@ -2116,7 +2115,6 @@ namespace System.Runtime.Intrinsics [Intrinsic] [CLSCompliant(false)] public static unsafe Vector128 LoadAlignedNonTemporal(T* source) => LoadAligned(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. @@ -3160,7 +3158,6 @@ namespace System.Runtime.Intrinsics ); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. /// The vector that will be stored. @@ -3199,7 +3196,6 @@ namespace System.Runtime.Intrinsics [Intrinsic] [CLSCompliant(false)] public static unsafe void StoreAlignedNonTemporal(this Vector128 source, T* destination) => source.StoreAligned(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// /// Stores to lower 64 bits of to memory destination of [] diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs index d6118dbc844..d387e0377e0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs @@ -42,7 +42,6 @@ namespace System.Runtime.Intrinsics get => Vector128.Create(Scalar.AllBitsSet); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets the number of that are in a . /// The type of the vector () is not supported. public static int Count @@ -54,7 +53,6 @@ namespace System.Runtime.Intrinsics return Vector128.Size / sizeof(T); } } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets a new with the elements set to their index. /// The type of the vector () is not supported. @@ -578,7 +576,6 @@ namespace System.Runtime.Intrinsics /// static bool ISimdVector, T>.LessThanOrEqualAny(Vector128 left, Vector128 right) => Vector128.LessThanOrEqualAny(left, right); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector128 ISimdVector, T>.Load(T* source) => Vector128.Load(source); @@ -587,7 +584,6 @@ namespace System.Runtime.Intrinsics /// static Vector128 ISimdVector, T>.LoadAlignedNonTemporal(T* source) => Vector128.LoadAlignedNonTemporal(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector128 ISimdVector, T>.LoadUnsafe(ref readonly T source) => Vector128.LoadUnsafe(in source); @@ -655,7 +651,6 @@ namespace System.Runtime.Intrinsics /// static Vector128 ISimdVector, T>.Sqrt(Vector128 vector) => Vector128.Sqrt(vector); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.Store(Vector128 source, T* destination) => source.Store(destination); @@ -664,7 +659,6 @@ namespace System.Runtime.Intrinsics /// static void ISimdVector, T>.StoreAlignedNonTemporal(Vector128 source, T* destination) => source.StoreAlignedNonTemporal(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.StoreUnsafe(Vector128 vector, ref T destination) => vector.StoreUnsafe(ref destination); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs index d1dde486f58..c85772d3f59 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs @@ -1993,7 +1993,6 @@ namespace System.Runtime.Intrinsics || Vector128.LessThanOrEqualAny(left._upper, right._upper); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. /// The source from which the vector will be loaded. @@ -2032,7 +2031,6 @@ namespace System.Runtime.Intrinsics [Intrinsic] [CLSCompliant(false)] public static Vector256 LoadAlignedNonTemporal(T* source) => LoadAligned(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. @@ -3044,7 +3042,6 @@ namespace System.Runtime.Intrinsics ); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. /// The vector that will be stored. @@ -3083,7 +3080,6 @@ namespace System.Runtime.Intrinsics [Intrinsic] [CLSCompliant(false)] public static void StoreAlignedNonTemporal(this Vector256 source, T* destination) => source.StoreAligned(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs index f886b55e18d..2f5b638c740 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs @@ -41,7 +41,6 @@ namespace System.Runtime.Intrinsics get => Vector256.Create(Scalar.AllBitsSet); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets the number of that are in a . /// The type of the vector () is not supported. public static int Count @@ -53,7 +52,6 @@ namespace System.Runtime.Intrinsics return Vector256.Size / sizeof(T); } } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets a new with the elements set to their index. /// The type of the vector () is not supported. @@ -567,7 +565,6 @@ namespace System.Runtime.Intrinsics /// static bool ISimdVector, T>.LessThanOrEqualAny(Vector256 left, Vector256 right) => Vector256.LessThanOrEqualAny(left, right); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector256 ISimdVector, T>.Load(T* source) => Vector256.Load(source); @@ -576,7 +573,6 @@ namespace System.Runtime.Intrinsics /// static Vector256 ISimdVector, T>.LoadAlignedNonTemporal(T* source) => Vector256.LoadAlignedNonTemporal(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector256 ISimdVector, T>.LoadUnsafe(ref readonly T source) => Vector256.LoadUnsafe(in source); @@ -644,7 +640,6 @@ namespace System.Runtime.Intrinsics /// static Vector256 ISimdVector, T>.Sqrt(Vector256 vector) => Vector256.Sqrt(vector); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.Store(Vector256 source, T* destination) => source.Store(destination); @@ -653,7 +648,6 @@ namespace System.Runtime.Intrinsics /// static void ISimdVector, T>.StoreAlignedNonTemporal(Vector256 source, T* destination) => source.StoreAlignedNonTemporal(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.StoreUnsafe(Vector256 vector, ref T destination) => vector.StoreUnsafe(ref destination); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs index 7a22ec76818..bc7e32e1e5f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs @@ -2056,7 +2056,6 @@ namespace System.Runtime.Intrinsics || Vector256.LessThanOrEqualAny(left._upper, right._upper); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. /// The source from which the vector will be loaded. @@ -2095,7 +2094,6 @@ namespace System.Runtime.Intrinsics [Intrinsic] [CLSCompliant(false)] public static Vector512 LoadAlignedNonTemporal(T* source) => LoadAligned(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. @@ -3106,7 +3104,6 @@ namespace System.Runtime.Intrinsics ); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. /// The vector that will be stored. @@ -3145,7 +3142,6 @@ namespace System.Runtime.Intrinsics [Intrinsic] [CLSCompliant(false)] public static void StoreAlignedNonTemporal(this Vector512 source, T* destination) => source.StoreAligned(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs index 7fb65ad7583..b64b6e0f60a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs @@ -41,7 +41,6 @@ namespace System.Runtime.Intrinsics get => Vector512.Create(Scalar.AllBitsSet); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets the number of that are in a . /// The type of the vector () is not supported. public static int Count @@ -53,7 +52,6 @@ namespace System.Runtime.Intrinsics return Vector512.Size / sizeof(T); } } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets a new with the elements set to their index. /// The type of the vector () is not supported. @@ -567,7 +565,6 @@ namespace System.Runtime.Intrinsics /// static bool ISimdVector, T>.LessThanOrEqualAny(Vector512 left, Vector512 right) => Vector512.LessThanOrEqualAny(left, right); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector512 ISimdVector, T>.Load(T* source) => Vector512.Load(source); @@ -576,7 +573,6 @@ namespace System.Runtime.Intrinsics /// static Vector512 ISimdVector, T>.LoadAlignedNonTemporal(T* source) => Vector512.LoadAlignedNonTemporal(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector512 ISimdVector, T>.LoadUnsafe(ref readonly T source) => Vector512.LoadUnsafe(in source); @@ -644,7 +640,6 @@ namespace System.Runtime.Intrinsics /// static Vector512 ISimdVector, T>.Sqrt(Vector512 vector) => Vector512.Sqrt(vector); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.Store(Vector512 source, T* destination) => source.Store(destination); @@ -653,7 +648,6 @@ namespace System.Runtime.Intrinsics /// static void ISimdVector, T>.StoreAlignedNonTemporal(Vector512 source, T* destination) => source.StoreAlignedNonTemporal(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.StoreUnsafe(Vector512 vector, ref T destination) => vector.StoreUnsafe(ref destination); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs index 7203311532d..5e0bcb38a4d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs @@ -1847,7 +1847,6 @@ namespace System.Runtime.Intrinsics return false; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. /// The source from which the vector will be loaded. @@ -1886,7 +1885,6 @@ namespace System.Runtime.Intrinsics [Intrinsic] [CLSCompliant(false)] public static unsafe Vector64 LoadAlignedNonTemporal(T* source) => LoadAligned(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Loads a vector from the given source. /// The type of the elements in the vector. @@ -3024,7 +3022,6 @@ namespace System.Runtime.Intrinsics return result; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. /// The vector that will be stored. @@ -3063,7 +3060,6 @@ namespace System.Runtime.Intrinsics [Intrinsic] [CLSCompliant(false)] public static unsafe void StoreAlignedNonTemporal(this Vector64 source, T* destination) => source.StoreAligned(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Stores a vector at the given destination. /// The type of the elements in the vector. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs index 64fc7f07b7f..0458c73719e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs @@ -41,7 +41,6 @@ namespace System.Runtime.Intrinsics get => Vector64.Create(Scalar.AllBitsSet); } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets the number of that are in a . /// The type of the vector () is not supported. public static unsafe int Count @@ -53,7 +52,6 @@ namespace System.Runtime.Intrinsics return Vector64.Size / sizeof(T); } } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// Gets a new with the elements set to their index. /// The type of the vector () is not supported. @@ -635,7 +633,6 @@ namespace System.Runtime.Intrinsics /// static bool ISimdVector, T>.LessThanOrEqualAny(Vector64 left, Vector64 right) => Vector64.LessThanOrEqualAny(left, right); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector64 ISimdVector, T>.Load(T* source) => Vector64.Load(source); @@ -644,7 +641,6 @@ namespace System.Runtime.Intrinsics /// static Vector64 ISimdVector, T>.LoadAlignedNonTemporal(T* source) => Vector64.LoadAlignedNonTemporal(source); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static Vector64 ISimdVector, T>.LoadUnsafe(ref readonly T source) => Vector64.LoadUnsafe(in source); @@ -712,7 +708,6 @@ namespace System.Runtime.Intrinsics /// static Vector64 ISimdVector, T>.Sqrt(Vector64 vector) => Vector64.Sqrt(vector); -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.Store(Vector64 source, T* destination) => source.Store(destination); @@ -721,7 +716,6 @@ namespace System.Runtime.Intrinsics /// static void ISimdVector, T>.StoreAlignedNonTemporal(Vector64 source, T* destination) => source.StoreAlignedNonTemporal(destination); -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') /// static void ISimdVector, T>.StoreUnsafe(Vector64 vector, ref T destination) => vector.StoreUnsafe(ref destination); diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any1SearchValues.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any1SearchValues.cs index 9a52511b987..46156d7df92 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any1SearchValues.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any1SearchValues.cs @@ -6,8 +6,6 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // address of managed types - namespace System.Buffers { internal sealed class Any1SearchValues : SearchValues @@ -16,9 +14,9 @@ namespace System.Buffers { private readonly TImpl _e0; - public Any1SearchValues(ReadOnlySpan values) + public unsafe Any1SearchValues(ReadOnlySpan values) { - Debug.Assert(Unsafe.SizeOf() == Unsafe.SizeOf()); + Debug.Assert(sizeof(T) == sizeof(TImpl)); Debug.Assert(values.Length == 1); _e0 = values[0]; } diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any2SearchValues.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any2SearchValues.cs index 640a15f05c8..8cbec8897a8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any2SearchValues.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any2SearchValues.cs @@ -6,8 +6,6 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // address of managed types - namespace System.Buffers { internal sealed class Any2SearchValues : SearchValues @@ -16,9 +14,9 @@ namespace System.Buffers { private readonly TImpl _e0, _e1; - public Any2SearchValues(ReadOnlySpan values) + public unsafe Any2SearchValues(ReadOnlySpan values) { - Debug.Assert(Unsafe.SizeOf() == Unsafe.SizeOf()); + Debug.Assert(sizeof(T) == sizeof(TImpl)); Debug.Assert(values.Length == 2); (_e0, _e1) = (values[0], values[1]); } diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any3SearchValues.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any3SearchValues.cs index f166aef4270..8b3d29775cc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any3SearchValues.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any3SearchValues.cs @@ -6,8 +6,6 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // address of managed types - namespace System.Buffers { internal sealed class Any3SearchValues : SearchValues @@ -16,9 +14,9 @@ namespace System.Buffers { private readonly TImpl _e0, _e1, _e2; - public Any3SearchValues(ReadOnlySpan values) + public unsafe Any3SearchValues(ReadOnlySpan values) { - Debug.Assert(Unsafe.SizeOf() == Unsafe.SizeOf()); + Debug.Assert(sizeof(T) == sizeof(TImpl)); Debug.Assert(values.Length == 3); (_e0, _e1, _e2) = (values[0], values[1], values[2]); } diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any4SearchValues.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any4SearchValues.cs index 8f87afe2e23..17584c362a9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any4SearchValues.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any4SearchValues.cs @@ -6,8 +6,6 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // address of managed types - namespace System.Buffers { internal sealed class Any4SearchValues : SearchValues @@ -16,9 +14,9 @@ namespace System.Buffers { private readonly TImpl _e0, _e1, _e2, _e3; - public Any4SearchValues(ReadOnlySpan values) + public unsafe Any4SearchValues(ReadOnlySpan values) { - Debug.Assert(Unsafe.SizeOf() == Unsafe.SizeOf()); + Debug.Assert(sizeof(T) == sizeof(TImpl)); Debug.Assert(values.Length == 4); (_e0, _e1, _e2, _e3) = (values[0], values[1], values[2], values[3]); } diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any5SearchValues.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any5SearchValues.cs index 0cdfc16d04c..30c60c69716 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any5SearchValues.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Any5SearchValues.cs @@ -6,8 +6,6 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 8500 // address of managed types - namespace System.Buffers { internal sealed class Any5SearchValues : SearchValues @@ -16,9 +14,9 @@ namespace System.Buffers { private readonly TImpl _e0, _e1, _e2, _e3, _e4; - public Any5SearchValues(ReadOnlySpan values) + public unsafe Any5SearchValues(ReadOnlySpan values) { - Debug.Assert(Unsafe.SizeOf() == Unsafe.SizeOf()); + Debug.Assert(sizeof(T) == sizeof(TImpl)); Debug.Assert(values.Length == 5); (_e0, _e1, _e2, _e3, _e4) = (values[0], values[1], values[2], values[3], values[4]); } diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs index bf06e365f40..36965c24da7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs @@ -9,8 +9,6 @@ using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.Wasm; using System.Runtime.Intrinsics.X86; -#pragma warning disable 8500 // sizeof of managed types - namespace System.Buffers { internal static class IndexOfAnyAsciiSearcher diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMap.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMap.cs index 3211c0c320f..482dd4bc1de 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMap.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMap.cs @@ -10,8 +10,6 @@ using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.Wasm; using System.Runtime.Intrinsics.X86; -#pragma warning disable CS8500 // Takes the address of a managed type - namespace System.Buffers { /// Data structure used to optimize checks for whether a char is in a set of chars. diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMapState.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMapState.cs index c1631feabf8..fd0296a8c8d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMapState.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMapState.cs @@ -8,8 +8,6 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable CS8500 // Takes the address of a managed type - namespace System.Buffers { /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Span.cs b/src/libraries/System.Private.CoreLib/src/System/Span.cs index 62fcdc2cd27..9621de1c83b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Span.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Span.cs @@ -10,7 +10,6 @@ using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; #pragma warning disable 0809 // Obsolete member 'Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' -#pragma warning disable 8500 // address / sizeof of managed types namespace System { diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Packed.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Packed.cs index 70d4e22acb5..52eb1b0b2be 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Packed.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Packed.cs @@ -7,8 +7,6 @@ using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#pragma warning disable 8500 // sizeof of managed types - namespace System { // This is a separate class instead of 'partial SpanHelpers' to hide the private helpers 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 65b17b29156..0d61e3b662d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs @@ -7,8 +7,6 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; -#pragma warning disable 8500 // sizeof of managed types - namespace System { internal static partial class SpanHelpers // .T @@ -3775,7 +3773,7 @@ namespace System return count; } - public static int CountValueType(ref T current, T value, int length) where T : struct, IEquatable? + public static unsafe int CountValueType(ref T current, T value, int length) where T : struct, IEquatable? { int count = 0; ref T end = ref Unsafe.Add(ref current, length); @@ -3794,7 +3792,7 @@ namespace System // Count the last vector and mask off the elements that were already counted (number of elements between oneVectorAwayFromEnd and current). ulong mask = Vector512.Equals(Vector512.LoadUnsafe(ref oneVectorAwayFromEnd), targetVector).ExtractMostSignificantBits(); - mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)Unsafe.SizeOf()); + mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); count += BitOperations.PopCount(mask); } else if (Vector256.IsHardwareAccelerated && length >= Vector256.Count) @@ -3809,7 +3807,7 @@ namespace System // Count the last vector and mask off the elements that were already counted (number of elements between oneVectorAwayFromEnd and current). uint mask = Vector256.Equals(Vector256.LoadUnsafe(ref oneVectorAwayFromEnd), targetVector).ExtractMostSignificantBits(); - mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)Unsafe.SizeOf()); + mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); count += BitOperations.PopCount(mask); } else @@ -3824,7 +3822,7 @@ namespace System // Count the last vector and mask off the elements that were already counted (number of elements between oneVectorAwayFromEnd and current). uint mask = Vector128.Equals(Vector128.LoadUnsafe(ref oneVectorAwayFromEnd), targetVector).ExtractMostSignificantBits(); - mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)Unsafe.SizeOf()); + mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); count += BitOperations.PopCount(mask); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs index 7776024aaeb..2f83103a190 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#pragma warning disable 8500 // sizeof of managed types - namespace System { internal static partial class SpanHelpers diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index ccc2e3d021f..6fc5ae0d006 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -5337,7 +5337,6 @@ namespace System.Threading.Tasks [MethodImpl(MethodImplOptions.AggressiveInlining)] // method looks long, but for a given TResult it results in a relatively small amount of asm public static unsafe Task FromResult(TResult result) { -#pragma warning disable 8500 // address of / sizeof of managed types // The goal of this function is to be give back a cached task if possible, or to otherwise give back a new task. // To give back a cached task, we need to be able to evaluate the incoming result value, and we need to avoid as // much overhead as possible when doing so, as this function is invoked as part of the return path from every async @@ -5386,7 +5385,6 @@ namespace System.Threading.Tasks // No cached task is available. Manufacture a new one for this result. return new Task(result); -#pragma warning restore 8500 } /// Creates a that's completed exceptionally with the specified exception. diff --git a/src/libraries/System.Private.CoreLib/src/System/TypedReference.cs b/src/libraries/System.Private.CoreLib/src/System/TypedReference.cs index 59a427c6cfb..552fcff2902 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TypedReference.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TypedReference.cs @@ -53,9 +53,7 @@ namespace System // reference to TypedReference is banned, so have to pass result as pointer unsafe { -#pragma warning disable CS8500 // Takes a pointer to a managed type InternalMakeTypedReference(&result, target, fields, targetType); -#pragma warning restore CS8500 } return result; } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs index e6c8fcb4d89..f2bfb59b769 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs @@ -100,31 +100,31 @@ namespace System.Xml } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void WriteTextNodeRaw(XmlBinaryNodeType nodeType, T value) + private unsafe void WriteTextNodeRaw(XmlBinaryNodeType nodeType, T value) where T : unmanaged { - // GetTextNodeBuffer performs bounds checks and ensures returned buffer has size of at least (1 + Unsafe.SizeOf()) - byte[] buffer = GetTextNodeBuffer(1 + Unsafe.SizeOf(), out int offset); + // GetTextNodeBuffer performs bounds checks and ensures returned buffer has size of at least (1 + sizeof(T)) + byte[] buffer = GetTextNodeBuffer(1 + sizeof(T), out int offset); - Debug.Assert(offset >= 0 && offset + 1 + Unsafe.SizeOf() <= buffer.Length, "WriteTextNodeRaw"); + Debug.Assert(offset >= 0 && offset + 1 + sizeof(T) <= buffer.Length, "WriteTextNodeRaw"); ref byte bytePtr = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(buffer), offset); bytePtr = (byte)nodeType; Unsafe.WriteUnaligned(ref Unsafe.Add(ref bytePtr, 1), value); - Advance(1 + Unsafe.SizeOf()); + Advance(1 + sizeof(T)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void WriteRaw(T value) + private unsafe void WriteRaw(T value) where T : unmanaged { - // GetBuffer performs bounds checks and ensures returned buffer has size of at least (Unsafe.SizeOf()) - byte[] buffer = GetBuffer(Unsafe.SizeOf(), out int offset); + // GetBuffer performs bounds checks and ensures returned buffer has size of at least (sizeof(T)) + byte[] buffer = GetBuffer(sizeof(T), out int offset); - Debug.Assert(offset >= 0 && offset + Unsafe.SizeOf() <= buffer.Length, "WriteRaw"); + Debug.Assert(offset >= 0 && offset + sizeof(T) <= buffer.Length, "WriteRaw"); ref byte bytePtr = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(buffer), offset); Unsafe.WriteUnaligned(ref bytePtr, value); - Advance(Unsafe.SizeOf()); + Advance(sizeof(T)); } private void WriteTextNodeWithInt8(XmlBinaryNodeType nodeType, byte value) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBufferReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBufferReader.cs index ef1983fa5cc..780f4827f53 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBufferReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBufferReader.cs @@ -935,7 +935,6 @@ namespace System.Xml return (sbyte)GetByte(offset); } -#pragma warning disable 8500 // sizeof of managed types private unsafe T ReadRawBytes() where T : unmanaged { ReadOnlySpan buffer = GetBuffer(sizeof(T), out int offset) @@ -948,7 +947,6 @@ namespace System.Xml private unsafe T ReadRawBytes(int offset) where T : unmanaged => MemoryMarshal.Read(_buffer.AsSpan(offset, sizeof(T))); -#pragma warning restore 8500 public int GetInt16(int offset) => BitConverter.IsLittleEndian ? ReadRawBytes(offset) : BinaryPrimitives.ReverseEndianness(ReadRawBytes(offset)); diff --git a/src/libraries/System.Private.Uri/tests/UnitTests/System.Private.Uri.Unit.Tests.csproj b/src/libraries/System.Private.Uri/tests/UnitTests/System.Private.Uri.Unit.Tests.csproj index 83f98440edc..e3f38a50e35 100644 --- a/src/libraries/System.Private.Uri/tests/UnitTests/System.Private.Uri.Unit.Tests.csproj +++ b/src/libraries/System.Private.Uri/tests/UnitTests/System.Private.Uri.Unit.Tests.csproj @@ -1,7 +1,7 @@ - + true - 436 + $(NoWarn);436 ../../src/Resources/Strings.resx $(NetCoreAppCurrent) enable diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.csproj index f57576c378c..d8b8fdfcfe0 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.csproj @@ -8,7 +8,7 @@ true - RS2008;RS1038;$(NoWarn) + $(NoWarn);RS2008;RS1038 $(DefineConstants);JSIMPORTGENERATOR cs diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.csproj index 8d187cfa8b3..1ef090dee7a 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.csproj @@ -8,7 +8,7 @@ true - RS2008;RS1038;$(NoWarn) + $(NoWarn);RS2008;RS1038 cs $(DefineConstants);MICROSOFT_INTEROP_COMINTERFACEGENERATOR ../Common/Resources/Strings.resx diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj index fd0512ebaec..17727680fae 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/LibraryImportGenerator.csproj @@ -8,7 +8,7 @@ true - RS2008;RS1038;$(NoWarn) + $(NoWarn);RS2008;RS1038 cs ../Common/Resources/Strings.resx diff --git a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs index fc632d99b33..f11418a9cbc 100644 --- a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs +++ b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs @@ -202,14 +202,12 @@ namespace System.Runtime.Intrinsics public static bool LessThanOrEqualAny(System.Runtime.Intrinsics.Vector128 left, System.Runtime.Intrinsics.Vector128 right) { throw null; } public static System.Runtime.Intrinsics.Vector128 LessThanOrEqual(System.Runtime.Intrinsics.Vector128 left, System.Runtime.Intrinsics.Vector128 right) { throw null; } public static System.Runtime.Intrinsics.Vector128 LessThan(System.Runtime.Intrinsics.Vector128 left, System.Runtime.Intrinsics.Vector128 right) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector128 Load(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector128 LoadAligned(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector128 LoadAlignedNonTemporal(T* source) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static System.Runtime.Intrinsics.Vector128 LoadUnsafe(ref readonly T source) { throw null; } [System.CLSCompliantAttribute(false)] public static System.Runtime.Intrinsics.Vector128 LoadUnsafe(ref readonly T source, nuint elementOffset) { throw null; } @@ -302,14 +300,12 @@ namespace System.Runtime.Intrinsics public static System.Runtime.Intrinsics.Vector128 Shuffle(System.Runtime.Intrinsics.Vector128 vector, System.Runtime.Intrinsics.Vector128 indices) { throw null; } public static System.Runtime.Intrinsics.Vector128 Shuffle(System.Runtime.Intrinsics.Vector128 vector, System.Runtime.Intrinsics.Vector128 indices) { throw null; } public static System.Runtime.Intrinsics.Vector128 Sqrt(System.Runtime.Intrinsics.Vector128 vector) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe void Store(this System.Runtime.Intrinsics.Vector128 source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAligned(this System.Runtime.Intrinsics.Vector128 source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAlignedNonTemporal(this System.Runtime.Intrinsics.Vector128 source, T* destination) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static void StoreUnsafe(this System.Runtime.Intrinsics.Vector128 source, ref T destination) { throw null; } [System.CLSCompliantAttribute(false)] public static void StoreUnsafe(this System.Runtime.Intrinsics.Vector128 source, ref T destination, nuint elementOffset) { throw null; } @@ -579,14 +575,12 @@ namespace System.Runtime.Intrinsics public static bool LessThanOrEqualAny(System.Runtime.Intrinsics.Vector256 left, System.Runtime.Intrinsics.Vector256 right) { throw null; } public static System.Runtime.Intrinsics.Vector256 LessThanOrEqual(System.Runtime.Intrinsics.Vector256 left, System.Runtime.Intrinsics.Vector256 right) { throw null; } public static System.Runtime.Intrinsics.Vector256 LessThan(System.Runtime.Intrinsics.Vector256 left, System.Runtime.Intrinsics.Vector256 right) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector256 Load(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector256 LoadAligned(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector256 LoadAlignedNonTemporal(T* source) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static System.Runtime.Intrinsics.Vector256 LoadUnsafe(ref readonly T source) { throw null; } [System.CLSCompliantAttribute(false)] public static System.Runtime.Intrinsics.Vector256 LoadUnsafe(ref readonly T source, nuint elementOffset) { throw null; } @@ -679,14 +673,12 @@ namespace System.Runtime.Intrinsics public static System.Runtime.Intrinsics.Vector256 Shuffle(System.Runtime.Intrinsics.Vector256 vector, System.Runtime.Intrinsics.Vector256 indices) { throw null; } public static System.Runtime.Intrinsics.Vector256 Shuffle(System.Runtime.Intrinsics.Vector256 vector, System.Runtime.Intrinsics.Vector256 indices) { throw null; } public static System.Runtime.Intrinsics.Vector256 Sqrt(System.Runtime.Intrinsics.Vector256 vector) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe void Store(this System.Runtime.Intrinsics.Vector256 source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAligned(this System.Runtime.Intrinsics.Vector256 source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAlignedNonTemporal(this System.Runtime.Intrinsics.Vector256 source, T* destination) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static void StoreUnsafe(this System.Runtime.Intrinsics.Vector256 source, ref T destination) { throw null; } [System.CLSCompliantAttribute(false)] public static void StoreUnsafe(this System.Runtime.Intrinsics.Vector256 source, ref T destination, nuint elementOffset) { throw null; } @@ -957,14 +949,12 @@ namespace System.Runtime.Intrinsics public static bool LessThanOrEqualAny(System.Runtime.Intrinsics.Vector512 left, System.Runtime.Intrinsics.Vector512 right) { throw null; } public static System.Runtime.Intrinsics.Vector512 LessThanOrEqual(System.Runtime.Intrinsics.Vector512 left, System.Runtime.Intrinsics.Vector512 right) { throw null; } public static System.Runtime.Intrinsics.Vector512 LessThan(System.Runtime.Intrinsics.Vector512 left, System.Runtime.Intrinsics.Vector512 right) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector512 Load(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector512 LoadAligned(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector512 LoadAlignedNonTemporal(T* source) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static System.Runtime.Intrinsics.Vector512 LoadUnsafe(ref readonly T source) { throw null; } [System.CLSCompliantAttribute(false)] public static System.Runtime.Intrinsics.Vector512 LoadUnsafe(ref readonly T source, nuint elementOffset) { throw null; } @@ -1057,14 +1047,12 @@ namespace System.Runtime.Intrinsics public static System.Runtime.Intrinsics.Vector512 Shuffle(System.Runtime.Intrinsics.Vector512 vector, System.Runtime.Intrinsics.Vector512 indices) { throw null; } public static System.Runtime.Intrinsics.Vector512 Shuffle(System.Runtime.Intrinsics.Vector512 vector, System.Runtime.Intrinsics.Vector512 indices) { throw null; } public static System.Runtime.Intrinsics.Vector512 Sqrt(System.Runtime.Intrinsics.Vector512 vector) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe void Store(this System.Runtime.Intrinsics.Vector512 source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAligned(this System.Runtime.Intrinsics.Vector512 source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAlignedNonTemporal(this System.Runtime.Intrinsics.Vector512 source, T* destination) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static void StoreUnsafe(this System.Runtime.Intrinsics.Vector512 source, ref T destination) { throw null; } [System.CLSCompliantAttribute(false)] public static void StoreUnsafe(this System.Runtime.Intrinsics.Vector512 source, ref T destination, nuint elementOffset) { throw null; } @@ -1304,14 +1292,12 @@ namespace System.Runtime.Intrinsics public static bool LessThanOrEqualAny(System.Runtime.Intrinsics.Vector64 left, System.Runtime.Intrinsics.Vector64 right) { throw null; } public static System.Runtime.Intrinsics.Vector64 LessThanOrEqual(System.Runtime.Intrinsics.Vector64 left, System.Runtime.Intrinsics.Vector64 right) { throw null; } public static System.Runtime.Intrinsics.Vector64 LessThan(System.Runtime.Intrinsics.Vector64 left, System.Runtime.Intrinsics.Vector64 right) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector64 Load(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector64 LoadAligned(T* source) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe System.Runtime.Intrinsics.Vector64 LoadAlignedNonTemporal(T* source) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static System.Runtime.Intrinsics.Vector64 LoadUnsafe(ref readonly T source) { throw null; } [System.CLSCompliantAttribute(false)] public static System.Runtime.Intrinsics.Vector64 LoadUnsafe(ref readonly T source, nuint elementOffset) { throw null; } @@ -1400,14 +1386,12 @@ namespace System.Runtime.Intrinsics public static System.Runtime.Intrinsics.Vector64 Shuffle(System.Runtime.Intrinsics.Vector64 vector, System.Runtime.Intrinsics.Vector64 indices) { throw null; } public static System.Runtime.Intrinsics.Vector64 Shuffle(System.Runtime.Intrinsics.Vector64 vector, System.Runtime.Intrinsics.Vector64 indices) { throw null; } public static System.Runtime.Intrinsics.Vector64 Sqrt(System.Runtime.Intrinsics.Vector64 vector) { throw null; } -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') [System.CLSCompliantAttribute(false)] public static unsafe void Store(this System.Runtime.Intrinsics.Vector64 source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAligned(this System.Runtime.Intrinsics.Vector64 source, T* destination) { throw null; } [System.CLSCompliantAttribute(false)] public static unsafe void StoreAlignedNonTemporal(this System.Runtime.Intrinsics.Vector64 source, T* destination) { throw null; } -#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T') public static void StoreUnsafe(this System.Runtime.Intrinsics.Vector64 source, ref T destination) { throw null; } [System.CLSCompliantAttribute(false)] public static void StoreUnsafe(this System.Runtime.Intrinsics.Vector64 source, ref T destination, nuint elementOffset) { throw null; } diff --git a/src/libraries/System.Runtime/tests/System.Dynamic.Runtime.Tests/System.Dynamic.Runtime.Tests.csproj b/src/libraries/System.Runtime/tests/System.Dynamic.Runtime.Tests/System.Dynamic.Runtime.Tests.csproj index 38bc2f67d0b..06cb70e978c 100644 --- a/src/libraries/System.Runtime/tests/System.Dynamic.Runtime.Tests/System.Dynamic.Runtime.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Dynamic.Runtime.Tests/System.Dynamic.Runtime.Tests.csproj @@ -1,7 +1,7 @@ true - 67,168,219,414,162,184,458,464,78,169,114,693,108,1981,649,109,1066,3021,3026,3002,3014,3022,660,661,429;xUnit1013 + $(NoWarn);67;168;219;414;162;184;458;464;78;169;114;693;108;1981;649;109;1066;3021;3026;3002;3014;3022;660;661;429;xUnit1013 $(NetCoreAppCurrent);$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-maccatalyst @@ -152,4 +152,4 @@ - \ No newline at end of file + diff --git a/src/libraries/System.Runtime/tests/System.Runtime.CompilerServices.Unsafe.Tests/UnsafeTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.CompilerServices.Unsafe.Tests/UnsafeTests.cs index 8cc4f236af4..1304168bff9 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.CompilerServices.Unsafe.Tests/UnsafeTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.CompilerServices.Unsafe.Tests/UnsafeTests.cs @@ -6,8 +6,6 @@ using System.Numerics; using System.Runtime.InteropServices; using Xunit; -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type - namespace System.Runtime.CompilerServices { public class UnsafeTests diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/GCTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/GCTests.cs index e20c3877b5c..137c1dc8246 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/GCTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/GCTests.cs @@ -1097,7 +1097,7 @@ namespace System.Tests EmbeddedValueType[] array = uninitialized ? GC.AllocateUninitializedArray>(length, pinned: true) : GC.AllocateArray>(length, pinned: true); byte* pointer = (byte*)Unsafe.AsPointer(ref array[0]); // Unsafe.AsPointer is safe since array is pinned - var size = Unsafe.SizeOf>(); + int size = sizeof(EmbeddedValueType); GC.Collect(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/PemEncoding.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/PemEncoding.cs index b5f02097cc9..3e3625b01e5 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/PemEncoding.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/PemEncoding.cs @@ -525,7 +525,6 @@ namespace System.Security.Cryptography int encodedSize = GetEncodedSize(label.Length, data.Length); -#pragma warning disable CS8500 // takes address of managed type return string.Create( encodedSize, (LabelPointer: (IntPtr)(&label), DataPointer: (IntPtr)(&data)), @@ -542,7 +541,6 @@ namespace System.Security.Cryptography throw new CryptographicException(); } }); -#pragma warning restore CS8500 } } } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainProcessor.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainProcessor.cs index ceb2d401ec6..b441a3cbe04 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainProcessor.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainProcessor.cs @@ -15,8 +15,6 @@ using Internal.Cryptography; using Microsoft.Win32.SafeHandles; using X509VerifyStatusCodeUniversal = Interop.Crypto.X509VerifyStatusCodeUniversal; -#pragma warning disable 8500 // taking address of managed type - namespace System.Security.Cryptography.X509Certificates { internal sealed class OpenSslX509ChainProcessor : IChainPal diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.AndroidKeyStore.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.AndroidKeyStore.cs index 916da956c23..72824f6a004 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.AndroidKeyStore.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.AndroidKeyStore.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; -#pragma warning disable 8500 // taking address of managed type - namespace System.Security.Cryptography.X509Certificates { internal sealed partial class StorePal @@ -129,9 +127,7 @@ namespace System.Security.Cryptography.X509Certificates [UnmanagedCallersOnly] private static unsafe void EnumCertificatesCallback(void* certPtr, void* privateKeyPtr, Interop.AndroidCrypto.PAL_KeyAlgorithm privateKeyAlgorithm, void* context) { -#pragma warning disable 8500 // taking address of managed type EnumCertificatesContext* callbackContext = (EnumCertificatesContext*)context; -#pragma warning restore 8500 AndroidCertificatePal certPal; var handle = new SafeX509Handle((IntPtr)certPtr); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.TrustedStore.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.TrustedStore.cs index dc86f467b9e..2b2ca1502b0 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.TrustedStore.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.TrustedStore.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; -#pragma warning disable 8500 // taking address of managed type - namespace System.Security.Cryptography.X509Certificates { internal sealed partial class StorePal diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Replace.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Replace.cs index ac4066a2f00..96c5fd5c347 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Replace.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Replace.cs @@ -3,8 +3,6 @@ using System.Diagnostics.CodeAnalysis; -#pragma warning disable CS8500 // takes address of managed type - namespace System.Text.RegularExpressions { // Callback class diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs index 3c24bdc78ad..e7350da6bac 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs @@ -1591,7 +1591,6 @@ namespace System.Text.RegularExpressions } // Get the pointer/length of the span to be able to pass it into string.Create. -#pragma warning disable CS8500 // takes address of managed type ReadOnlySpan tmpChars = chars; // avoid address exposing the span and impacting the other code in the method that uses it return #if NET @@ -1616,7 +1615,6 @@ namespace System.Text.RegularExpressions } Debug.Assert(i == span.Length); }); -#pragma warning restore CS8500 } /// diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexReplacement.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexReplacement.cs index 60fede15695..00a37d7fa8c 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexReplacement.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexReplacement.cs @@ -6,8 +6,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; -#pragma warning disable CS8500 // takes address of managed type - namespace System.Text.RegularExpressions { /// diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.ForEachAsync.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.ForEachAsync.cs index ef700e1b9c9..3cff4876f08 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.ForEachAsync.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.ForEachAsync.cs @@ -106,7 +106,6 @@ namespace System.Threading.Tasks typeof(T) == typeof(nint) || typeof(T) == typeof(nuint); -#pragma warning disable CS8500 [MethodImpl(MethodImplOptions.AggressiveInlining)] static unsafe bool CompareExchange(ref T location, T value, T comparand) => sizeof(T) == sizeof(byte) ? Interlocked.CompareExchange(ref Unsafe.As(ref location), Unsafe.As(ref value), Unsafe.As(ref comparand)) == Unsafe.As(ref comparand) : @@ -114,7 +113,6 @@ namespace System.Threading.Tasks sizeof(T) == sizeof(uint) ? Interlocked.CompareExchange(ref Unsafe.As(ref location), Unsafe.As(ref value), Unsafe.As(ref comparand)) == Unsafe.As(ref comparand) : sizeof(T) == sizeof(ulong) ? Interlocked.CompareExchange(ref Unsafe.As(ref location), Unsafe.As(ref value), Unsafe.As(ref comparand)) == Unsafe.As(ref comparand) : throw new UnreachableException(); -#pragma warning restore CS8500 // The worker body. Each worker will execute this same body. Func taskBody = static async o => diff --git a/src/mono/System.Private.CoreLib/src/System/ArgIterator.cs b/src/mono/System.Private.CoreLib/src/System/ArgIterator.cs index 9f65c307c12..1209465f604 100644 --- a/src/mono/System.Private.CoreLib/src/System/ArgIterator.cs +++ b/src/mono/System.Private.CoreLib/src/System/ArgIterator.cs @@ -63,9 +63,7 @@ namespace System TypedReference result = default; unsafe { -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('TypedReference') IntGetNextArg(&result); -#pragma warning restore CS8500 } return result; } @@ -81,9 +79,7 @@ namespace System TypedReference result = default; unsafe { -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('TypedReference') IntGetNextArgWithType(&result, rth.Value); -#pragma warning restore CS8500 } return result; } diff --git a/src/mono/System.Private.CoreLib/src/System/Buffer.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Buffer.Mono.cs index bcb9b6b38f2..a74166daba1 100644 --- a/src/mono/System.Private.CoreLib/src/System/Buffer.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Buffer.Mono.cs @@ -21,13 +21,11 @@ namespace System { if (!RuntimeHelpers.IsReferenceOrContainsReferences()) { -#pragma warning disable 8500 // sizeof of managed types // Blittable memmove SpanHelpers.Memmove( ref Unsafe.As(ref destination), ref Unsafe.As(ref source), elementCount * (nuint)sizeof(T)); -#pragma warning restore 8500 } else if (elementCount > 0) { diff --git a/src/mono/System.Private.CoreLib/src/System/Enum.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Enum.Mono.cs index 5a4fe01cfc5..2d2a93a459e 100644 --- a/src/mono/System.Private.CoreLib/src/System/Enum.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Enum.Mono.cs @@ -6,8 +6,6 @@ using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; -#pragma warning disable 8500 // pointer to / sizeof managed types - namespace System { public partial class Enum diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs index 7811adcf631..b9cbbee87f8 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs @@ -111,9 +111,7 @@ namespace System.Reflection unsafe { // Passing TypedReference by reference is easier to make correct in native code -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('TypedReference') RuntimeFieldHandle.SetValueDirect(this, (RuntimeType)FieldType, &obj, value, (RuntimeType?)DeclaringType); -#pragma warning restore CS8500 } } @@ -127,9 +125,7 @@ namespace System.Reflection unsafe { // Passing TypedReference by reference is easier to make correct in native code -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('TypedReference') return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, &obj, (RuntimeType?)DeclaringType); -#pragma warning restore CS8500 } } diff --git a/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs index 4e101c99b76..71667471610 100644 --- a/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Mono.cs @@ -109,7 +109,6 @@ namespace System.Runtime.InteropServices private static Dictionary<(Type, string), ICustomMarshaler>? MarshalerInstanceCache; -#pragma warning disable 8500 #pragma warning disable 9080 private static unsafe void SetInvokeArgs(ref string cookie, IntPtr *params_byref) { @@ -117,7 +116,6 @@ namespace System.Runtime.InteropServices *(ByReference*)params_byref = objRef; } #pragma warning restore 9080 -#pragma warning restore 8500 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "Implementation detail of MarshalAs.CustomMarshaler")] diff --git a/src/mono/System.Private.CoreLib/src/System/TypedReference.Mono.cs b/src/mono/System.Private.CoreLib/src/System/TypedReference.Mono.cs index 4997c59e5d7..d9003bfecc6 100644 --- a/src/mono/System.Private.CoreLib/src/System/TypedReference.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/TypedReference.Mono.cs @@ -18,9 +18,7 @@ namespace System public static unsafe object? ToObject(TypedReference value) { -#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('TypedReference') return InternalToObject(&value); -#pragma warning restore CS8500 } [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/src/mono/browser/debugger/BrowserDebugProxy/MonoSDBHelper.cs b/src/mono/browser/debugger/BrowserDebugProxy/MonoSDBHelper.cs index 9d70f173db0..e8e8b7916e9 100644 --- a/src/mono/browser/debugger/BrowserDebugProxy/MonoSDBHelper.cs +++ b/src/mono/browser/debugger/BrowserDebugProxy/MonoSDBHelper.cs @@ -518,16 +518,14 @@ namespace Microsoft.WebAssembly.Diagnostics private unsafe T ReadBigEndian() where T : struct { - Span data = stackalloc byte[Unsafe.SizeOf()]; + Span data = stackalloc byte[sizeof(T)]; T ret = default; Read(data); if (BitConverter.IsLittleEndian) { data.Reverse(); } -#pragma warning disable CS8500 // takes address of managed type data.CopyTo(new Span(&ret, data.Length)); -#pragma warning restore CS8500 return ret; } } @@ -547,10 +545,8 @@ namespace Microsoft.WebAssembly.Diagnostics private unsafe void WriteBigEndian(T val) where T : struct { - Span data = stackalloc byte[Unsafe.SizeOf()]; -#pragma warning disable CS8500 // takes address of managed type + Span data = stackalloc byte[sizeof(T)]; new Span(&val, data.Length).CopyTo(data); -#pragma warning restore CS8500 if (BitConverter.IsLittleEndian) { data.Reverse(); diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/browser/debugger/tests/debugger-test/debugger-test.csproj index be87407a471..64358661431 100644 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-test.csproj +++ b/src/mono/browser/debugger/tests/debugger-test/debugger-test.csproj @@ -1,7 +1,7 @@ true - 219 + $(NoWarn);219 true false PrepareForWasmBuildApp;$(WasmBuildAppDependsOn) diff --git a/src/mono/wasm/testassets/WasmOnAspNetCore/AspNetCoreServer/AspNetCoreServer.csproj b/src/mono/wasm/testassets/WasmOnAspNetCore/AspNetCoreServer/AspNetCoreServer.csproj index 0b1748884ce..5606622f348 100644 --- a/src/mono/wasm/testassets/WasmOnAspNetCore/AspNetCoreServer/AspNetCoreServer.csproj +++ b/src/mono/wasm/testassets/WasmOnAspNetCore/AspNetCoreServer/AspNetCoreServer.csproj @@ -6,7 +6,7 @@ enable true - CA2007 + $(NoWarn);CA2007 diff --git a/src/mono/wasm/testassets/WasmOnAspNetCore/BlazorClient/BlazorClient.csproj b/src/mono/wasm/testassets/WasmOnAspNetCore/BlazorClient/BlazorClient.csproj index 8516c0b339b..40518a0b434 100644 --- a/src/mono/wasm/testassets/WasmOnAspNetCore/BlazorClient/BlazorClient.csproj +++ b/src/mono/wasm/testassets/WasmOnAspNetCore/BlazorClient/BlazorClient.csproj @@ -1,4 +1,4 @@ - + net9.0 @@ -6,7 +6,7 @@ enable true - CS8604;CS4014 + $(NoWarn);CS8604;CS4014 blazorclient diff --git a/src/mono/wasm/testassets/WasmOnAspNetCore/Shared/Shared.csproj b/src/mono/wasm/testassets/WasmOnAspNetCore/Shared/Shared.csproj index b88de9e4180..458fcffbabb 100644 --- a/src/mono/wasm/testassets/WasmOnAspNetCore/Shared/Shared.csproj +++ b/src/mono/wasm/testassets/WasmOnAspNetCore/Shared/Shared.csproj @@ -5,7 +5,7 @@ Library true enable - CA2007 + $(NoWarn);CA2007 diff --git a/src/mono/wasm/testassets/WasmOnAspNetCore/WasmBrowserClient/WasmBrowserClient.csproj b/src/mono/wasm/testassets/WasmOnAspNetCore/WasmBrowserClient/WasmBrowserClient.csproj index a74e1246d8b..92ae54e5883 100644 --- a/src/mono/wasm/testassets/WasmOnAspNetCore/WasmBrowserClient/WasmBrowserClient.csproj +++ b/src/mono/wasm/testassets/WasmOnAspNetCore/WasmBrowserClient/WasmBrowserClient.csproj @@ -6,7 +6,7 @@ true enable - CA1050;CA2007;CA1861;IL2104 + $(NoWarn);CA1050;CA2007;CA1861;IL2104 true wasmclient diff --git a/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/Android.Device_Emulator.gRPC.Test.csproj b/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/Android.Device_Emulator.gRPC.Test.csproj index 12755944bf3..9afea14f62b 100644 --- a/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/Android.Device_Emulator.gRPC.Test.csproj +++ b/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/Android.Device_Emulator.gRPC.Test.csproj @@ -18,7 +18,7 @@ enable - CS8981;SYSLIB0039 + $(NoWarn);CS8981;SYSLIB0039 diff --git a/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/InteropTestsWebsite.csproj b/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/InteropTestsWebsite.csproj index 0c763a85c8c..e3cef240a94 100644 --- a/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/InteropTestsWebsite.csproj +++ b/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/InteropTestsWebsite.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -8,7 +8,7 @@ - CS8981;SYSLIB0039 + $(NoWarn);CS8981;SYSLIB0039 diff --git a/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj b/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj index 63e7058259b..49503b15eed 100644 --- a/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj +++ b/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj @@ -17,7 +17,7 @@ $(DefineConstants);DIAGNOSTICS_RUNTIME - CS1591,CS8073,CS0162 + $(NoWarn);CS1591;CS8073;CS0162