开发者

How can I know that a xaml is deprecated?

I was using the following xaml in wpf:

<Style TargetType="{x:Type Border}">
  <Setter Property="BitmapEffect">
    <Setter.Value>
        <BitmapEffectGroup>
            <DropShadowBitmapEffect ShadowDepth="1"/>
        </BitmapEffectGroup>
    </Setter.Value>
  </Setter> 
</Style>

When I discovered that DropShadowBitmapEffect is now deprecated in favour of DropShadowEffect:

<Style TargetType=开发者_运维问答"{x:Type Border}">
    <Setter Property="Effect">
        <Setter.Value>
            <DropShadowEffect></DropShadowEffect>
        </Setter.Value>
    </Setter>
</Style>

But I know this in a lucky way!! How can I know that a certain control written in xaml is now deprecated??


A good static analysis tool should be able to tell you when you use something that's been deprecated. In some cases the C# compiler will tell you. In fact, in this case, both R# and the C# compiler will pick up on the fact that you're using a property marked as Obsolete, if you assign it in C# code.

Unfortunately, at this time, it doesn't seem that either the R# static analysis process or the XAML compiler will pick up on if you use obsolete properties or elements in XAML. However, it does appear that the intellisense feature in R# will strikeout items that are deprecated, even when editing XAML.

I'd definitely check out fxcop to see if it'll work with XAML and see if there's a rule to check for usage of Obsolete members.

Edit:

R# (or Resharper) is a helpful plugin for Visual Studio that gives a lot of cool features including some in-editor static analysis.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜