@@ -12,12 +12,11 @@ public class ReadOnlyCollectionWrapper<T, TCollection>
1212 : DisposableBase , IReadOnlyCollection < T >
1313 where TCollection : class , ICollection < T >
1414{
15- [ SuppressMessage ( "Roslynator" , "RCS1169:Make field read-only." ) ]
16- private TCollection ? _source ;
15+ protected TCollection ? InternalUnsafeSource ;
1716 protected readonly bool SourceOwned ;
1817
1918 protected TCollection InternalSource
20- => _source ?? throw new ObjectDisposedException ( GetType ( ) . ToString ( ) ) ;
19+ => InternalUnsafeSource ?? throw new ObjectDisposedException ( GetType ( ) . ToString ( ) ) ;
2120
2221 /// <summary>
2322 /// Constructs a wrapper for read-only access to a collection.
@@ -31,7 +30,7 @@ protected TCollection InternalSource
3130 [ ExcludeFromCodeCoverage ]
3231 public ReadOnlyCollectionWrapper ( TCollection source , bool owner = false )
3332 {
34- _source = source ?? throw new ArgumentNullException ( nameof ( source ) ) ;
33+ InternalUnsafeSource = source ?? throw new ArgumentNullException ( nameof ( source ) ) ;
3534 SourceOwned = owner ;
3635 }
3736
@@ -102,7 +101,7 @@ public virtual void Export(ICollection<T> to)
102101 [ ExcludeFromCodeCoverage ]
103102 protected override void OnDispose ( )
104103 {
105- var source = Nullify ( ref _source ! ) ;
104+ var source = Nullify ( ref InternalUnsafeSource ! ) ;
106105 if ( SourceOwned && source is IDisposable d ) d . Dispose ( ) ;
107106 }
108107
@@ -117,7 +116,7 @@ public TCollection ExtractAndDispose()
117116 if ( SourceOwned ) throw new NotSupportedException ( "The underlying collection is owned by this wrapper." ) ;
118117 using ( this )
119118 {
120- return Nullify ( ref _source ! ) ;
119+ return Nullify ( ref InternalUnsafeSource ! ) ;
121120 }
122121 }
123122 #endregion
0 commit comments