Methods that should be declared as 'public' in C#, 'Public' in VB.NET
Lists internal methods consumed outside their assembly thanks to System.Runtime.CompilerServices.InternalsVisibleToAttribute, via the property NDepend.CodeModel.IMember.ShouldBePublic: https://www.ndepend.com/api/NDepend.CodeModel.IMember.html#NDepend_CodeModel_IMember_ShouldBePublic
A query (not a rule): it informs that the code relies on the peculiar InternalsVisibleToAttribute behavior, not that methods should be public.
A query (not a rule): it informs that the code relies on the peculiar InternalsVisibleToAttribute behavior, not that methods should be public.
CQLinq source
This code query 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>Methods that should be declared as 'public' in C#, 'Public' in VB.NET</Name>
from m in Application.Methods where
m.ShouldBePublic
let usedInAssemblies = m.MethodsCallingMe.ParentAssemblies().Except(m.ParentAssembly)
select new {
m,
m.ParentAssembly,
usedInAssemblies,
m.MethodsCallingMe
}
//<Desc>
// Lists *internal* methods consumed outside their assembly thanks to
// *System.Runtime.CompilerServices.InternalsVisibleToAttribute*, via the
// property *NDepend.CodeModel.IMember.ShouldBePublic*:
// https://www.ndepend.com/api/NDepend.CodeModel.IMember.html#NDepend_CodeModel_IMember_ShouldBePublic
//
// A query (not a rule): it informs that the code relies on the peculiar
// *InternalsVisibleToAttribute* behavior, not that methods should be public.
//</Desc>
Open in the interactive Rules Explorer · All default rules
Visibility: all 12 items
- Methods that could have a lower visibility ND1800
- Types that could have a lower visibility ND1801
- Fields that could have a lower visibility ND1802
- Types that could be declared as private, nested in a parent type ND1803
- Avoid publicly visible constant fields ND1804
- Fields should be declared as private or protected ND1805
- Constructors of abstract classes should be declared as protected or private ND1806
- Avoid public methods not publicly visible ND1807
- Event handler methods should be declared as private or protected ND1808
- Wrong usage of CannotDecreaseVisibilityAttribute ND1809
- Exception classes should be declared as public ND1810
- Methods that should be declared as 'public' in C#, 'Public' in VB.NET