public void TestThicknessHandling(ThicknessStyle thicknessStyle)
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                ThicknessStyle = thicknessStyle
            };

            this.DoTestCase(stylerOptions, thicknessStyle);
        }
        public void TestDesignReferenceRemoval()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                RemoveDesignTimeReferences = true
            };

            this.DoTest(stylerOptions);
        }
        public void TestReorderSetterHandling(ReorderSettersBy reorderSettersBy)
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                ReorderSetters = reorderSettersBy,
            };

            this.DoTestCase(stylerOptions, reorderSettersBy);
        }
        public void TestClosingElementHandling(int testNumber, bool spaceBeforeClosingSlash)
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                SpaceBeforeClosingSlash = spaceBeforeClosingSlash
            };

            this.DoTestCase(stylerOptions, testNumber);
        }
        public void TestNestedPropertiesAndChildrenHandling()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                ReorderVSM = VisualStateManagerRule.First
            };

            this.DoTest(stylerOptions);
        }
        public void TestKeepSelectAttributesOnFirstLine()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                FirstLineAttributes = "x:Name, x:Key"
            };

            this.DoTest(stylerOptions);
        }
        public void TestCommentHandling(byte testNumber)
        {
            var stylerOptions = new StylerOptions
            {
                IndentSize    = 2,
                CommentSpaces = testNumber,
            };

            this.DoTestCase(stylerOptions, testNumber);
        }
        public void TestBindingSplitting()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                NoNewLineMarkupExtensions = "x:Bind, Binding"
            };

            this.DoTest(stylerOptions);
        }
        public void TestAttributeIgnoreEncode()
        {
            var stylerOptions = new StylerOptions(
                config: FileHandlingIntegrationTests.GetConfiguration(@"TestConfigurations\TestAttributeIgnoreEncode.json"))
            {
                IgnoreEncodeForAttributes = "Selector"
            };

            FileHandlingIntegrationTests.DoTest(stylerOptions);
        }
 private void DoTestCase <T>(
     StylerOptions stylerOptions,
     T testIdentifier,
     [System.Runtime.CompilerServices.CallerMemberName] string callerMemberName = "")
 {
     FileHandlingIntegrationTests.DoTest(
         stylerOptions,
         Path.Combine("TestFiles", callerMemberName),
         testIdentifier.ToString());
 }
        public void TestVisualStateManagerLast()
        {
            var stylerOptions = new StylerOptions(
                config: FileHandlingIntegrationTests.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                ReorderVSM = VisualStateManagerRule.Last
            };

            FileHandlingIntegrationTests.DoTest(stylerOptions);
        }
        public void TestxBindSplitting()
        {
            var stylerOptions = new StylerOptions(
                config: FileHandlingIntegrationTests.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                NoNewLineMarkupExtensions = "x:Bind"
            };

            FileHandlingIntegrationTests.DoTest(stylerOptions);
        }
        public void TestSuppressedDefaultHandling()
        {
            var stylerOptions = new StylerOptions(
                config: FileHandlingIntegrationTests.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                SuppressProcessing = true
            };

            FileHandlingIntegrationTests.DoTest(stylerOptions);
        }
        public void TestReorderSetterHandling(ReorderSettersBy reorderSettersBy)
        {
            var stylerOptions = new StylerOptions(config: this.legacyConfig)
            {
                ReorderSetters            = reorderSettersBy,
                NoNewLineMarkupExtensions = "x:Bind"
            };

            this.DoTestCase(stylerOptions, reorderSettersBy);
        }
Exemple #15
0
        public void TestFirstLineAttributesDisabled()
        {
            var stylerOptions = new StylerOptions(config: this.defaultConfig)
            {
                FirstLineAttributes       = "x:Name, x:Key",
                EnableAttributeReordering = false
            };

            this.DoTest(stylerOptions);
        }
Exemple #16
0
        public void TestAttributeToleranceHandling()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                AttributesTolerance      = 3,
                RootElementLineBreakRule = LineBreakRule.Always,
            };

            this.DoTest(stylerOptions);
        }
Exemple #17
0
        public void TestMarkupWithAttributeNotOnFirstLine()
        {
            var stylerOptions = new StylerOptions(config: this.legacyConfig)
            {
                KeepFirstAttributeOnSameLine = false,
                AttributesTolerance          = 1,
                NoNewLineMarkupExtensions    = "x:Bind"
            };

            this.DoTest(stylerOptions);
        }
Exemple #18
0
        public void TestMarkupWithAttributeNotOnFirstLine()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                KeepFirstAttributeOnSameLine = false,
                AttributesTolerance          = 1
            };

            this.DoTest(stylerOptions);
        }
Exemple #19
0
        public void TestAttributeOrderRuleGroupsOnSeparateLinesHandling()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                PutAttributeOrderRuleGroupsOnSeparateLines = true,
                MaxAttributesPerLine = 3,
            };

            this.DoTest(stylerOptions);
        }
Exemple #20
0
        public void TestMarkupExtensionHandling(bool indentWithTabs, int tabSize)
        {
            var stylerOptions = new StylerOptions
            {
                FormatMarkupExtension = true,
                IndentWithTabs        = indentWithTabs,
                IndentSize            = tabSize,
            };

            DoTestCase(stylerOptions, $"{tabSize}_{(indentWithTabs ? "tabs" : "spaces")}");
        }
Exemple #21
0
        public void TestNestedCustomMarkupExtensionsWithBindings()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                KeepFirstAttributeOnSameLine = false,
                AttributesTolerance          = 1,
                NoNewLineMarkupExtensions    = "x:Bind, Binding"
            };

            this.DoTest(stylerOptions);
        }
Exemple #22
0
        public void TestAttributeThresholdHandling()
        {
            var stylerOptions = new StylerOptions
            {
                AttributesTolerance          = 0,
                MaxAttributeCharatersPerLine = 80,
                MaxAttributesPerLine         = 3,
                PutEndingBracketOnNewLine    = true
            };

            DoTest(stylerOptions);
        }
Exemple #23
0
        public void TestRootHandling(int testNumber, LineBreakRule lineBreakRule)
        {
            var stylerOptions = new StylerOptions
            {
                AttributesTolerance  = 3,
                MaxAttributesPerLine = 4,
                PutAttributeOrderRuleGroupsOnSeparateLines = true,
                RootElementLineBreakRule = lineBreakRule,
            };

            DoTestCase(stylerOptions, testNumber);
        }
 public static void WriteToUserProfile(StylerOptions options)
 {
     try
     {
         var text = JsonConvert.SerializeObject(options);
         File.WriteAllText(GetOptionsFilePath().ToString(), text);
     }
     catch (Exception ex)
     {
         LoggingService.LogError("Exception when saving user XamlStyler options", ex);
     }
 }
        public IStylerOptions GetGlobalOptions()
        {
            var defaultGlobalOptions = new StylerOptions
            {
                // TODO Check info about IndentSize, is it necessary
                IndentSize = 4
            };

            var globalOptions = ParseOptionsOrDefault(GlobalOptionsFilePath, defaultGlobalOptions, new GlobalOptionsJsonConverter());

            return(globalOptions);
        }
Exemple #26
0
        public void TestMarkupExtensionHandling()
        {
            string testInput = MethodBase.GetCurrentMethod().Name + ".xaml";

            var stylerOptions = new StylerOptions
            {
                FormatMarkupExtension = true
            };
            var styler = StylerService.CreateInstance(stylerOptions);

            DoTest(testInput, styler);
        }
Exemple #27
0
        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);
        }
Exemple #28
0
        public void TestAttributeThresholdHandling()
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                AttributesTolerance           = 0,
                MaxAttributeCharactersPerLine = 80,
                MaxAttributesPerLine          = 3,
                PutEndingBracketOnNewLine     = true
            };

            this.DoTest(stylerOptions);
        }
Exemple #29
0
        public void TestRootHandling(int testNumber, LineBreakRule lineBreakRule)
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                AttributesTolerance  = 3,
                MaxAttributesPerLine = 4,
                PutAttributeOrderRuleGroupsOnSeparateLines = true,
                RootElementLineBreakRule = lineBreakRule,
            };

            this.DoTestCase(stylerOptions, testNumber);
        }
Exemple #30
0
        public void TestMarkupExtensionHandling(bool indentWithTabs, int tabSize)
        {
            var stylerOptions = new StylerOptions(
                config: this.GetConfiguration(@"TestConfigurations\LegacyTestSettings.json"))
            {
                FormatMarkupExtension     = true,
                IndentWithTabs            = indentWithTabs,
                IndentSize                = tabSize,
                AttributeIndentationStyle = AttributeIndentationStyle.Mixed,
            };

            this.DoTestCase(stylerOptions, $"{tabSize}_{(indentWithTabs ? "tabs" : "spaces")}");
        }