How can i do custom rules for classes validations in c#?

I need to verify in my .net projects if have some specific classes if are not allowed on the project.
I search a lot and didnt find nothing about this


Welcome to the community!

You can write Roslyn analyzers; they’ll be imported by default (see the bottom of the page).