Skip to content

Commit 19f0385

Browse files
authored
Replace most corelib uses of Unsafe.SizeOf<T> with sizeof(T) (#104923)
Also suppress CS8500 globally rather than in hundreds of files individually and fix NoWarns that weren't inheriting global NoWarns.
1 parent 769ead4 commit 19f0385

File tree

140 files changed

+112
-442
lines changed

Some content is hidden

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

140 files changed

+112
-442
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388
<Features>strict;nullablePublicOnly</Features>
389389
<TreatWarningsAsErrors Condition="'$(TreatWarningsAsErrors)' == ''">true</TreatWarningsAsErrors>
390390
<!-- Warnings to always disable -->
391-
<NoWarn>$(NoWarn),CS8969</NoWarn>
391+
<NoWarn>$(NoWarn);CS8500;CS8969</NoWarn>
392392
<!-- Always pass portable to override arcade sdk which uses embedded for local builds -->
393393
<DebugType>portable</DebugType>
394394
<KeepNativeSymbols Condition="'$(KeepNativeSymbols)' == '' and '$(DotNetBuildSourceOnly)' == 'true'">true</KeepNativeSymbols>

src/coreclr/System.Private.CoreLib/src/System/ArgIterator.cs

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public ArgIterator(RuntimeArgumentHandle arglist, void* ptr)
5858
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ArgIterator_Init2")]
5959
private static partial void Init(ArgIterator* thisPtr, IntPtr cookie, void* ptr);
6060

61-
#pragma warning disable CS8500 // Takes a pointer to a managed type
6261
// Fetch an argument as a typed referece, advance the iterator.
6362
// Throws an exception if past end of argument list
6463
[CLSCompliant(false)]

src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs

-4
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,7 @@ public static unsafe T[] AllocateUninitializedArray<T>(int length, bool pinned =
790790
// for debug builds we always want to call AllocateNewArray to detect AllocateNewArray bugs
791791
#if !DEBUG
792792
// small arrays are allocated using `new[]` as that is generally faster.
793-
#pragma warning disable 8500 // sizeof of managed types
794793
if (length < 2048 / sizeof(T))
795-
#pragma warning restore 8500
796794
{
797795
return new T[length];
798796
}
@@ -892,9 +890,7 @@ public static unsafe IReadOnlyDictionary<string, object> GetConfigurationVariabl
892890
Configurations = new Dictionary<string, object>()
893891
};
894892

895-
#pragma warning disable CS8500 // takes address of managed type
896893
_EnumerateConfigurationValues(&context, &ConfigCallback);
897-
#pragma warning restore CS8500
898894
return context.Configurations!;
899895
}
900896

src/coreclr/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs

-4
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ public override int GetHashCode() =>
9393
throw new ArgumentException(SR.Arg_TypedReference_Null);
9494

9595
// Passing TypedReference by reference is easier to make correct in native code
96-
#pragma warning disable CS8500 // Takes a pointer to a managed type
9796
return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, &obj, (RuntimeType?)DeclaringType);
98-
#pragma warning restore CS8500
9997
}
10098

10199
[DebuggerStepThrough]
@@ -111,9 +109,7 @@ public override void SetValueDirect(TypedReference obj, object value)
111109
throw new ArgumentException(SR.Arg_TypedReference_Null);
112110

113111
// Passing TypedReference by reference is easier to make correct in native code
114-
#pragma warning disable CS8500 // Takes a pointer to a managed type
115112
RuntimeFieldHandle.SetValueDirect(this, (RuntimeType)FieldType, &obj, value, (RuntimeType?)DeclaringType);
116-
#pragma warning restore CS8500
117113
}
118114

119115
public override RuntimeFieldHandle FieldHandle => new RuntimeFieldHandle(this);

src/coreclr/System.Private.CoreLib/src/System/Runtime/DependentHandle.cs

-2
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ private static IntPtr InternalAllocWithGCTransition(object? target, object? depe
253253
// This optimization is the same that is used in GCHandle in RELEASE mode.
254254
// This is not used in DEBUG builds as the runtime performs additional checks.
255255
// The logic below is the inlined copy of ObjectFromHandle in the unmanaged runtime.
256-
#pragma warning disable 8500 // address of managed types
257256
private static unsafe object? InternalGetTarget(IntPtr dependentHandle) => *(object*)dependentHandle;
258-
#pragma warning restore 8500
259257
#endif
260258

261259
[MethodImpl(MethodImplOptions.InternalCall)]

src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/InternalCalls.cs

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ internal static partial class InternalCalls
2323
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ResumeAtInterceptionLocation")]
2424
internal static unsafe partial void ResumeAtInterceptionLocation(void* pvRegDisplay);
2525

26-
#pragma warning disable CS8500
2726
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "CallCatchFunclet")]
2827
internal static unsafe partial IntPtr RhpCallCatchFunclet(
2928
ObjectHandleOnStack exceptionObj, byte* pHandlerIP, void* pvRegDisplay, EH.ExInfo* exInfo);
@@ -38,7 +37,6 @@ internal static unsafe partial bool RhpCallFilterFunclet(
3837

3938
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AppendExceptionStackFrame")]
4039
internal static unsafe partial void RhpAppendExceptionStackFrame(ObjectHandleOnStack exceptionObj, IntPtr ip, UIntPtr sp, int flags, EH.ExInfo* exInfo);
41-
#pragma warning restore CS8500
4240

4341
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "EHEnumInitFromStackFrameIterator")]
4442
[return: MarshalAs(UnmanagedType.Bool)]

src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.CoreCLR.cs

-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ private static void InternalFreeWithGCTransition(IntPtr dependentHandle)
4646
[MethodImpl(MethodImplOptions.InternalCall)]
4747
internal static extern object? InternalGet(IntPtr handle);
4848
#else
49-
#pragma warning disable 8500 // address of managed types
5049
internal static unsafe object? InternalGet(IntPtr handle) => *(object*)handle;
51-
#pragma warning restore 8500
5250
#endif
5351

5452
[MethodImpl(MethodImplOptions.InternalCall)]

src/coreclr/nativeaot/Common/src/Internal/Runtime/CompilerHelpers/StartupCodeHelpers.cs

-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ private static unsafe object[] InitializeStatics(IntPtr gcStaticRegionStart, int
206206
nint blockAddr = MethodTable.SupportsRelativePointers ? (nint)ReadRelPtr32(pBlock) : *pBlock;
207207
if ((blockAddr & GCStaticRegionConstants.Uninitialized) == GCStaticRegionConstants.Uninitialized)
208208
{
209-
#pragma warning disable CS8500 // takes address of managed type
210209
object? obj = null;
211210
RuntimeImports.RhAllocateNewObject(
212211
new IntPtr(blockAddr & ~GCStaticRegionConstants.Mask),
@@ -234,7 +233,6 @@ private static unsafe object[] InitializeStatics(IntPtr gcStaticRegionStart, int
234233

235234
// Update the base pointer to point to the pinned object
236235
*pBlock = *(IntPtr*)&obj;
237-
#pragma warning restore CS8500
238236
}
239237

240238
currentBase++;

src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs

-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ internal static unsafe class CachedInterfaceDispatch
1515
private static unsafe IntPtr RhpCidResolve(IntPtr callerTransitionBlockParam, IntPtr pCell)
1616
{
1717
IntPtr locationOfThisPointer = callerTransitionBlockParam + TransitionBlock.GetThisOffset();
18-
#pragma warning disable 8500 // address of managed types
1918
object pObject = *(object*)locationOfThisPointer;
20-
#pragma warning restore 8500
2119
IntPtr dispatchResolveTarget = RhpCidResolve_Worker(pObject, pCell);
2220
return dispatchResolveTarget;
2321
}

src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs

+1-8
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,11 @@ private static void AppendExceptionStackFrameViaClasslib(object exception, IntPt
279279
isFirstFrame = false;
280280
}
281281
#else
282-
#pragma warning disable CS8500
283282
fixed (EH.ExInfo* pExInfo = &exInfo)
284283
{
285284
InternalCalls.RhpAppendExceptionStackFrame(ObjectHandleOnStack.Create(ref exception), ip, sp, flags, pExInfo);
286285
}
287-
#pragma warning restore CS8500
286+
288287
// Clear flags only if we called the function
289288
isFirstRethrowFrame = false;
290289
isFirstFrame = false;
@@ -686,13 +685,11 @@ public static void RhUnwindAndIntercept(ref ExInfo exInfo, UIntPtr interceptStac
686685
if (unwoundReversePInvoke)
687686
{
688687
object exceptionObj = exInfo.ThrownException;
689-
#pragma warning disable CS8500
690688
fixed (EH.ExInfo* pExInfo = &exInfo)
691689
{
692690
InternalCalls.RhpCallCatchFunclet(
693691
ObjectHandleOnStack.Create(ref exceptionObj), null, exInfo._frameIter.RegisterSet, pExInfo);
694692
}
695-
#pragma warning restore CS8500
696693
}
697694
else
698695
{
@@ -922,13 +919,11 @@ private static void DispatchEx(scoped ref StackFrameIterator frameIter, ref ExIn
922919
InternalCalls.RhpCallCatchFunclet(
923920
exceptionObj, pCatchHandler, frameIter.RegisterSet, ref exInfo);
924921
#else // NATIVEAOT
925-
#pragma warning disable CS8500
926922
fixed (EH.ExInfo* pExInfo = &exInfo)
927923
{
928924
InternalCalls.RhpCallCatchFunclet(
929925
ObjectHandleOnStack.Create(ref exceptionObj), pCatchHandler, frameIter.RegisterSet, pExInfo);
930926
}
931-
#pragma warning restore CS8500
932927
#endif // NATIVEAOT
933928
// currently, RhpCallCatchFunclet will resume after the catch
934929
Debug.Assert(false, "unreachable");
@@ -1209,12 +1204,10 @@ private static void InvokeSecondPass(ref ExInfo exInfo, uint idxStart, uint idxL
12091204
#if NATIVEAOT
12101205
InternalCalls.RhpCallFinallyFunclet(pFinallyHandler, exInfo._frameIter.RegisterSet);
12111206
#else // NATIVEAOT
1212-
#pragma warning disable CS8500
12131207
fixed (EH.ExInfo* pExInfo = &exInfo)
12141208
{
12151209
InternalCalls.RhpCallFinallyFunclet(pFinallyHandler, exInfo._frameIter.RegisterSet, pExInfo);
12161210
}
1217-
#pragma warning restore CS8500
12181211
#endif // NATIVEAOT
12191212
exInfo._idxCurClause = MaxTryRegionIdx;
12201213
}

src/coreclr/nativeaot/System.Private.CoreLib/src/System/GC.NativeAot.cs

-8
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,7 @@ public static unsafe IReadOnlyDictionary<string, object> GetConfigurationVariabl
695695
Configurations = new Dictionary<string, object>()
696696
};
697697

698-
#pragma warning disable CS8500 // takes address of managed type
699698
RuntimeImports.RhEnumerateConfigurationValues(&context, &ConfigCallback);
700-
#pragma warning restore CS8500
701699
return context.Configurations!;
702700
}
703701

@@ -810,9 +808,7 @@ public static unsafe T[] AllocateUninitializedArray<T>(int length, bool pinned =
810808
// for debug builds we always want to call AllocateNewArray to detect AllocateNewArray bugs
811809
#if !DEBUG
812810
// small arrays are allocated using `new[]` as that is generally faster.
813-
#pragma warning disable 8500 // sizeof of managed types
814811
if (length < 2048 / sizeof(T))
815-
#pragma warning restore 8500
816812
{
817813
return new T[length];
818814
}
@@ -832,9 +828,7 @@ static T[] AllocateNewUninitializedArray(int length, bool pinned)
832828
throw new OverflowException();
833829

834830
T[]? array = null;
835-
#pragma warning disable CS8500 // takes address of managed type
836831
RuntimeImports.RhAllocateNewArray(MethodTable.Of<T[]>(), (uint)length, (uint)flags, &array);
837-
#pragma warning restore CS8500
838832
if (array == null)
839833
throw new OutOfMemoryException();
840834

@@ -861,9 +855,7 @@ public static unsafe T[] AllocateArray<T>(int length, bool pinned = false)
861855
throw new OverflowException();
862856

863857
T[]? array = null;
864-
#pragma warning disable CS8500 // takes address of managed type
865858
RuntimeImports.RhAllocateNewArray(MethodTable.Of<T[]>(), (uint)length, (uint)flags, &array);
866-
#pragma warning restore CS8500
867859
if (array == null)
868860
throw new OutOfMemoryException();
869861

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs

+4-16
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,7 @@ public unsafe DynamicInvokeInfo(MethodBase method, IntPtr invokeThunk)
365365
else if (argCount == 1)
366366
{
367367
ByReference br = ByReference.Create(ref parameters[0]);
368-
#pragma warning disable CS8500
369368
void* pByrefStorage = &br;
370-
#pragma warning restore CS8500
371369

372370
// Since no copy of args is required, pass 'parameters' for both arguments.
373371
CheckArguments(parameters, pByrefStorage, parameters);
@@ -410,9 +408,7 @@ private unsafe ref byte InvokeWithManyArguments(
410408
IntPtr* pStorage = stackalloc IntPtr[2 * argCount];
411409
NativeMemory.Clear(pStorage, (nuint)(2 * argCount) * (nuint)sizeof(IntPtr));
412410

413-
#pragma warning disable 8500
414411
void* pByRefStorage = (ByReference*)(pStorage + argCount);
415-
#pragma warning restore 8500
416412

417413
GCFrameRegistration regArgStorage = new((void**)pStorage, (uint)argCount, areByRefs: false);
418414
GCFrameRegistration regByRefStorage = new((void**)pByRefStorage, (uint)argCount, areByRefs: true);
@@ -461,9 +457,7 @@ private unsafe ref byte InvokeWithManyArguments(
461457
IntPtr* pStorage = stackalloc IntPtr[2 * argCount];
462458
NativeMemory.Clear(pStorage, (nuint)(2 * argCount) * (nuint)sizeof(IntPtr));
463459

464-
#pragma warning disable 8500
465460
void* pByRefStorage = (ByReference*)(pStorage + argCount);
466-
#pragma warning restore 8500
467461

468462
GCFrameRegistration regArgStorage = new((void**)pStorage, (uint)argCount, areByRefs: false);
469463
GCFrameRegistration regByRefStorage = new((void**)pByRefStorage, (uint)argCount, areByRefs: true);
@@ -501,9 +495,7 @@ private unsafe ref byte InvokeWithFewArguments(
501495
StackAllocatedArguments argStorage = default;
502496
Span<object?> copyOfParameters = ((Span<object?>)argStorage._args).Slice(0, _argumentCount);
503497
StackAllocatedByRefs byrefStorage = default;
504-
#pragma warning disable CS8500
505498
void* pByRefStorage = (ByReference*)&byrefStorage;
506-
#pragma warning restore CS8500
507499

508500
CheckArguments(copyOfParameters, pByRefStorage, parameters, binderBundle);
509501

@@ -535,9 +527,7 @@ private unsafe ref byte InvokeWithFewArguments(
535527
StackAllocatedArguments argStorage = default;
536528
Span<object?> copyOfParameters = ((Span<object?>)argStorage._args).Slice(0, _argumentCount);
537529
StackAllocatedByRefs byrefStorage = default;
538-
#pragma warning disable CS8500
539530
void* pByRefStorage = (ByReference*)&byrefStorage;
540-
#pragma warning restore CS8500
541531

542532
CheckArguments(copyOfParameters, pByRefStorage, parameters);
543533

@@ -562,9 +552,7 @@ private unsafe ref byte InvokeDirectWithFewArguments(
562552
Debug.Assert(_argumentCount <= MaxStackAllocArgCount);
563553

564554
StackAllocatedByRefs byrefStorage = default;
565-
#pragma warning disable CS8500
566555
void* pByRefStorage = (ByReference*)&byrefStorage;
567-
#pragma warning restore CS8500
568556

569557
// Since no copy of args is required, pass 'parameters' for both arguments.
570558
CheckArguments(parameters, pByRefStorage, parameters);
@@ -686,10 +674,10 @@ private unsafe void CheckArguments(
686674

687675
copyOfParameters[i] = arg!;
688676

689-
#pragma warning disable 8500, 9094
677+
#pragma warning disable 9094
690678
((ByReference*)byrefParameters)[i] = new ByReference(ref (argumentInfo.Transform & Transform.Reference) != 0 ?
691679
ref Unsafe.As<object?, byte>(ref copyOfParameters[i]) : ref arg.GetRawData());
692-
#pragma warning restore 8500, 9094
680+
#pragma warning restore 9094
693681
}
694682
}
695683

@@ -763,10 +751,10 @@ private unsafe void CheckArguments(
763751

764752
copyOfParameters[i] = arg;
765753

766-
#pragma warning disable 8500, 9094
754+
#pragma warning disable 9094
767755
((ByReference*)byrefParameters)[i] = new ByReference(ref (argumentInfo.Transform & Transform.Reference) != 0 ?
768756
ref Unsafe.As<object?, byte>(ref copyOfParameters[i]) : ref arg.GetRawData());
769-
#pragma warning restore 8500, 9094
757+
#pragma warning restore 9094
770758
}
771759
}
772760

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/EnumInfo.cs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
using System.Runtime.CompilerServices;
1010
using System.Runtime.InteropServices;
1111

12-
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
13-
1412
namespace System.Reflection
1513
{
1614
public abstract class EnumInfo

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs

-2
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,8 @@ static ManagedObjectWrapperHolder()
429429
private static bool IsRootedCallback(IntPtr pObj)
430430
{
431431
// We are paused in the GC, so this is safe.
432-
#pragma warning disable CS8500 // Takes a pointer to a managed type
433432
ManagedObjectWrapperHolder* holder = (ManagedObjectWrapperHolder*)&pObj;
434433
return holder->_wrapper->IsRooted;
435-
#pragma warning restore CS8500
436434
}
437435

438436
private readonly ManagedObjectWrapper* _wrapper;

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs

-4
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ ptr is string ||
260260

261261
// Compat note: CLR wouldn't bother with a range check. If someone does this,
262262
// they're likely taking dependency on some CLR implementation detail quirk.
263-
#pragma warning disable 8500 // sizeof of managed types
264263
ArgumentOutOfRangeException.ThrowIfGreaterThan(checked(ofs + sizeof(T)), size, nameof(ofs));
265-
#pragma warning restore 8500
266264

267265
IntPtr nativeBytes = AllocCoTaskMem(size);
268266
NativeMemory.Clear((void*)nativeBytes, (nuint)size);
@@ -340,9 +338,7 @@ ptr is string ||
340338

341339
// Compat note: CLR wouldn't bother with a range check. If someone does this,
342340
// they're likely taking dependency on some CLR implementation detail quirk.
343-
#pragma warning disable 8500 // sizeof of managed types
344341
ArgumentOutOfRangeException.ThrowIfGreaterThan(checked(ofs + sizeof(T)), size, nameof(ofs));
345-
#pragma warning restore 8500
346342

347343
IntPtr nativeBytes = AllocCoTaskMem(size);
348344
NativeMemory.Clear((void*)nativeBytes, (nuint)size);

src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs

-2
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,9 @@ private CompilationResult CompileMethodInternal(IMethodNode methodCodeNodeNeedin
350350
IntPtr exception;
351351
IntPtr nativeEntry;
352352
uint codeSize;
353-
#pragma warning disable CS8500 // takes address of managed type
354353
var result = JitCompileMethod(out exception,
355354
_jit, (IntPtr)(&_this), _unmanagedCallbacks,
356355
ref methodInfo, (uint)CorJitFlag.CORJIT_FLAG_CALL_GETJITFLAGS, out nativeEntry, out codeSize);
357-
#pragma warning restore CS8500
358356
if (exception != IntPtr.Zero)
359357
{
360358
if (_lastException != null)

src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ILCompiler.Reflection.ReadyToRun.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!-- ILSpy requires this assembly to target netstandard2.0 -->
1111
<TargetFramework>netstandard2.0</TargetFramework>
1212
<CLSCompliant>false</CLSCompliant>
13-
<NoWarn>8002,NU1701</NoWarn>
13+
<NoWarn>$(NoWarn);8002;NU1701</NoWarn>
1414
<RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
1515
<OutputPath>$(RuntimeBinDir)</OutputPath>
1616
<Platforms>AnyCPU;x64</Platforms>

src/coreclr/tools/r2rdump/R2RDump.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly>
1010
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
1111
<CLSCompliant>false</CLSCompliant>
12-
<NoWarn>8002,NU1701</NoWarn>
12+
<NoWarn>$(NoWarn);8002;NU1701</NoWarn>
1313
<RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
1414
<OutputPath>$(RuntimeBinDir)/R2RDump</OutputPath>
1515
<RunAnalyzers>false</RunAnalyzers>

src/coreclr/tools/r2rtest/R2RTest.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<OutputType>Exe</OutputType>
66
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
7-
<NoWarn>8002,NU1701</NoWarn>
7+
<NoWarn>$(NoWarn);8002;NU1701</NoWarn>
88
<PlatformTarget>AnyCPU</PlatformTarget>
99
<OutputPath>$(RuntimeBinDir)\R2RTest</OutputPath>
1010
<RunAnalyzers>false</RunAnalyzers>

src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
using System.Runtime.ExceptionServices;
88
using System.Runtime.InteropServices;
99

10-
#pragma warning disable 8500 // takes address of managed type
11-
1210
internal static partial class Interop
1311
{
1412
internal static partial class Sys

src/libraries/Common/src/System/HexConverter.cs

-2
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,8 @@ public static unsafe string ToString(ReadOnlySpan<byte> bytes, Casing casing = C
193193
}
194194
return result.ToString();
195195
#else
196-
#pragma warning disable CS8500 // takes address of managed type
197196
return string.Create(bytes.Length * 2, (RosPtr: (IntPtr)(&bytes), casing), static (chars, args) =>
198197
EncodeToUtf16(*(ReadOnlySpan<byte>*)args.RosPtr, chars, args.casing));
199-
#pragma warning restore CS8500
200198
#endif
201199
}
202200

0 commit comments

Comments
 (0)