private void TestConfig(StylerOptions stylerOptions, string expectedConfiguration) { var actualOptions = JsonConvert.SerializeObject(stylerOptions); var expectedOptions = File.ReadAllText(this.GetConfiguration(expectedConfiguration)); Assert.That(Regex.Replace(actualOptions, @"\s+", ""), Is.EqualTo(Regex.Replace(expectedOptions, @"\s+", ""))); }
public void TestAttributeSortingOptionHandling() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { AttributeOrderingRuleGroups = new[] { // Class definition group "x:Class", // WPF Namespaces group "xmlns, xmlns:x", // Other namespace "xmlns:*", // Element key group "Key, x:Key, Uid, x:Uid", // Element name group "Name, x:Name, Title", // Attached layout group "Grid.Column, Grid.ColumnSpan, Grid.Row, Grid.RowSpan, Canvas.Right, Canvas.Bottom, Canvas.Left, Canvas.Top", // Core layout group "MinWidth, MinHeight, Width, Height, MaxWidth, MaxHeight, Margin", // Alignment layout group "Panel.ZIndex, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment", // Unmatched "*:*, *", // Miscellaneous/Other attributes group "Offset, Color, TargetName, Property, Value, StartPoint, EndPoint, PageSource, PageIndex", // Blend related group "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText", } }; this.DoTest(stylerOptions); }
public void TestVisualStateManagerNone() { var stylerOptions = new StylerOptions(config: this.legacyAttributeOrderingConfig) { ReorderVSM = VisualStateManagerRule.None }; this.DoTest(stylerOptions); }
public void TestClosingElementHandling(int testNumber, bool spaceBeforeClosingSlash) { var stylerOptions = new StylerOptions(config: this.legacyConfig) { SpaceBeforeClosingSlash = spaceBeforeClosingSlash }; this.DoTestCase(stylerOptions, testNumber); }
public void TestThicknessHandling(ThicknessSeparator ThicknessSeparator) { var stylerOptions = new StylerOptions(config: this.legacyConfig) { ThicknessSeparator = ThicknessSeparator }; this.DoTestCase(stylerOptions, ThicknessSeparator); }
public void TestFirstLineAttributes() { var stylerOptions = new StylerOptions(config: this.defaultConfig) { FirstLineAttributes = "x:Name, x:Key" }; this.DoTest(stylerOptions); }
public void TestxBindSplitting() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { NoNewLineMarkupExtensions = "x:Bind" }; this.DoTest(stylerOptions); }
public void TestCommentHandling(byte testNumber) { var stylerOptions = new StylerOptions(config: this.legacyConfig) { CommentPadding = testNumber, }; this.DoTestCase(stylerOptions, testNumber); }
public void TestNestedPropertiesAndChildrenHandling() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { NoNewLineMarkupExtensions = "x:Bind" }; this.DoTest(stylerOptions); }
public void TestReorderSetterHandling(ReorderSettersBy reorderSettersBy) { var stylerOptions = new StylerOptions(config: this.legacyConfig) { ReorderSetters = reorderSettersBy, NoNewLineMarkupExtensions = "x:Bind" }; this.DoTestCase(stylerOptions, reorderSettersBy); }
public void TestMarkupExtensionHandling() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { FormatMarkupExtension = true, NoNewLineMarkupExtensions = "x:Bind" }; this.DoTest(stylerOptions); }
public void TestFirstLineAttributesDisabled() { var stylerOptions = new StylerOptions(config: this.defaultConfig) { FirstLineAttributes = "x:Name, x:Key", EnableAttributeReordering = false }; this.DoTest(stylerOptions); }
public void TestAttributeOrderRuleGroupsOnSeparateLinesHandling() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { SeparateByGroups = true, MaxAttributesPerLine = 3, }; this.DoTest(stylerOptions); }
public void TestAttributeToleranceHandling() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { AttributesTolerance = 3, RootElementLineBreakRule = LineBreakRule.Always, }; this.DoTest(stylerOptions); }
public void TestMarkupWithAttributeNotOnFirstLine() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { KeepFirstAttributeOnSameLine = false, AttributesTolerance = 1, NoNewLineMarkupExtensions = "x:Bind" }; this.DoTest(stylerOptions); }
public void TestRootHandling(int testNumber, LineBreakRule lineBreakRule) { var stylerOptions = new StylerOptions(config: this.legacyConfig) { AttributesTolerance = 3, MaxAttributesPerLine = 4, SeparateByGroups = true, RootElementLineBreakRule = lineBreakRule, }; this.DoTestCase(stylerOptions, testNumber); }
public void TestAttributeThresholdHandling() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { AttributesTolerance = 0, MaxAttributeCharatersPerLine = 80, MaxAttributesPerLine = 3, PutEndingBracketOnNewLine = true }; this.DoTest(stylerOptions); }
public XamlMagicConsole(Options options) { this.options = options; StylerOptions stylerOptions = new StylerOptions(); if (this.options.Configuration != null) { var config = File.ReadAllText(this.options.Configuration); stylerOptions = JsonConvert.DeserializeObject<StylerOptions>(config); if (this.options.LogLevel == LogLevel.Insanity) { this.Log(JsonConvert.SerializeObject(stylerOptions), LogLevel.Insanity); } this.Log(JsonConvert.SerializeObject(stylerOptions.AttributeOrderingRuleGroups), LogLevel.Debug); } this.stylerService = StylerService.CreateInstance(stylerOptions); }
public void TestAttributeSortingOptionHandling() { var stylerOptions = new StylerOptions(config: this.legacyConfig) { AttributeOrderingRuleGroups = new[] { "x:Class*", "xmlns, xmlns:x", "xmlns:*", "Key, x:Key, Uid, x:Uid", "Name, x:Name, Title", "Grid.Column, Grid.ColumnSpan, Grid.Row, Grid.RowSpan, Canvas.Right, Canvas.Bottom, Canvas.Left, Canvas.Top", "MinWidth, MinHeight, Width, Height, MaxWidth, MaxHeight, Margin", "Panel.ZIndex, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment", "*:*, *", "Offset, Color, TargetName, Property, Value, StartPoint, EndPoint, PageSource, PageIndex", "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText", } }; this.DoTest(stylerOptions); }
public void TestWildCard() { var stylerOptions = new StylerOptions(config: this.defaultConfig) { AttributeOrderingRuleGroups = new[] { "x:Class*", "xmlns, xmlns:x", "xmlns:*", "x:Key, Key, x:Name, Name, x:Uid, Uid, Title", "Grid.*, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom", "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight", "Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex", "Style, Background, Foreground, Fill, BorderBrush, BorderThickness, Stroke, StrokeThickness, Opacity", "FontFamily, FontSize, LineHeight, FontWeight, FontStyle, FontStretch", "*:*, *", "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint", "ToolTipService.*, AutomationProperties.*", "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText" } }; this.DoTest(stylerOptions); }
private bool LoadConfiguration(string config) { try { StylerOptions configOptions = JsonConvert.DeserializeObject <StylerOptions>(config); if (configOptions == null) { this.LoadFallbackConfiguration(); } else { foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(this)) { if (propertyDescriptor.Name.Equals(nameof(this.SerializedAttributeOrderingRuleGroups)) || propertyDescriptor.Name.Equals(nameof(this.ConfigPath))) { continue; } propertyDescriptor.SetValue(this, propertyDescriptor.GetValue(configOptions)); } if (this.AttributeOrderingRuleGroups == null) { this.AttributeOrderingRuleGroups = this.DefaultAttributeOrderingRuleGroups; } } } catch (Exception) { this.LoadFallbackConfiguration(); return(false); } return(true); }
public void TestConfiguration_BadSetting() { var stylerOptions = new StylerOptions(config: this.GetConfiguration(@"TestConfigurations\BadSetting.json")); this.TestConfig(stylerOptions, @"TestConfigurations\SerializedDefault.json"); }
public void TestConfiguration_AllDifferent() { var stylerOptions = new StylerOptions(config: this.GetConfiguration(@"TestConfigurations\AllDifferent.json")); this.TestConfig(stylerOptions, @"TestConfigurations\AllDifferent.json"); }
public void TestVisualStateManagerLast() { var stylerOptions = new StylerOptions(config: this.legacyAttributeOrderingConfig); this.DoTest(stylerOptions); }
public void TestAttachedProperty() { var stylerOptions = new StylerOptions(config: this.legacyConfig); this.DoTest(stylerOptions); }
public void TestConfiguration_Single() { var stylerOptions = new StylerOptions(config: this.GetConfiguration(@"TestConfigurations\Single.json")); this.TestConfig(stylerOptions, @"TestConfigurations\SerializedSingle.json"); }
public void TestCommentHandlingFirstLine() { var stylerOptions = new StylerOptions(config: this.legacyConfig); this.DoTest(stylerOptions); }
public void TestConfiguration_Empty() { var stylerOptions = new StylerOptions(config: this.GetConfiguration(@"TestConfigurations\Empty.json")); this.TestConfig(stylerOptions, @"TestConfigurations\SerializedDefault.json"); }