realvizu / NsDepCop

NsDepCop is a static code analysis tool that helps to enforce namespace dependency rules in C# projects. No more unplanned or unnoticed dependencies in your system.
GNU General Public License v2.0
200 stars 32 forks source link

Disallow concrete type #23

Closed realvizu closed 7 years ago

realvizu commented 7 years ago

Use case: For testability purposes accessing System.DateTime directly should be prohibited. All access should be via IEnvironmentInfo interface (eg. IEnvironmentInfo.GetDateTime).

Config should be enhanced to allow defining that a concrete type is accessible from a concrete namespace but inaccessible for all other namespaces.

realvizu commented 7 years ago

Oops, the proposed feature does not fulfill the described use case because it's not the usage of DateTime that should be disallowed but the usage of DateTime.Now, DateTime.UtcNow. But checking property invocations is clearly outside of the scope of NsDepCop so closing this as won't fix.