<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.DotNet.DeadCodeAnalysis;
using System.Threading;
using System.IO;

namespace DeadCode
{
    // TODO: Rename this to "DeadRegions". Rename namespaces to ConditionalRegionAnalysis? ConditionalRegionAnalysisEngine?
    // to allow for more dead code analysis based on roslyn which is not about proprocessor regions.
    internal class DeadCode
    {
        private static AnalysisEngine _engine;
        private static bool s_printDisabled;
        private static bool s_printEnabled;
        private static bool s_printVarying;
        private static bool s_edit;

        public static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintUsage();
                return -1;
            }

            var projectPaths = new List<string>();
            IEnumerable<string> ignoredSymbols = null;
            IEnumerable<string> definedSymbols = null;

            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i];
                if (arg[0] == '/' || arg[0] == '-')
                {
                    string argName = arg.Substring(1);
                    if (argName.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (++i < args.Length)
                        {
                            ignoredSymbols = args[i].Split(';', ',', ' ', '\t', '\n');
                        }
                        else
                        {
                            PrintUsage();
                            return -1;
                        }
                    }
                    else if (argName.Equals("define", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (++i < args.Length)
                        {
                            definedSymbols = args[i].Split(';', ',', ' ', '\t', '\n');
                        }
                        else
                        {
                            PrintUsage();
                            return -1;
                        }
                    }
                    else if (argName.Equals("printdisabled", StringComparison.InvariantCultureIgnoreCase))
                    {
                        s_printDisabled = true;
                    }
                    else if (argName.Equals("printenabled", StringComparison.InvariantCultureIgnoreCase))
                    {
                        s_printEnabled = true;
                    }
                    else if (argName.Equals("printvarying", StringComparison.InvariantCultureIgnoreCase))
                    {
                        s_printVarying = true;
                    }
                    else if (argName.Equals("edit", StringComparison.InvariantCultureIgnoreCase))
                    {
                        s_edit = true;
                    }
                }
                else
                {
                    projectPaths.Add(arg);
                }
            }

            if (projectPaths.Count == 0)
            {
                PrintUsage();
                return -1;
            }

            var cts = new CancellationTokenSource();
            var ct = cts.Token;
            Console.CancelKeyPress += delegate { cts.Cancel(); };

            Console.WriteLine("Analyzing...");

            _engine = AnalysisEngine.FromFilePaths(
                projectPaths,
                alwaysDefinedSymbols: definedSymbols,
                alwaysIgnoredSymbols: ignoredSymbols);

            try
            {
                RunAsync(ct).Wait(ct);
            }
            catch (OperationCanceledException)
            {<commit_msg>Add 'disable' command line option<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.DotNet.DeadCodeAnalysis;
using System.Threading;
using System.IO;

namespace DeadCode
{
    // TODO: Rename this to "DeadRegions". Rename namespaces to ConditionalRegionAnalysis? ConditionalRegionAnalysisEngine?
    // to allow for more dead code analysis based on roslyn which is not about proprocessor regions.
    internal class DeadCode
    {
        private static AnalysisEngine _engine;
        private static bool s_printDisabled;
        private static bool s_printEnabled;
        private static bool s_printVarying;
        private static bool s_edit;

        public static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintUsage();
                return -1;
            }

            var projectPaths = new List<string>();
            IEnumerable<string> ignoredSymbols = null;
            IEnumerable<string> definedSymbols = null;
            IEnumerable<string> disabledSymbols = null;

            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i];
                if (arg[0] == '/' || arg[0] == '-')
                {
                    string argName = arg.Substring(1);
                    if (argName.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (++i < args.Length)
                        {
                            ignoredSymbols = args[i].Split(';', ',', ' ', '\t', '\n');
                        }
                        else
                        {
                            PrintUsage();
                            return -1;
                        }
                    }
                    else if (argName.Equals("define", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (++i < args.Length)
                        {
                            definedSymbols = args[i].Split(';', ',', ' ', '\t', '\n');
                        }
                        else
                        {
                            PrintUsage();
                            return -1;
                        }
                    }
                    else if (argName.Equals("disable", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (++i < args.Length)
                        {
                            disabledSymbols = args[i].Split(';', ',', ' ', '\t', '\n');
                        }
                        else
                        {
                            PrintUsage();
                            return -1;
                        }
                    }
                    else if (argName.Equals("printdisabled", StringComparison.InvariantCultureIgnoreCase))
                    {
                        s_printDisabled = true;
                    }
                    else if (argName.Equals("printenabled", StringComparison.InvariantCultureIgnoreCase))
                    {
                        s_printEnabled = true;
                    }
                    else if (argName.Equals("printvarying", StringComparison.InvariantCultureIgnoreCase))
                    {
                        s_printVarying = true;
                    }
                    else if (argName.Equals("edit", StringComparison.InvariantCultureIgnoreCase))
                    {
                        s_edit = true;
                    }
                }
                else
                {
                    projectPaths.Add(arg);
                }
            }

            if (projectPaths.Count == 0)
            {
                PrintUsage();
                return -1;
            }

            var cts = new CancellationTokenSource();
            var ct = cts.Token;
            Console.CancelKeyPress += delegate { cts.Cancel(); };

            Console.WriteLine("Analyzing...");

            _engine = AnalysisEngine.FromFilePaths(
                projectPaths,
                alwaysDefinedSymbols: definedSymbols,
                alwaysDisabledSymbols: disabledSymbols,
                alwaysIgnoredSymbols: ignoredSymbols);

            try
            {
                RunAsync(ct).Wait(ct);
            }
            catch (OperationCanceledException)
            {
{'fraction_non_alphanumeric': 0.08601247600767754, 'fraction_numerical': 0.002519193857965451, 'mean_word_length': 1.0514271653543308, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6504196', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1795, 'n_words': 398}