Ejemplo n.º 1
0
        public void InitializeAllConfiguration()
        {
            string configFilePath = SettingsFilePath;

            if (!File.Exists(configFilePath))
            {
                try
                {
                    string directory = Path.GetDirectoryName(configFilePath);
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }
                    File.WriteAllText(configFilePath, CSharpenerConfigSettings.DefaultConfigurationFile);
                }
                catch
                {
                    SetDefaultSettingsFilePath();
                }
            }

            IList <string> optionsFileContents = File.ReadAllLines(configFilePath);

            CSharpenerConfigSettings.InitializeSettings(optionsFileContents);
        }
Ejemplo n.º 2
0
        public SyntaxNode AddHeader(SyntaxNode root, string fileName)
        {
            string headerTemplate = CSharpenerConfigSettings.GetHeaderTemplate();

            if (string.IsNullOrWhiteSpace(headerTemplate))
            {
                return(root);
            }

            string formattedHeader = FormatHeader(headerTemplate, fileName);

            SyntaxNode firstNode = GetFirstNode(root);

            if (firstNode == null)
            {
                return(root);
            }
            SyntaxTriviaList leadingTrivia        = GetLeadingTrivia(firstNode);
            bool             triviaContainsHeader = TriviaContainsHeader(leadingTrivia, formattedHeader);

            if (triviaContainsHeader)
            {
                return(root);
            }

            SyntaxTrivia headerTrivia = SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, formattedHeader);
            SyntaxNode   newFirstNode = firstNode.WithLeadingTrivia(headerTrivia);
            SyntaxNode   newRoot      = root.ReplaceNode(firstNode, newFirstNode);

            return(newRoot);
        }
Ejemplo n.º 3
0
        public SortingConfiguration()
        {
            IList <string> kindSortOrderConfigItems = CSharpenerConfigSettings.GetConfigItemsForSection(CSharpenerConfigSettings.KindSortOrderSectionName);

            KindSortOrder = InitializeKindSortOrder(kindSortOrderConfigItems);

            IList <string> accessModifierConfigItems = CSharpenerConfigSettings.GetConfigItemsForSection(CSharpenerConfigSettings.AccessModifierSectionName);

            AccessModifierSortOrder = InitializeAccessModifierSortOrder(accessModifierConfigItems);

            IList <string> modifierConfigItems = CSharpenerConfigSettings.GetConfigItemsForSection(CSharpenerConfigSettings.ModifierSectionName);

            ModifiersSortOrder = InitializeModifiersSortOrder(modifierConfigItems);
        }
Ejemplo n.º 4
0
        public static void InitializeConfig(string testConfig)
        {
            IList <string> configLines = GetConfigLines(testConfig);

            CSharpenerConfigSettings.InitializeSettings(configLines);
        }