开发者

How to use ResourceExposureAttribute and ResourceConsumptionAttribute?

开发者 https://www.devze.com 2023-01-07 15:21 出处:网络
I have found the attribute ResourceExpo开发者_开发百科sureAttribute and ResourceConsumptionAttribute in the DefaultTraceListener.

I have found the attribute ResourceExpo开发者_开发百科sureAttribute and ResourceConsumptionAttribute in the DefaultTraceListener.

When are used? Are they read by the framework or should be considered by the programmer? More, what are the differences between them?


These attributes are declared with a ConditionalAttribute, meaning that the compiler shouldn't include them in the final source code unless the conditional (in this case RESOURCE_ANNOTATION_WORK) is defined. It appears that these attributes are for some static analysis tool, internal to the .NET development team, to run over a special build of the Framework for some purpose. It's not clear what that purpose is. Something to do with side-by-side loading of two versions of the Framework in the same process.

ResourceConsumption seems to be the basic attribute, indicating that this class or method consumes some form of resource beyond just ordinary memory, and whether this is a per-process or per-machine resource that is consumed. ResourceExposure seems to indicate that the class or method wraps that resource for consumption by other classes or methods.

I encountered the attributes when looking at the source code for Font and FontFamily, but there are many, many classes which are annotated with them. I don't think it's useful for any code you write to add the attributes, because they won't get compiled in unless you specifically opt in to doing so, and you don't have the tool to analyze the results.

0

精彩评论

暂无评论...
验证码 换一张
取 消