@@ -39,18 +39,25 @@ internal Dictionary<Type, TypeDocumentation> Parse()
3939
4040 private void Parse ( XmlNode node )
4141 {
42- if ( node . Attributes is null || node . Attributes . Count == 0 )
43- throw new InvalidOperationException ( "Invalid XML node." ) ;
42+ try
43+ {
44+ if ( node . Attributes is null || node . Attributes . Count == 0 )
45+ throw new InvalidOperationException ( "Invalid XML node." ) ;
4446
45- var name = ( node . Attributes [ "name" ] ? . Value )
46- ?? throw new InvalidOperationException ( $ "No 'name' attribute found in XML node '{ node . Value } '.") ;
47+ var name = ( node . Attributes [ "name" ] ? . Value )
48+ ?? throw new InvalidOperationException ( $ "No 'name' attribute found in XML node '{ node . Value } '.") ;
4749
48- switch ( name [ 0 ] )
50+ switch ( name [ 0 ] )
51+ {
52+ case 'T' : ParseTypeNode ( node , name [ 2 ..] ) ; break ;
53+ case 'P' : ParsePropertyNode ( node , name [ 2 ..] ) ; break ;
54+ case 'F' : ParseFieldNode ( node , name [ 2 ..] ) ; break ;
55+ case 'M' : ParseMethodNode ( node , name [ 2 ..] ) ; break ;
56+ }
57+ }
58+ catch ( Exception ex )
4959 {
50- case 'T' : ParseTypeNode ( node , name [ 2 ..] ) ; break ;
51- case 'P' : ParsePropertyNode ( node , name [ 2 ..] ) ; break ;
52- case 'F' : ParseFieldNode ( node , name [ 2 ..] ) ; break ;
53- case 'M' : ParseMethodNode ( node , name [ 2 ..] ) ; break ;
60+ // temporary workaround
5461 }
5562 }
5663
@@ -90,6 +97,13 @@ private FieldDocumentation ParseFieldNode(XmlNode node, string name)
9097
9198 private static MethodInfo ? GetMethod ( Type type , string name , IReadOnlyCollection < string > parameters )
9299 {
100+ // temporary workaround for ctors and generic type nodes,
101+ // until proper handling is implemented
102+ if ( IsCtor ( name ) || IsGeneric ( name ) )
103+ {
104+ return null ;
105+ }
106+
93107 return type . GetMethods ( )
94108 . Where ( method => method . Name == name )
95109 . Where ( method =>
@@ -114,6 +128,16 @@ private FieldDocumentation ParseFieldNode(XmlNode node, string name)
114128 . SingleOrDefault ( ) ;
115129 }
116130
131+ private static bool IsGeneric ( string value )
132+ {
133+ return value . Contains ( '`' ) ;
134+ }
135+
136+ private static bool IsCtor ( string value )
137+ {
138+ return value . EndsWith ( "#ctor" , StringComparison . Ordinal ) ;
139+ }
140+
117141 private TDocumentation ParseMemberNode < TMember , TDocumentation > ( string name , Func < Type , string , IReadOnlyCollection < string > , TMember ? > getMember , Func < TMember , TDocumentation > getDocumentation )
118142 where TMember : MemberInfo
119143 where TDocumentation : MemberDocumentation < TMember >
@@ -122,8 +146,7 @@ private TDocumentation ParseMemberNode<TMember, TDocumentation>(string name, Fun
122146 var parameters = ResolveMethodParameters ( name ) ;
123147
124148 var memberInfo = getMember . Invoke ( type , memberName , parameters )
125- ?? throw new InvalidOperationException (
126- $ "Member '{ memberName } ' not found in type '{ type . Name } '.") ;
149+ ?? throw new InvalidOperationException ( $ "Member '{ memberName } ' not found in type '{ type . Name } '.") ;
127150
128151 var typeDocumentation = ResolveTypeDocumentation ( type ) ;
129152
@@ -140,21 +163,21 @@ private static IReadOnlyCollection<string> ResolveMethodParameters(string name)
140163
141164 if ( startIndex == - 1 )
142165 {
143- return Array . Empty < string > ( ) ;
166+ return [ ] ;
144167 }
145168
146169 var endIndex = name . LastIndexOf ( ')' ) ;
147170
148171 if ( endIndex <= startIndex )
149172 {
150- return Array . Empty < string > ( ) ;
173+ return [ ] ;
151174 }
152175
153176 var parametersString = name . Substring ( startIndex + 1 , endIndex - startIndex - 1 ) ;
154177
155178 if ( string . IsNullOrWhiteSpace ( parametersString ) )
156179 {
157- return Array . Empty < string > ( ) ;
180+ return [ ] ;
158181 }
159182
160183 var result = parametersString
0 commit comments