File tree 3 files changed +12
-2
lines changed
3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
1
<Project >
2
2
<PropertyGroup >
3
- <LangVersion >12 </LangVersion >
3
+ <LangVersion >13 </LangVersion >
4
4
<Nullable >enable</Nullable >
5
5
<TreatWarningsAsErrors >true</TreatWarningsAsErrors >
6
6
<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) =>
65
65
sealed class MemoizedEnumerable < T > ( IEnumerable < T > sequence ) : IEnumerable < T > , IDisposable
66
66
{
67
67
List < T > ? cache ;
68
- readonly object locker = new ( ) ;
68
+ readonly Lock locker = new ( ) ;
69
69
readonly IEnumerable < T > source = sequence ?? throw new ArgumentNullException ( nameof ( sequence ) ) ;
70
70
IEnumerator < T > ? sourceEnumerator ;
71
71
int ? errorIndex ;
@@ -77,7 +77,9 @@ public IEnumerator<T> GetEnumerator()
77
77
{
78
78
lock ( this . locker )
79
79
{
80
+ #pragma warning disable CA1508 // Avoid dead conditional code
80
81
if ( this . cache == null )
82
+ #pragma warning restore CA1508 // Avoid dead conditional code
81
83
{
82
84
this . error ? . Throw ( ) ;
83
85
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