<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using log4net.Core;

namespace SlimJim.Model
{
	public class SlnGenerationOptions
	{
		private const string DefaultSolutionName = "SlimJim";
		private string projectsRootDirectory;
		private string solutionName;
		private string slnOutputPath;
		private readonly List<string> additionalSearchPaths;
		private readonly List<string> ignoreDirectoryPatterns;

		public SlnGenerationOptions(string workingDirectory)
		{
			ProjectsRootDirectory = workingDirectory;
			additionalSearchPaths = new List<string>();
			ignoreDirectoryPatterns = new List<string>();
			TargetProjectNames = new List<string>();
			VisualStudioVersion = VisualStudioVersion.VS2012;
			LoggingThreshold = Level.Info;
		}

		public List<string> TargetProjectNames { get; private set; }

		public string ProjectsRootDirectory
		{
			get { return projectsRootDirectory; }
			set
			{
				projectsRootDirectory = ResolvePath(value);
			}
		}

		public VisualStudioVersion VisualStudioVersion { get; set; }
		public bool IncludeEfferentAssemblyReferences { get; set; }
		public bool ShowHelp { get; set; }
		public bool ConvertReferences { get; set; }
		public bool RestoreReferences { get; set; }
		public bool FixHintPaths { get; set; }
		public bool RestoreHintPaths { get; set; }
		public bool OpenInVisualStudio { get; set; }
		public Level LoggingThreshold { get; set; }

		public List<string> AdditionalSearchPaths
		{
			get
			{
				return additionalSearchPaths.ConvertAll(ResolvePath);
			}
		}

		private string ResolvePath(string p)
		{
			return !Path.IsPathRooted(p) ? Path.Combine(ProjectsRootDirectory, p) : p;
		}

		public string SlnOutputPath
		{
			get { return slnOutputPath != null ? ResolvePath(slnOutputPath) : ProjectsRootDirectory; }
			set { slnOutputPath = value; }
		}

		public string SolutionName
		{
			get
			{
				if (string.IsNullOrEmpty(solutionName))
				{
					if (TargetProjectNames.Count == 1)
					{
						return TargetProjectNames[0];
					}

					if (TargetProjectNames.Count > 1)
					{
						return string.Join("_", TargetProjectNames);
					}

					if (!string.IsNullOrEmpty(ProjectsRootDirectory))
					{
						return GetLastSegmentNameOfProjectsRootDirectory();
					}

					return DefaultSolutionName;
				}

				return solutionName;
			}
			set { solutionName = value; }
		}

		private string GetLastSegmentNameOfProjectsRootDirectory()
		{
			var dirName = new DirectoryInfo(ProjectsRootDirectory).Name;
			if (string.IsNullOrEmpty(dirName) || dirName == "/")
			{
				return DefaultSolutionName;
			}
			return dirName;
		}

		public SlnGenerationMode Mode
		{
			get
			{
				return TargetProjectNames.Count == 0<commit_msg>Fix fix for Unix paths on Windows file systems.<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using log4net.Core;

namespace SlimJim.Model
{
	public class SlnGenerationOptions
	{
		private const string DefaultSolutionName = "SlimJim";
		private string projectsRootDirectory;
		private string solutionName;
		private string slnOutputPath;
		private readonly List<string> additionalSearchPaths;
		private readonly List<string> ignoreDirectoryPatterns;

		public SlnGenerationOptions(string workingDirectory)
		{
			ProjectsRootDirectory = workingDirectory;
			additionalSearchPaths = new List<string>();
			ignoreDirectoryPatterns = new List<string>();
			TargetProjectNames = new List<string>();
			VisualStudioVersion = VisualStudioVersion.VS2012;
			LoggingThreshold = Level.Info;
		}

		public List<string> TargetProjectNames { get; private set; }

		public string ProjectsRootDirectory
		{
			get { return projectsRootDirectory; }
			set
			{
				projectsRootDirectory = ResolvePath(value);
			}
		}

		public VisualStudioVersion VisualStudioVersion { get; set; }
		public bool IncludeEfferentAssemblyReferences { get; set; }
		public bool ShowHelp { get; set; }
		public bool ConvertReferences { get; set; }
		public bool RestoreReferences { get; set; }
		public bool FixHintPaths { get; set; }
		public bool RestoreHintPaths { get; set; }
		public bool OpenInVisualStudio { get; set; }
		public Level LoggingThreshold { get; set; }

		public List<string> AdditionalSearchPaths
		{
			get
			{
				return additionalSearchPaths.ConvertAll(ResolvePath);
			}
		}

		private string ResolvePath(string p)
		{
			return !Path.IsPathRooted(p) ? Path.Combine(ProjectsRootDirectory, p) : p;
		}

		public string SlnOutputPath
		{
			get { return slnOutputPath != null ? ResolvePath(slnOutputPath) : ProjectsRootDirectory; }
			set { slnOutputPath = value; }
		}

		public string SolutionName
		{
			get
			{
				if (string.IsNullOrEmpty(solutionName))
				{
					if (TargetProjectNames.Count > 0)
					{
						return string.Join("_", TargetProjectNames);
					}

					if (!string.IsNullOrEmpty(ProjectsRootDirectory))
					{
						return GetLastSegmentNameOfProjectsRootDirectory();
					}

					return DefaultSolutionName;
				}

				return solutionName;
			}
			set { solutionName = value; }
		}

		private string GetLastSegmentNameOfProjectsRootDirectory()
		{
			var dir = new DirectoryInfo(ProjectsRootDirectory);
            
			if (string.IsNullOrEmpty(dir.Name) || dir.FullName == dir.Root.FullName)
			{
				return DefaultSolutionName;
			}
			return dir.Name;
		}

		public SlnGenerationMode Mode
		{
			get
			{
				return TargetProjectNames.Count == 0
{'fraction_non_alphanumeric': 0.08426763110307414, 'fraction_numerical': 0.0028933092224231465, 'mean_word_length': 3.8390201224846896, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '2638004', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1591, 'n_words': 389}