2121using System . Collections . Specialized ;
2222using System . ComponentModel ;
2323using System . Diagnostics ;
24+ using System . Diagnostics . CodeAnalysis ;
2425using System . Linq ;
2526
26- #nullable disable
27-
2827using ICSharpCode . ILSpyX . TreeView . PlatformAbstractions ;
2928
3029namespace ICSharpCode . ILSpyX . TreeView
3130{
3231 public partial class SharpTreeNode : INotifyPropertyChanged
3332 {
33+ [ AllowNull ]
3434 protected static ITreeNodeImagesProvider ImagesProvider { get ; private set ; }
3535 public static void SetImagesProvider ( ITreeNodeImagesProvider provider ) => ImagesProvider = provider ;
3636
37- SharpTreeNodeCollection modelChildren ;
38- internal SharpTreeNode modelParent ;
37+ SharpTreeNodeCollection ? modelChildren ;
38+ internal SharpTreeNode ? modelParent ;
3939 bool isVisible = true ;
4040
4141 void UpdateIsVisible ( bool parentIsVisible , bool updateFlattener )
@@ -53,7 +53,7 @@ void UpdateIsVisible(bool parentIsVisible, bool updateFlattener)
5353 node = node . listParent ;
5454 }
5555 // Remember the removed nodes:
56- List < SharpTreeNode > removedNodes = null ;
56+ List < SharpTreeNode > ? removedNodes = null ;
5757 if ( updateFlattener && ! newIsVisible )
5858 {
5959 removedNodes = VisibleDescendantsAndSelf ( ) . ToList ( ) ;
@@ -118,19 +118,19 @@ public SharpTreeNodeCollection Children {
118118 }
119119 }
120120
121- public SharpTreeNode Parent {
121+ public SharpTreeNode ? Parent {
122122 get { return modelParent ; }
123123 }
124124
125- public virtual object Text {
125+ public virtual object ? Text {
126126 get { return null ; }
127127 }
128128
129- public virtual object Icon {
129+ public virtual object ? Icon {
130130 get { return null ; }
131131 }
132132
133- public virtual object ToolTip {
133+ public virtual object ? ToolTip {
134134 get { return null ; }
135135 }
136136
@@ -199,7 +199,7 @@ public virtual void OnChildrenChanged(NotifyCollectionChangedEventArgs e)
199199 while ( removeEnd . modelChildren != null && removeEnd . modelChildren . Count > 0 )
200200 removeEnd = removeEnd . modelChildren . Last ( ) ;
201201
202- List < SharpTreeNode > removedNodes = null ;
202+ List < SharpTreeNode > ? removedNodes = null ;
203203 int visibleIndexOfRemoval = 0 ;
204204 if ( node . isVisible )
205205 {
@@ -221,11 +221,11 @@ public virtual void OnChildrenChanged(NotifyCollectionChangedEventArgs e)
221221 }
222222 if ( e . NewItems != null )
223223 {
224- SharpTreeNode insertionPos ;
224+ SharpTreeNode ? insertionPos ;
225225 if ( e . NewStartingIndex == 0 )
226226 insertionPos = null ;
227227 else
228- insertionPos = modelChildren [ e . NewStartingIndex - 1 ] ;
228+ insertionPos = modelChildren ? [ e . NewStartingIndex - 1 ] ;
229229
230230 foreach ( SharpTreeNode node in e . NewItems )
231231 {
@@ -260,7 +260,7 @@ public virtual void OnChildrenChanged(NotifyCollectionChangedEventArgs e)
260260
261261 #region Expanding / LazyLoading
262262
263- public virtual object ExpandedIcon {
263+ public virtual object ? ExpandedIcon {
264264 get { return Icon ; }
265265 }
266266
@@ -371,13 +371,13 @@ public IEnumerable<SharpTreeNode> VisibleDescendantsAndSelf()
371371
372372 public IEnumerable < SharpTreeNode > Ancestors ( )
373373 {
374- for ( SharpTreeNode n = this . Parent ; n != null ; n = n . Parent )
374+ for ( SharpTreeNode ? n = this . Parent ; n != null ; n = n . Parent )
375375 yield return n ;
376376 }
377377
378378 public IEnumerable < SharpTreeNode > AncestorsAndSelf ( )
379379 {
380- for ( SharpTreeNode n = this ; n != null ; n = n . Parent )
380+ for ( SharpTreeNode ? n = this ; n != null ; n = n . Parent )
381381 yield return n ;
382382 }
383383
@@ -402,7 +402,7 @@ public bool IsEditing {
402402 }
403403 }
404404
405- public virtual string LoadEditText ( )
405+ public virtual string ? LoadEditText ( )
406406 {
407407 return null ;
408408 }
@@ -699,7 +699,7 @@ void RaiseIsLastChangedIfNeeded(NotifyCollectionChangedEventArgs e)
699699
700700 #region INotifyPropertyChanged Members
701701
702- public event PropertyChangedEventHandler PropertyChanged ;
702+ public event PropertyChangedEventHandler ? PropertyChanged ;
703703
704704 public void RaisePropertyChanged ( string name )
705705 {
@@ -725,10 +725,10 @@ public virtual void ActivateItemSecondary(IPlatformRoutedEventArgs e)
725725 {
726726 }
727727
728- public override string ToString ( )
728+ public override string ? ToString ( )
729729 {
730730 // used for keyboard navigation
731- object text = this . Text ;
731+ object ? text = this . Text ;
732732 return text != null ? text . ToString ( ) : string . Empty ;
733733 }
734734 }
0 commit comments