File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 11<Project >
22 <PropertyGroup >
3- <LangVersion >12 </LangVersion >
3+ <LangVersion >13 </LangVersion >
44 <Nullable >enable</Nullable >
55 <TreatWarningsAsErrors >true</TreatWarningsAsErrors >
66 <AnalysisLevel >8.0-all</AnalysisLevel >
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public static IEnumerable<T> Memoize<T>(this IEnumerable<T> source) =>
6565 sealed class MemoizedEnumerable < T > ( IEnumerable < T > sequence ) : IEnumerable < T > , IDisposable
6666 {
6767 List < T > ? cache ;
68- readonly object locker = new ( ) ;
68+ readonly Lock locker = new ( ) ;
6969 readonly IEnumerable < T > source = sequence ?? throw new ArgumentNullException ( nameof ( sequence ) ) ;
7070 IEnumerator < T > ? sourceEnumerator ;
7171 int ? errorIndex ;
@@ -77,7 +77,9 @@ public IEnumerator<T> GetEnumerator()
7777 {
7878 lock ( this . locker )
7979 {
80+ #pragma warning disable CA1508 // Avoid dead conditional code
8081 if ( this . cache == null )
82+ #pragma warning restore CA1508 // Avoid dead conditional code
8183 {
8284 this . error ? . Throw ( ) ;
8385
Original file line number Diff line number Diff line change 1+ #if NET9_0_OR_GREATER
2+ // https://learn.microsoft.com/dotnet/csharp/language-reference/statements/lock#guidelines
3+ global using Lock = System . Threading . Lock ;
4+ #else
5+ // For why "System.Object" instead of "object", see:
6+ // https://github.com/dotnet/runtime/issues/110242
7+ global using Lock = System . Object ;
8+ #endif
You can’t perform that action at this time.
0 commit comments