Microsoft historically recommended sealing attributes for potential performance benefits. In my coding standards book, I advocate sealing any class not intended for inheritance, primarily to communicate the class’s intent and uphold proper OOP design principles. However, benchmarks show that sealing attributes does not provide a meaningful performance advantage.
Performance Breakdown
These benchmark results demonstrate that the non-sealed Attribute is slightly faster.
When I set up my EditorConfig to check for this issue, it looks like this:
dotnet_diagnostic.CA1813.severity = suggestionI maintain my recommendation: any class not intended for inheritance should be sealed for robust class design.


Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks
Make a one-time donation
Make a monthly donation
Make a yearly donation
Choose an amount
Or enter a custom amount
Your contribution is appreciated.
Your contribution is appreciated.
Your contribution is appreciated.
DonateDonate monthlyDonate yearlyIf you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave
© The information in this article is copywritten and cannot be reproduced in any way without express permission from David McCarter.
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
