NDepend for HasAttribute ("System.CodeDom.Compiler.GeneratedCodeAttribute".AllowNoMatch())

StackOverflow https://stackoverflow.com/questions/17533060

  •  02-06-2022
  •  | 
  •  

Question

I have a modified custom rule as provided below, and I got a query syntax error for "System.CodeDom.Compiler.GeneratedCodeAttribute" Not as a valid type name. (I also got same error for our other custom attributes). I tried to use AllowNoMatch() with it to avoid syntax error, but then it has no effect on my result.

Another attribute "System.Diagnostics.DebuggerNonUserCodeAttribute" works just fine.

Do I miss anything?

=============================================================

// <Name>Methods too big (LOC)</Name>
warnif count > 0 from m in JustMyCode.Methods where 
   m.NbLinesOfCode > 30 
   && !m.ParentType.HasAttribute( "System.Diagnostics.DebuggerNonUserCodeAttribute" )
   && !m.ParentType.HasAttribute( "System.CodeDom.Compiler.GeneratedCodeAttribute" )

   orderby m.NbLinesOfCode descending,
       m.NbILInstructions descending
select new { m, m.NbLinesOfCode, m.NbILInstructions }

// Methods where NbLinesOfCode > 30 or NbILInstructions > 200
// are extremely complex and should be split in smaller methods.
// See the definition of the NbLinesOfCode metric here 
// http://www.ndepend.com/Metrics.aspx#NbLinesOfCode
Était-ce utile?

La solution

I found out the problem was having an issue to include the third party assembly file (System.dll in this case) where I have two conflict System.dll files.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top