Dinidu Hewage
Dinidu Hewage

Reputation: 2191

Can C# file restrict for adding specific access modifier variables?

I have a requirement that all my .cs file variables should be protected. Is there a way to restrict adding private access modifier type variables to this type of files?

Upvotes: 0

Views: 98

Answers (2)

Toni Wenzel
Toni Wenzel

Reputation: 2091

You might use StyleCop or implement a custom code analyser

Upvotes: 0

Rahul
Rahul

Reputation: 77876

Though that's a typical requirement but if it's a organization coding rule then you can use Microsoft FxCop static code analysis tool and define your own rule set; which then per your setting may cause the build to fail or throw warning if the rule isn't met

Upvotes: 1

Related Questions