如何将 stylecop 与 .xaml 文件一起使用
我的任务是在 .xaml 文件上使用 stylecop。有谁有一个好的地方来开始寻找完成这项任务的最佳方法。我在网上逛了一圈,还没有找到好的解决办法。我们的开发环境是VS 2010 WPF应用程序。 感谢您的帮助。
I have been tasked with utilizing stylecop on .xaml files. Does anyone have a good place to start looking for the best way to accomplish this task. I have drifted around the internet and have yet to find a good solution. Our development environment is VS 2010 WPF application.
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
StyleCop 是一个源分析工具,可以增加其可读性。 Visual Studio 本身就是一个很好的起点。当您开始使用 VS 编写 xaml 时,它会自动缩进代码。
这是一个例子
这是预期的(我认为)
StyleCop is a source analysis tool to increase the readability of it. Visual Studio itself would be a good place to start. When you start writing xaml using VS it automatically indents code.
Here is an example
This is what is expected (I think)
根据 http://archive.msdn.microsoft.com/sourceanalysis,StyleCop 仅分析 C# 源代码代码 - XAML 是一种完全不同的语言。如果您的老板或经理要求您在
.xaml
文件上使用 StyleCop - 他们可能的意思(您应该与他们仔细检查,而不是相信我的话) ,就是分析关联的xaml.cs
文件。每个 xaml 文件都是一个分部类 - 类的一部分是 XAML(它会被转换为自动xaml.designer.cs
文件,您不能也不应该弄乱它) - 另一部分该类(通常称为代码隐藏)的一部分是.xaml.cs
。这份文档是您可以使用 StyleCop 的文档,尽管它的一些规则可能会因为它仅在部分类的一半上运行这一事实而令人困惑。这是您可以希望实现的最好目标。
As per http://archive.msdn.microsoft.com/sourceanalysis, StyleCop only analyzes C# source code - XAML is a completely different language. If your boss or manager tasked you with using StyleCop on the
.xaml
files - what they probably meant (and you should double check with them rather than take my word for it), is to analyse the associatedxaml.cs
files. Every xaml file is a partial class - one part of the class is the XAML (which gets translated to an automaticxaml.designer.cs
file which you cannot and should not mess with) - and the other part of the class (often called the codebehind) is the.xaml.cs
. This document is one you can use StyleCop on, although some of it's rules may be confused by the fact that it's being run on only one half of a partial class.That's the best you can hope to accomplish.
Microsoft Xaml Toolkit 具有 Fxcop 集成,您可能会觉得有用。
博客发布:http://blogs.msdn.com/b/wpf/archive/2010/07/28/microsoft-xaml-toolkit-ctp-july-2010-fxcop-integration.aspx
下载:http://archive.msdn.microsoft.com/XAML
The Microsoft Xaml Toolkit has Fxcop integration you might find useful.
blog posting: http://blogs.msdn.com/b/wpf/archive/2010/07/28/microsoft-xaml-toolkit-ctp-july-2010-fxcop-integration.aspx
downloads: http://archive.msdn.microsoft.com/XAML