<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;

namespace Nethereum.Generators.Core
{
    public static class CodeGenLanguageExt
    {

        private static readonly Dictionary<CodeGenLanguage, string> ProjectFileExtensions = new Dictionary<CodeGenLanguage, string>
        {
            {CodeGenLanguage.CSharp, ".csproj"},
            {CodeGenLanguage.FSharp, ".fsproj"},
            {CodeGenLanguage.Vb, ".vbproj"}
        };

        public static string AddProjectFileExtension(this CodeGenLanguage language, string projectFileName)
        {
            if (string.IsNullOrEmpty(projectFileName))
                throw new ArgumentNullException(nameof(projectFileName));
            

            if (ProjectFileExtensions.ContainsKey(language))
            {
                var extension = ProjectFileExtensions[language];
                var requestedExtension = Path.GetExtension(projectFileName);
                if (string.IsNullOrEmpty(requestedExtension))
                    return $"{projectFileName.TrimEnd('.')}{extension}";

                return Path.ChangeExtension(projectFileName, extension);
            }

            return null;
        }

        public static string GetCodeOutputFileExtension(this CodeGenLanguage codeGenLanguage)
        {
            if (codeGenLanguage == CodeGenLanguage.CSharp)
                return "cs";
            else if (codeGenLanguage == CodeGenLanguage.Vb)
            {
                return "vb";
            }<commit_msg>Fixed automatic project extension setting for files names containing dots.<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;

namespace Nethereum.Generators.Core
{
    public static class CodeGenLanguageExt
    {

        private static readonly Dictionary<CodeGenLanguage, string> ProjectFileExtensions = new Dictionary<CodeGenLanguage, string>
        {
            {CodeGenLanguage.CSharp, ".csproj"},
            {CodeGenLanguage.FSharp, ".fsproj"},
            {CodeGenLanguage.Vb, ".vbproj"}
        };

        public static string AddProjectFileExtension(this CodeGenLanguage language, string projectFileName)
        {
            if (string.IsNullOrEmpty(projectFileName))
                throw new ArgumentNullException(nameof(projectFileName));
            

            if (ProjectFileExtensions.ContainsKey(language))
            {
                var extension = ProjectFileExtensions[language];

                if (projectFileName.EndsWith(extension, StringComparison.InvariantCultureIgnoreCase))
                    return projectFileName;

                return projectFileName + extension;
            }

            return null;
        }

        public static string GetCodeOutputFileExtension(this CodeGenLanguage codeGenLanguage)
        {
            if (codeGenLanguage == CodeGenLanguage.CSharp)
                return "cs";
            else if (codeGenLanguage == CodeGenLanguage.Vb)
            {
                return "vb";
            }
{'fraction_non_alphanumeric': 0.07608336089976844, 'fraction_numerical': 0.0, 'mean_word_length': 2.2, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4734694', 'n_tokens_mistral': 719, 'n_tokens_neox': 677, 'n_words': 155}