Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,10 @@ public static void PulseAll(object obj)
ObjPulseAll(obj);
}

#pragma warning disable CA2252 // Opt in to preview features before using them (Lock)
/// <summary>
/// Gets the number of times there was contention upon trying to take a <see cref="Monitor"/>'s lock so far.
/// </summary>
public static long LockContentionCount => GetLockContentionCount() + Lock.ContentionCount;
#pragma warning restore CA2252

[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ObjectNative_GetMonitorLockContentionCount")]
private static partial long GetLockContentionCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<!-- AD0001 : https://github.com/dotnet/runtime/issues/90356 -->
<NoWarn>$(NoWarn);AD0001</NoWarn>
<!-- CA2252: Opt in to preview features before using them (Lock) -->
<EnablePreviewFeatures>true</EnablePreviewFeatures>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<SharedGUID>c5ed3c1d-b572-46f1-8f96-522a85ce1179</SharedGUID>
<StringResourcesName Condition="'$(StringResourcesName)' == ''">System.Private.CoreLib.Strings</StringResourcesName>
<GenerateResourcesSubstitutions>true</GenerateResourcesSubstitutions>

<!-- CA2252: Opt in to preview features before using them (for System.Threading.Lock) -->
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also delete CA2252 pragmas from under src/libraries/System.Private.CoreLib

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<EnablePreviewFeatures>true</EnablePreviewFeatures>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ private void ContentionLockCreated(nint LockID, nint AssociatedObjectID, ushort
LogContentionLockCreated(LockID, AssociatedObjectID, ClrInstanceID);
}

#pragma warning disable CA2252 // Opt in to preview features before using them (Lock)
[NonEvent]
[MethodImpl(MethodImplOptions.NoInlining)]
public void ContentionLockCreated(Lock lockObj) => ContentionLockCreated(lockObj.LockIdForEvents, lockObj.ObjectIdForEvents);
#pragma warning restore CA2252

[Event(81, Level = EventLevel.Informational, Message = Messages.ContentionStart, Task = Tasks.Contention, Opcode = EventOpcode.Start, Version = 2, Keywords = Keywords.ContentionKeyword)]
private void ContentionStart(
Expand All @@ -101,7 +99,6 @@ private void ContentionStart(
LogContentionStart(ContentionFlags, ClrInstanceID, LockID, AssociatedObjectID, LockOwnerThreadID);
}

#pragma warning disable CA2252 // Opt in to preview features before using them (Lock)
[NonEvent]
[MethodImpl(MethodImplOptions.NoInlining)]
public void ContentionStart(Lock lockObj) =>
Expand All @@ -111,7 +108,6 @@ public void ContentionStart(Lock lockObj) =>
lockObj.LockIdForEvents,
lockObj.ObjectIdForEvents,
lockObj.OwningThreadId);
#pragma warning restore CA2252

[Event(91, Level = EventLevel.Informational, Message = Messages.ContentionStop, Task = Tasks.Contention, Opcode = EventOpcode.Stop, Version = 1, Keywords = Keywords.ContentionKeyword)]
private void ContentionStop(ContentionFlagsMap ContentionFlags, ushort ClrInstanceID, double DurationNs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ private unsafe void ContentionLockCreated(nint LockID, nint AssociatedObjectID,
WriteEventCore(90, 3, data);
}

#pragma warning disable CA2252 // Opt in to preview features before using them (Lock)
[NonEvent]
[MethodImpl(MethodImplOptions.NoInlining)]
public void ContentionLockCreated(Lock lockObj) => ContentionLockCreated(lockObj.LockIdForEvents, lockObj.ObjectIdForEvents);
#pragma warning restore CA2252

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
[Event(81, Level = EventLevel.Informational, Message = Messages.ContentionStart, Task = Tasks.Contention, Opcode = EventOpcode.Start, Version = 2, Keywords = Keywords.ContentionKeyword)]
Expand Down Expand Up @@ -131,7 +129,6 @@ private unsafe void ContentionStart(
WriteEventCore(81, 3, data);
}

#pragma warning disable CA2252 // Opt in to preview features before using them (Lock)
[NonEvent]
[MethodImpl(MethodImplOptions.NoInlining)]
public void ContentionStart(Lock lockObj) =>
Expand All @@ -141,7 +138,6 @@ public void ContentionStart(Lock lockObj) =>
lockObj.LockIdForEvents,
lockObj.ObjectIdForEvents,
lockObj.OwningThreadId);
#pragma warning restore CA2252

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
[Event(91, Level = EventLevel.Informational, Message = Messages.ContentionStop, Task = Tasks.Contention, Opcode = EventOpcode.Stop, Version = 1, Keywords = Keywords.ContentionKeyword)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ private static void ReliableEnterTimeout(object obj, int timeout, ref bool lockT
try_enter_with_atomic_var(obj, timeout, true, ref lockTaken);
}

#pragma warning disable CA2252 // Opt in to preview features before using them (Lock)
public static long LockContentionCount => Monitor_get_lock_contention_count() + Lock.ContentionCount;
#pragma warning restore CA2252

[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern long Monitor_get_lock_contention_count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace System.Threading
//
internal partial class TimerQueue
{
public static long TickCount64 => Environment.TickCount64;
private static long TickCount64 => Environment.TickCount64;
private static List<TimerQueue>? s_scheduledTimers;
private static List<TimerQueue>? s_scheduledTimersToFire;
private static long s_shortestDueTimeMs = long.MaxValue;
Expand Down