File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed
Rubberduck.SettingsProvider Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . ComponentModel ;
2
3
using System . Diagnostics ;
3
4
using System . IO ;
4
5
using System . Linq ;
@@ -76,7 +77,7 @@ public void Save(T toSerialize)
76
77
else
77
78
{
78
79
var parent = doc . Descendants ( ) . FirstOrDefault ( e => e . Name . LocalName . Equals ( RootElement ) ) ;
79
- Debug . Assert ( parent != null ) ;
80
+ // ReSharper disable once PossibleNullReferenceException
80
81
parent . Add ( settings ) ;
81
82
}
82
83
}
@@ -89,22 +90,21 @@ public void Save(T toSerialize)
89
90
90
91
private static XDocument GetConfigurationDoc ( string file )
91
92
{
93
+ XDocument output ;
92
94
try
93
95
{
94
- return XDocument . Load ( file ) ;
95
- }
96
- catch
97
- {
98
- var output = new XDocument ( ) ;
99
- var root = output . Descendants ( RootElement ) . FirstOrDefault ( ) ;
100
- if ( root == null )
96
+ output = XDocument . Load ( file ) ;
97
+ if ( output . Descendants ( ) . FirstOrDefault ( e => e . Name . LocalName . Equals ( RootElement ) ) != null )
101
98
{
102
- output . Add ( new XElement ( RootElement ) ) ;
103
- root = output . Descendants ( RootElement ) . FirstOrDefault ( ) ;
99
+ return output ;
104
100
}
105
- Debug . Assert ( root != null ) ;
106
- return output ;
107
101
}
102
+ // ReSharper disable once EmptyGeneralCatchClause
103
+ catch { }
104
+
105
+ output = new XDocument ( ) ;
106
+ output . Add ( new XElement ( RootElement ) ) ;
107
+ return output ;
108
108
}
109
109
}
110
110
}
You can’t perform that action at this time.
0 commit comments