System.Runtime.Versioning.ResourceConsumptionAttribute Class

Specifies the resource consumed by the member of a class. This class cannot be inherited.

See Also: ResourceConsumptionAttribute Members


[System.AttributeUsage(System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.All, Inherited=false)]
public sealed class ResourceConsumptionAttribute : Attribute


If the System.Runtime.Versioning.ResourceConsumptionAttribute attribute is applied to a member, the System.Runtime.Versioning.ResourceExposureAttribute attribute must also be applied.

If the resource scope of the consumed resource is different than the resource scope of how it is consumed, the constructor that takes a consumptionScope parameter should be used to specify how the resource is consumed. For example, a resource may be exposed as a ResourceScope.Machine resource, but only used at the ResourceScope.Process and ResourceScope.Assembly scope. For this example the consumptionScope parameter is set to ResourceScope.Process | ResourceScope.Assembly.

The resourceScope parameter in the constructor must specify a System.Runtime.Versioning.ResourceScope greater than or equal to the resource exposure of all called members. For example, a method consuming two ResourceScope.Process resources and one ResourceScope.Machine resource would be identified as consuming a ResourceScope.Machine and a ResourceScope.Process resource by setting resourceScope to ResourceScope.Machine | ResourceScope.Process.

Public members cannot expose ResourceScope.Assembly or ResourceScope.Private resources. ResourceScope.Assembly members cannot expose ResourceScope.Private resources.

The graph of methods terminates when a System.Runtime.Versioning.ResourceExposureAttribute attribute with a resource scope of ResourceScope.None is applied to a method.


Namespace: System.Runtime.Versioning
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0