Discard generated Assemblies from JustMyCode

JustMyCode Definition ND3000 Defining JustMyCode

A notmycode query: matched assemblies (and their namespaces, types, methods, fields) are removed from the JustMyCode code base view used by most default queries and rules.

It matches assemblies tagged System.CodeDom.Compiler.GeneratedCodeAttribute, ASP.NET Core Razor .Views.dll assemblies, and assemblies with no C#, VB or F# code. Enrich it to discard your own generated assemblies.

notmycode queries run before other queries and rules; modifying one re-runs the queries relying on JustMyCode. Several notmycode assemblies queries cumulate. Documentation: https://www.ndepend.com/docs/cqlinq-syntax#NotMyCode

CQLinq source

This JustMyCode definition is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Discard generated Assemblies from JustMyCode</Name>
// <Id>ND3000:DiscardGeneratedAssembliesFromJustMyCode</Id>

notmycode
from a in Application.Assemblies where 

   // Assemblies generated for Xsl IL compilation for example are tagged with this attribute
   a.HasAttribute ("System.CodeDom.Compiler.GeneratedCodeAttribute".AllowNoMatch())

   // Consider '.Views.dll' ASP.NET Core Razor assemblies as notmycode
   // because they are generated by the compiler
|| a.SimpleName.EndsWith(".views", StringComparison.OrdinalIgnoreCase) &&
   a.AssembliesUsed.Any(aUsed => aUsed.SimpleName.EqualsAny(
      "microsoft.aspnetcore.razor", "microsoft.aspnetcore.mvc.razor"
      , StringComparison.OrdinalIgnoreCase))   

   // Don't consider assemblies with no types
|| a.ChildTypes.FirstOrDefault() == null

select a

//<Desc>
// A **notmycode** query: matched assemblies (and their namespaces, types,
// methods, fields) are removed from the *JustMyCode* code base view used by
// most default queries and rules.
//
// It matches assemblies tagged
// *System.CodeDom.Compiler.GeneratedCodeAttribute*, ASP.NET Core Razor
// *.Views.dll* assemblies, and assemblies with no C#, VB or F# code. Enrich
// it to discard your own generated assemblies.
//
// *notmycode* queries run before other queries and rules; modifying one
// re-runs the queries relying on *JustMyCode*. Several *notmycode*
// assemblies queries cumulate. Documentation:
// https://www.ndepend.com/docs/cqlinq-syntax#NotMyCode
//</Desc>

Defining JustMyCode: all 7 items