开发者

Show obsolete/deprecated class usages in XAML

Context

开发者_运维技巧

We had quite a big memory leak in a WPF application we are developping that was caused by the use of DropShadowBitmapEffect in a resource library.

The drop shadow was used by some UserControl and by all our menus to cast a shadow over the actual content of the window, as such:

<DropShadowBitmapEffect x:Key="PopupDropShadow" ShadowDepth="1.5" Softness="0.15" />
...
<Rectangle BitmapEffect="{StaticResource PopupDropShadow}" ... />

I had to profile the application for many hours before I actually found the cause of the problem. The DropShadowBitmapEffect class is unmanaged and prevents objects from being GC'd. Also, you'll note that the DropShadowBitmapEffect class is marked as Obsolete, and that there is an updated class named DropShadowEffect that fixes the memory leak (and is also hardware accelerated thus improves render performance a whole lot). Here is the actual fix:

<DropShadowEffect x:Key="PopupDropShadow" ShadowDepth="1.5" />
...    
<Rectangle Effect="{StaticResource PopupDropShadow}" ... />

Question

Is it possible to have the deprecated/obsolete class usages throw warnings on compile when used in XAML in Visual Studio 2010?


I haven't tested it for XAML but Gendarme has a rule that checks for the use of obsolete code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜