Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use stylecop with .xaml files

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.

like image 262
billmiller Avatar asked May 24 '11 13:05

billmiller


People also ask

Is StyleCop still used?

StyleCop used to be a Visual Studio plugin and a NuGet package. You can still use this in Visual Studio 2019, but the current recommended way to use StyleCop is to use the Roslyn-based analyzers.

Is StyleCop free?

StyleCop is a free source code analysis tool for C# developers that was initially developed by Microsoft.


1 Answers

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

<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Hi" />
</Grid>
</Window>

This is what is expected (I think)

<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button Content="Hi" />
    </Grid>
</Window>
like image 116
vikram.ma Avatar answered Oct 27 '22 06:10

vikram.ma