@@ -24,17 +24,17 @@ public DebugView(Array<T> arr)
2424
2525 protected List < T > Inner ;
2626
27- public virtual AttributeList Owner
27+ public virtual AttributeList ? Owner
2828 {
2929 get => _Owner ;
3030 internal set
3131 {
3232 _Owner = value ;
3333 }
3434 }
35- AttributeList _Owner ;
35+ AttributeList ? _Owner ;
3636
37- protected Datamodel OwnerDatamodel => Owner ? . Owner ;
37+ protected Datamodel ? OwnerDatamodel => Owner ? . Owner ;
3838
3939 internal Array ( )
4040 {
@@ -94,40 +94,52 @@ public void CopyTo(T[] array, int offset)
9494
9595 public object SyncRoot => throw new NotImplementedException ( ) ;
9696
97- object IList . this [ int index ] { get => throw new NotImplementedException ( ) ; set => throw new NotImplementedException ( ) ; }
97+ object ? IList . this [ int index ] { get => throw new NotImplementedException ( ) ; set => throw new NotImplementedException ( ) ; }
9898
9999 public bool Remove ( T item ) => Inner . Remove ( item ) ;
100100
101101 public IEnumerator < T > GetEnumerator ( ) => Inner . GetEnumerator ( ) ;
102102 IEnumerator IEnumerable . GetEnumerator ( ) => Inner . GetEnumerator ( ) ;
103103
104104 #region IList
105- int IList . Add ( object value )
105+ int IList . Add ( object ? value )
106106 {
107- Add ( ( T ) value ) ;
107+ if ( value is not null )
108+ Add ( ( T ) value ) ;
108109 return Count ;
109110 }
110111
111- bool IList . Contains ( object value )
112+ bool IList . Contains ( object ? value )
112113 {
114+ if ( value is null )
115+ return false ;
113116 return Contains ( ( T ) value ) ;
114117 }
115118
116- int IList . IndexOf ( object value )
119+ int IList . IndexOf ( object ? value )
117120 {
121+ if ( value is null )
122+ throw new InvalidOperationException ( "Trying to get the index of a null object" ) ;
123+
118124 return IndexOf ( ( T ) value ) ;
119125 }
120126
121- void IList . Insert ( int index , object value )
127+ void IList . Insert ( int index , object ? value )
122128 {
129+ if ( value is null )
130+ throw new InvalidOperationException ( "Trying to insert a null object" ) ;
131+
123132 Insert ( index , ( T ) value ) ;
124133 }
125134
126135 bool IList . IsFixedSize { get { return false ; } }
127136 bool IList . IsReadOnly { get { return false ; } }
128137
129- void IList . Remove ( object value )
138+ void IList . Remove ( object ? value )
130139 {
140+ if ( value is null )
141+ throw new InvalidOperationException ( "Trying to remove a null object" ) ;
142+
131143 Remove ( ( T ) value ) ;
132144 }
133145
@@ -156,7 +168,7 @@ public ElementArray(int capacity)
156168 /// </summary>
157169 internal IEnumerable < Element > RawList { get { foreach ( var elem in Inner ) yield return elem ; } }
158170
159- public override AttributeList Owner
171+ public override AttributeList ? Owner
160172 {
161173 get => base . Owner ;
162174 internal set
@@ -191,7 +203,7 @@ protected override void Insert_Internal(int index, Element item)
191203 throw new ElementOwnershipException ( ) ;
192204 }
193205
194- base . Insert_Internal ( index , item ) ;
206+ base . Insert_Internal ( index , item ! ) ;
195207 }
196208
197209 public override Element this [ int index ]
@@ -210,6 +222,12 @@ public override Element this[int index]
210222 throw new DestubException ( this , index , err ) ;
211223 }
212224 }
225+
226+ if ( elem is null )
227+ {
228+ throw new InvalidOperationException ( "Element at specified index is null" ) ;
229+ }
230+
213231 return elem ;
214232 }
215233 set => base [ index ] = value ;
0 commit comments