@@ -35,6 +35,7 @@ private static class DocAttributeNames
35
35
{
36
36
public static readonly XName _visited = XName . Get ( nameof ( _visited ) ) ;
37
37
public static readonly XName _trimmed = XName . Get ( nameof ( _trimmed ) ) ;
38
+ public static readonly XName _gencode = XName . Get ( nameof ( _gencode ) ) ;
38
39
public static readonly XName Cref = XName . Get ( "cref" ) ;
39
40
public static readonly XName Name = XName . Get ( "name" ) ;
40
41
public static readonly XName Path = XName . Get ( "path" ) ;
@@ -89,7 +90,6 @@ static XDocument loadDoc(string path)
89
90
asm . Modules
90
91
. SelectMany ( m => m . Types )
91
92
. SelectManyRecursive ( t => t . NestedTypes )
92
- . Where ( t => ! t . IsCompilerGenerated ( ) || t . IsNamespaceDocPlaceholder ( ) )
93
93
. ToList ( )
94
94
;
95
95
@@ -107,8 +107,14 @@ static XDocument loadDoc(string path)
107
107
while ( ( mem = docMembers . Elements ( DocElementNames . Member ) . FirstOrDefault ( isInheritDocCandidate ) ) is not null )
108
108
replaceInheritDoc ( docPath , mem , docMap , docMembers , refDocs , logger ) ;
109
109
110
- foreach ( var md in docMembers . Elements ( DocElementNames . Member ) . Where ( m => m . HasAttribute ( DocAttributeNames . _visited ) ) )
111
- md . SetAttributeValue ( DocAttributeNames . _visited , null ) ;
110
+ foreach ( var md in docMembers . Elements ( DocElementNames . Member ) )
111
+ {
112
+ if ( md . HasAttribute ( DocAttributeNames . _visited ) )
113
+ md . SetAttributeValue ( DocAttributeNames . _visited , null ) ;
114
+
115
+ if ( md . HasAttribute ( DocAttributeNames . _gencode ) )
116
+ md . SetAttributeValue ( DocAttributeNames . _gencode , null ) ;
117
+ }
112
118
113
119
if ( trimLevel > ApiLevel . None )
114
120
{
@@ -143,14 +149,20 @@ private static IDictionary<string, IEnumerable<DocMatch>> generateDocMap(IList<T
143
149
string typeID = t . GetDocID ( ) ;
144
150
var memDocs = findDocsByID ( docMembers , typeID ) ;
145
151
146
- // Several tools include this hack to output namespace documentation
147
- // https://stackoverflow.com/questions/793210/xml-documentation-for-a-namespace
148
- if ( t . IsCompilerGenerated ( ) && t . IsNamespaceDocPlaceholder ( ) )
152
+ if ( t . IsGeneratedCode ( ) )
149
153
{
150
- foreach ( var md in memDocs )
151
- md . SetAttributeValue ( DocAttributeNames . Name , "N:" + t . Namespace ) ;
154
+ // Several tools include this hack to output namespace documentation
155
+ // https://stackoverflow.com/questions/793210/xml-documentation-for-a-namespace
156
+ if ( t . IsNamespaceDocPlaceholder ( ) )
157
+ {
158
+ foreach ( var md in memDocs )
159
+ md . SetAttributeValue ( DocAttributeNames . Name , "N:" + t . Namespace ) ;
152
160
153
- continue ;
161
+ continue ;
162
+ }
163
+
164
+ foreach ( var md in memDocs )
165
+ md . SetAttributeValue ( DocAttributeNames . _gencode , true ) ;
154
166
}
155
167
156
168
if ( t . GetApiLevel ( ) <= trimLevel )
@@ -183,7 +195,7 @@ private static IDictionary<string, IEnumerable<DocMatch>> generateDocMap(IList<T
183
195
dml . Add ( new DocMatch ( cref , t ) ) ;
184
196
}
185
197
186
- foreach ( var ( m , idx , memID ) in t . Methods . Where ( m => ! m . IsCompilerGenerated ( ) || m . IsEventMethod ( ) || m . IsPropertyMethod ( ) ) . SelectMany ( m => m . GetDocID ( ) . Select ( ( d , i ) => ( m , i , d ) ) ) )
198
+ foreach ( var ( m , idx , memID ) in t . Methods . SelectMany ( m => m . GetDocID ( ) . Select ( ( d , i ) => ( m , i , d ) ) ) )
187
199
{
188
200
if ( docMap . ContainsKey ( memID ) )
189
201
continue ;
@@ -209,6 +221,12 @@ private static IDictionary<string, IEnumerable<DocMatch>> generateDocMap(IList<T
209
221
md . SetAttributeValue ( DocAttributeNames . _trimmed , true ) ;
210
222
}
211
223
224
+ if ( m . IsGeneratedCode ( ) )
225
+ {
226
+ foreach ( var md in methDocs )
227
+ md . SetAttributeValue ( DocAttributeNames . _gencode , true ) ;
228
+ }
229
+
212
230
if ( methDocs . Descendants ( DocElementNames . InheritDoc ) . Any ( ) )
213
231
{
214
232
logger . Write ( ILogger . Severity . Diag , "Processing DocID: " + memID ) ;
@@ -257,7 +275,7 @@ private static void replaceInheritDoc(string file, XElement mem, IDictionary<str
257
275
string ? cref = ( string ) inh . Attribute ( DocAttributeNames . Cref ) ?? dml ? . FirstOrDefault ( ) ? . Cref ;
258
276
if ( string . IsNullOrEmpty ( cref ) )
259
277
{
260
- if ( ! mem . HasAttribute ( DocAttributeNames . _trimmed ) )
278
+ if ( ! mem . HasAttribute ( DocAttributeNames . _trimmed ) && ! mem . HasAttribute ( DocAttributeNames . _gencode ) )
261
279
logger . Warn ( ErrorCodes . NoBase , file , mem . SourceLine ( ) , mem . SourceColumn ( ) , "Cref not present and no base could be found for: " + memID ) ;
262
280
263
281
continue ;
@@ -275,7 +293,7 @@ private static void replaceInheritDoc(string file, XElement mem, IDictionary<str
275
293
doc = findDocsByID ( members , cref ! ) . FirstOrDefault ( ) ;
276
294
if ( doc is null )
277
295
{
278
- if ( ! mem . HasAttribute ( DocAttributeNames . _trimmed ) )
296
+ if ( ! mem . HasAttribute ( DocAttributeNames . _trimmed ) && ! mem . HasAttribute ( DocAttributeNames . _gencode ) )
279
297
logger . Warn ( ErrorCodes . NoDocs , file , mem . SourceLine ( ) , mem . SourceColumn ( ) , "No matching documentation could be found for: " + memID + ", which attempts to inherit from: " + cref ) ;
280
298
281
299
continue ;
@@ -364,7 +382,7 @@ static void removeDoc(List<XNode> nodes, int pos)
364
382
if ( nodes . Count > 0 && nodes [ 0 ] . IsWhiteSpace ( ) )
365
383
nodes . RemoveAt ( 0 ) ;
366
384
367
- if ( nodes . Count == 0 && ! inh . Ancestors ( DocElementNames . Member ) . Any ( m => m . HasAttribute ( DocAttributeNames . _trimmed ) ) )
385
+ if ( nodes . Count == 0 && ! inh . Ancestors ( DocElementNames . Member ) . Any ( m => m . HasAttribute ( DocAttributeNames . _trimmed ) || m . HasAttribute ( DocAttributeNames . _gencode ) ) )
368
386
logger . Warn ( ErrorCodes . NoNode , file , inh . SourceLine ( ) , inh . SourceColumn ( ) , "No matching non-duplicate nodes found for: " + memID + ", which attempts to inherit from: " + dm . Cref + " path=\" " + xpath + "\" " ) ;
369
387
else
370
388
inh . ReplaceWith ( nodes ) ;
0 commit comments