< Summary

Class:ProtobufEditorHelper
Assembly:DCL.Protobuf
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ProtocolBuffers/Editor/ProtobufEditorHelper.cs
Covered lines:0
Uncovered lines:22
Coverable lines:22
Total lines:49
Line coverage:0% (0 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CloneDirectory(...)0%20400%
ToSnakeCase(...)0%30500%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ProtocolBuffers/Editor/ProtobufEditorHelper.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.IO;
 5using System.Text;
 6using UnityEngine;
 7
 8public static class ProtobufEditorHelper
 9{
 10    public static void CloneDirectory(string root, string dest)
 11    {
 012        foreach (var directory in Directory.GetDirectories(root))
 13        {
 014            string dirName = Path.GetFileName(directory);
 015            if (!Directory.Exists(Path.Combine(dest, dirName)))
 16            {
 017                Directory.CreateDirectory(Path.Combine(dest, dirName));
 18            }
 019            CloneDirectory(directory, Path.Combine(dest, dirName));
 20        }
 21
 022        foreach (var file in Directory.GetFiles(root))
 23        {
 024            File.Copy(file, Path.Combine(dest, Path.GetFileName(file)));
 25        }
 026    }
 27
 28    public static string ToSnakeCase(this string text)
 29    {
 030        if(text == null) {
 031            throw new ArgumentNullException(nameof(text));
 32        }
 033        if(text.Length < 2) {
 034            return text;
 35        }
 036        var sb = new StringBuilder();
 037        sb.Append(char.ToLowerInvariant(text[0]));
 038        for(int i = 1; i < text.Length; ++i) {
 039            char c = text[i];
 040            if(char.IsUpper(c)) {
 041                sb.Append('_');
 042                sb.Append(char.ToLowerInvariant(c));
 043            } else {
 044                sb.Append(c);
 45            }
 46        }
 047        return sb.ToString();
 48    }
 49}