XamlStyler
XamlStyler copied to clipboard
Release as a Roslyn analyser
Is your feature request related to a problem? Please describe. I'm trying to enforce consistent syntax in XAML within my team and while this can be achieved with the provided CLI (pull requests don't get merged if automated checks fail or have warnings), having these checks relied on tend to result in relatively meaningless commits soon after a PR is created (and a general lag in the event issues aren't noticed by the pull request creator).
The CLI and VS extension (provided it is installed, usually not in a team setting) make it possible to do this locally, but lack the "there by default" advantage that a Roslyn analyser provides.
Side note: I spent some time building a script that parses output from dotnet build and reports issues via the Bitbucket Code Insights API. Making this available as a Roslyn analyser would (provided the emitted warnings and errors are in the same format) allow style deviations to be picked up.
Describe the solution you'd like Xaml Styler released as a Roslyn analyser providing;
- Reporting of style violations (file level or at violation site, depending on capabilities of existing code)
- Code action that fixes violations in a file (if possible)
Describe alternatives you've considered My search for Roslyn analysers targetting XAML style hasn't turned up anything thus far, hence this request.
Additional context While Roslyn itself doesn't process XAML (a specific MSBuild action is responsible for this I believe), according to https://stackoverflow.com/questions/32399050/roslyn-access-xaml-of-a-partial-class-from-code-analyzer there are ways to process the raw file content (provided the XAML file is included in the appropriate manner).
If open to this feature, let me know. XAML Styler seems rather flexible in its implementation, so I'd be interested trying to get a basic prototype together.
This is a really interesting idea -- a couple thoughts:
Reporting of style violations (file level or at violation site, depending on capabilities of existing code)
Per-file makes a lot of sense to me -- it should be easy to flag whether a given file matches styler settings. I think the violation site would be tricky, because the ordering of attributes, indentation, etc. can be both super dynamic and have cascading effects on surrounding code.
Code action that fixes violations in a file (if possible)
I think it most cases, the "fix" would be just style the file :)