Skip to content

Gendarme.Rules.Security.Cas.ReviewSealedTypeWithInheritanceDemandRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

ReviewSealedTypeWithInheritanceDemandRule

Assembly: Gendarme.Rules.Security.Cas
Version: git

Description

This rule checks for sealed types that have InheritanceDemand declarative security applied to them. Since those types cannot be inherited from the InheritanceDemand will never be executed by the runtime. Check if the permission is required and, if so, change the SecurityAction to the correct one. Otherwise remove the permission.

Examples

Bad example:

[SecurityPermission (SecurityAction.InheritanceDemand, Unrestricted = true)]
public sealed class Bad {
}

Good example (non sealed):

[SecurityPermission (SecurityAction.InheritanceDemand, Unrestricted = true)]
public class Good {
}

Good example (LinkDemand):

[SecurityPermission (SecurityAction.LinkDemand, Unrestricted = true)]
public sealed class Good {
}

Notes

  • Before Gendarme 2.2 this rule was part of Gendarme.Rules.Security and named SealedTypeWithInheritanceDemandRule.

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally