Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate JSON Schema for config file #473

Open
BinToss opened this issue Mar 3, 2024 · 1 comment
Open

Generate JSON Schema for config file #473

BinToss opened this issue Mar 3, 2024 · 1 comment
Labels

Comments

@BinToss
Copy link

BinToss commented Mar 3, 2024

See https://github.com/gregsdennis/json-everything, nuget:JsonSchema.Net.Generation

The schema will allow IDEs to provide completions/suggestions and validation.

I've handwritten a schema for my own use, but it's best to generate one from source so it never has to be updated separately.
image

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://raw.githubusercontent.com/Xavalon/XamlStyler/main/Settings.XamlStyler.schema.json",
  "type": "object",
  "properties": {
    "IndentSize": {
      "description": "XAML Styler (plugin only) detects and uses Visual Studio indent options by default. However, since xstyler.exe runs independently of Visual Studio, we are unable to detect those options. If you want to override the default behavior for either the plugin or xstyler.exe, you can set an extra property \"IndentSize\" in an external configuration.",
      "type": "integer",
      "default": 4
    },
    "IndentWithTabs": {
      "description": "XAML Styler (plugin only) detects and uses Visual Studio insertTabs setting by default. However, since xstyler.exe runs independently of Visual Studio, we are unable to detect those options. If you want to override the default behavior for either the plugin or xstyler.exe, you can set an extra property \"IndentWithTabs\" in an external configuration.",
      "type": "boolean",
      "default": false
    },
    "AttributesTolerance": {
      "type": "integer",
      "default": 2
    },
    "KeepFirstAttributeOnSameLine": {
      "type": "boolean",
      "default": false
    },
    "MaxAttributeCharactersPerLine": {
      "type": "integer",
      "default": 0
    },
    "MaxAttributesPerLine": {
      "type": "integer",
      "default": 1
    },
    "NewlineExemptionElements": {
      "type": "string",
      "default": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter"
    },
    "SeparateByGroups": {
      "type": "boolean",
      "default": false
    },
    "AttributeIndentation": {
      "type": "integer",
      "description": "Defines the number of spaces that attributes are indented on elements with more than one line of attributes. A value of 0 will align indentation with the first attribute.\nSee https://github.com/Xavalon/XamlStyler/wiki/Attribute-Formatting#attribute-indentation",
      "default": 0
    },
    "AttributeIndentationStyle": {
      "type": "integer",
      "enum": [
        {
          "code": 0,
          "description": "Mixed"
        },
        {
          "code": 1,
          "description": "Spaces"
        }
      ],
      "default": 1
    },
    "RemoveDesignTimeReferences": {
      "type": "boolean",
      "default": false
    },
    "IgnoreDesignTimeReferencePrefix": {
      "type": "boolean",
      "default": false
    },
    "EnableAttributeReordering": {
      "type": "boolean",
      "default": true
    },
    "AttributeOrderingRuleGroups": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "default": [
        "x:Class",
        "xmlns, xmlns:x",
        "xmlns:*",
        "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
        "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
        "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
        "Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex",
        "*:*, *",
        "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
        "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
        "Storyboard.*, From, To, Duration"
      ]
    },
    "FirstLineAttributes": {
      "type": "string",
      "default": ""
    },
    "OrderAttributesByName": {
      "type": "boolean",
      "default": true
    },
    "PutEndingBracketOnNewLine": {
      "type": "boolean",
      "default": false
    },
    "RemoveEndingTagOfEmptyElement": {
      "type": "boolean",
      "default": true
    },
    "SpaceBeforeClosingSlash": {
      "type": "boolean",
      "default": true
    },
    "RootElementLineBreakRule": {
      "type": "integer",
      "enum": [
        {
          "code": 0,
          "description": "Default"
        },
        {
          "code": 1,
          "description": "Always"
        },
        {
          "code": 2,
          "description": "Never"
        }
      ],
      "default": 0
    },
    "ReorderVSM": {
      "type": "integer",
      "enum": [
        {
          "code": 0,
          "description": "None"
        },
        {
          "code": 1,
          "description": "First"
        },
        {
          "code": 2,
          "description": "Last"
        }
      ],
      "default": 2
    },
    "ReorderGridChildren": {
      "type": "boolean",
      "default": false
    },
    "ReorderCanvasChildren": {
      "type": "boolean",
      "default": false
    },
    "ReorderSetters": {
      "type": "integer",
      "enum": [
        {
          "code": 0,
          "description": "None"
        },
        {
          "code": 1,
          "description": "Property"
        },
        {
          "code": 2,
          "description": "TargetName"
        },
        {
          "code": 3,
          "description": "TargetNameThenProperty"
        }
      ],
      "default": 0
    },
    "FormatMarkupExtension": {
      "type": "boolean",
      "default": true
    },
    "NoNewLineMarkupExtensions": {
      "type": "string",
      "default": "x:Bind, Binding"
    },
    "ThicknessSeparator": {
      "type": "integer",
      "enum": [
        {
          "code": 0,
          "description": "None"
        },
        {
          "code": 1,
          "description": "Space"
        },
        {
          "code": 2,
          "description": "Comma"
        }
      ],
      "default": 2
    },
    "ThicknessAttributes": {
      "type": "string",
      "default": "Margin, Padding, BorderThickness, ThumbnailClipMargin"
    },
    "FormatOnSave": {
      "type": "boolean",
      "default": true
    },
    "CommentPadding": {
      "type": "integer",
      "default": 2
    }
  }
}
@BinToss BinToss added the Feature label Mar 3, 2024
@mrlacey
Copy link
Contributor

mrlacey commented Apr 2, 2024

I know it's possible to package a file like this in a Visual Studio extension so it can be used there.
Does anyone know about VSCode and Rider?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants