protected override void Logic(ValidationTarget target)
        {
            var extList = new List <string>();

            foreach (var extention in extentions)
            {
                if (!string.IsNullOrEmpty(extention))
                {
                    var ext = extention.StartsWith(".") ? extention : "." + extention;
                    extList.Add(ext);
                }
                else
                {
                    // ユーザーが対処できるメッセージではないのでコメントアウト
                    //AddIssue(new Issue(null, IssueLevel.Warning, "設定された拡張子は空文字のため無視されます。", string.Empty, string.Empty));
                }
            }
            var hitPaths = target.GetAllAssetPaths()
                           .Where(targetPath => extList.Exists(ext => ext.Equals(Path.GetExtension(targetPath), StringComparison.InvariantCultureIgnoreCase)));
            var baseFolderPath = target.GetBaseFolderPath();

            foreach (var path in hitPaths)
            {
                if (AssetDatabase.IsValidFolder(path) || !path.StartsWith(baseFolderPath))
                {
                    continue;
                }
                var obj     = AssetDatabase.LoadMainAssetAtPath(path);
                var message = LocalizedMessage.Get("AssetExtentionBlacklistRule.UnauthorizedExtention", Path.GetExtension(path)) + Environment.NewLine + path;
                AddIssue(new Issue(obj, IssueLevel.Error, message, string.Empty, string.Empty));
            }
        }
Exemplo n.º 2
0
        protected override void Logic(ValidationTarget target)
        {
            //前提チェック
            if (string.IsNullOrEmpty(target.GetBaseFolderPath()))
            {
                throw new FatalValidationErrorException("ベースフォルダが指定されていません。");
            }
            //チェック結果を設定
            var baseFolder = AssetDatabase.LoadAssetAtPath <DefaultAsset>(target.GetBaseFolderPath());

            AddIssue(new Issue(baseFolder, IssueLevel.Info, "これはtargetを設定したサンプルルールの検証結果です。target:" + baseFolder.name));
            AddIssue(new Issue(null, IssueLevel.Info, "これはサンプルルールの解決策付き検証結果(情報)です。", "解決策テキスト", "https://github.com/vitdeck/VitDeck/wiki"));
            var items = "";

            for (int i = 0; i < 10; i++)
            {
                items += "- item" + Environment.NewLine;
            }
            AddIssue(new Issue(null, IssueLevel.Warning, "これはサンプルルールの改行の多い検証結果(警告)です。" + Environment.NewLine + items, "解決策テキスト", "https://github.com/vitdeck/VitDeck/wiki"));
            AddIssue(new Issue(null, IssueLevel.Error, "これはサンプルルールの検証結果(エラー)です。長い文------------------------------------------------------------章", "解決策テキスト", "https://github.com/vitdeck/VitDeck/wiki"));

            AddResultLog("Ruleのissueに紐付かないログです。customSetting:" + customSetting);
        }
        protected override void Logic(ValidationTarget target)
        {
            var hitObjectPaths = target.GetAllAssetGuids()
                                 .Where(targetGuid => IsUnauthorized(targetGuid, target.GetBaseFolderPath()))
                                 .Select(guid => AssetDatabase.GUIDToAssetPath(guid));

            foreach (var path in hitObjectPaths)
            {
                var obj      = AssetDatabase.LoadMainAssetAtPath(path);
                var message  = LocalizedMessage.Get("AssetGuidBlacklistRule.UnauthorizedAssetDetected", path);
                var solution = LocalizedMessage.Get("AssetGuidBlacklistRule.UnauthorizedAssetDetected.Solution");
                AddIssue(new Issue(obj, IssueLevel.Error, message, solution, string.Empty));
            }
        }
        protected override void Logic(ValidationTarget target)
        {
            var path = target.GetBaseFolderPath();

            if (!permissionPattern.IsMatch(path))
            {
                this.AddIssue(new Issue(
                                  AssetDatabase.LoadMainAssetAtPath(path),
                                  IssueLevel.Error,
                                  "ベースフォルダのパスが規則に一致しません。",
                                  this.solution,
                                  this.solutionURL
                                  ));
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 定められたルールに従って検証する。検証後にresultフィールドを結果として返す
 /// </summary>
 /// <param name="baseFolder">ベースフォルダの`Assets/`から始まる相対パス。</param>
 /// <returns>`result`に格納された検証結果</returns>
 public ValidationResult Validate(ValidationTarget target)
 {
     result = new ValidationResult(name);
     try
     {
         var path = target.GetBaseFolderPath();
         if (!AssetDatabase.IsValidFolder(path))
         {
             throw new FatalValidationErrorException(string.Format("正しいベースフォルダを指定してください。:{0}", path));
         }
         Logic(target);
     }
     catch (FatalValidationErrorException e)
     {
         result.AddIssue(new Issue(null, IssueLevel.Fatal, e.Message));
         throw e;
     }
     return(result);
 }
Exemplo n.º 6
0
        protected override void Logic(ValidationTarget target)
        {
            var path = target.GetBaseFolderPath();

            var di         = new DirectoryInfo(path);
            var folderSize = GetDirectorySize(di);

            if (folderSize > limit)
            {
                var excess    = folderSize - limit;
                var reference = AssetDatabase.LoadMainAssetAtPath(path);
                var message   = LocalizedMessage.Get("FolderSizeRule.Exceeded",
                                                     SIReadableNumberText.Get(limit, "B"),
                                                     SIReadableNumberText.Get(folderSize, "B"),
                                                     SIReadableNumberText.Get(excess, "B"));
                var solution    = LocalizedMessage.Get("FolderSizeRule.Exceeded.Solution");
                var solutionURL = LocalizedMessage.Get("FolderSizeRule.Exceeded.SolutionURL");
                AddIssue(new Issue(reference, IssueLevel.Error, message, solution, solutionURL));
            }
        }
Exemplo n.º 7
0
        protected override void Logic(ValidationTarget target)
        {
            var rootObjects  = target.GetRootObjects();
            var rootPath     = target.GetBaseFolderPath();
            var assetObjects = target.GetAllAssets();
            var assetPaths   = target.GetAllAssetPaths();

            for (var i = 0; i < assetObjects.Length; i++)
            {
                var asset = assetObjects[i];
                var path  = assetPaths[i];
                if (!(path.IndexOf(rootPath, StringComparison.Ordinal) == 0 && path.Length > rootPath.Length))
                {
                    continue;
                }
                var localPath = path.Substring(rootPath.Length + 1);
                // UdonScript以下のみ探索
                if (localPath.IndexOf(_scriptAssetPath, StringComparison.Ordinal) == 0 && asset is MonoScript src)
                {
                    // U# スクリプトは UdonSharpBehaviour を直接継承していなければならない
                    Type srcType  = src.GetClass();
                    var  baseType = srcType.UnderlyingSystemType.BaseType;
                    if (baseType == null || baseType.FullName != _baseClassName)
                    {
                        AddIssue(new Issue(asset, IssueLevel.Error, LocalizedMessage.Get("UdonSharpScriptNamespaceRule.NotUdonSharp", src.GetClass())));
                    }
                    // U# スクリプトは 正しい名前空間で定義されなければならない
                    if (srcType.Namespace == null || srcType.Namespace.IndexOf(namespaceString, StringComparison.Ordinal) == -1)
                    {
                        AddIssue(
                            new Issue(
                                asset,
                                IssueLevel.Error,
                                LocalizedMessage.Get("UdonSharpScriptNamespaceRule.InvalidNamespace"),
                                LocalizedMessage.Get("UdonSharpScriptNamespaceRule.InvalidNamespace.solution", src.GetClass())
                                )
                            );
                    }
                }
            }
        }
Exemplo n.º 8
0
        protected override void Logic(ValidationTarget target)
        {
            var paths          = target.GetAllAssetPaths();
            var matchPattern   = string.Format("^{0}$", permissionPattern);
            var rootFolderPath = target.GetBaseFolderPath();

            foreach (var path in paths)
            {
                if (!path.StartsWith(rootFolderPath))
                {
                    continue;
                }
                var assetName = Path.GetFileName(path);
                if (!Regex.IsMatch(assetName, matchPattern))
                {
                    string prohibition = GetProhibitionPattern(assetName, permissionPattern);
                    var    reference   = AssetDatabase.LoadMainAssetAtPath(path);
                    var    message     = LocalizedMessage.Get("AssetNamingRule.UnauthorizedTextDetected", path, prohibition);
                    AddIssue(new Issue(reference, IssueLevel.Error, message, string.Empty));
                }
            }
        }
        protected override void Logic(ValidationTarget target)
        {
            var referenceDictionary = targetFinder.ReferenceDictionary;

            // 除外する配布物アセットのパス
            var excludePaths = unauthorizedIDSet
                               .Select(guid => AssetDatabase.GUIDToAssetPath(guid));

            // 入稿フォルダ内および出展物から参照されるすべてのアセットのパス
            var allAssetPaths   = target.GetAllAssetPaths();
            var submitDirectory = target.GetBaseFolderPath();

            // 入稿フォルダ内に配置されているファイルのパス
            // GetFilesで取得したパス名にはバックスラッシュが混在するためスラッシュに変換
            var filePathsInSubmitDirectory = Directory
                                             .GetFiles(submitDirectory, "*", SearchOption.AllDirectories)
                                             .Select(x => x.Replace("\\", "/"));

            // 入稿フォルダ内のディレクトリのパス
            var folderPathInSubmitDirectory = Directory
                                              .GetDirectories(submitDirectory, "*", SearchOption.AllDirectories)
                                              .Select(x => x.Replace("\\", "/"));

            foreach (var assetPath in allAssetPaths)
            {
                // Unityのビルトインアセットを除外
                if (!assetPath.StartsWith("Assets"))
                {
                    continue;
                }

                // 運営からの配布物を検証対象から除外
                if (excludePaths.Contains(assetPath))
                {
                    continue;
                }

                // 入稿フォルダ内のサブディレクトリ(アセット含まない)を検証対象から除外
                if (folderPathInSubmitDirectory.Contains(assetPath) || assetPath == submitDirectory)
                {
                    continue;
                }

                // 入稿フォルダ内にパスがあるアセットなのか検証
                if (filePathsInSubmitDirectory.Contains(assetPath))
                {
                    continue;
                }

#if VRC_SDK_VRCSDK3
                // VRCSDK3: SerializedUdonPrograms の中を除外
                if (assetPath.StartsWith("Assets/SerializedUdonPrograms/"))
                {
                    continue;
                }
#endif

                // エラー対象である事が確定したためIssue発行
                var targetAsset = AssetDatabase.LoadMainAssetAtPath(assetPath);
                referenceDictionary.Reverse.TryGetValue(targetAsset, out var referrerAssets);

                var referrerMessage =
                    LocalizedMessage.Get("ExistInSubmitFolderRule.HasOutOfPackageReference", assetPath);
                var referrerSolution =
                    LocalizedMessage.Get("ExistInSubmitFolderRule.HasOutOfPackageReference.Solution");
                var referrerSolutionURL =
                    LocalizedMessage.Get("ExistInSubmitFolderRule.HasOutOfPackageReference.SolutionURL");

                if (referrerAssets != null)
                {
                    foreach (var referrerAsset in referrerAssets)
                    {
                        AddIssue(new Issue(referrerAsset, IssueLevel.Error, referrerMessage, referrerSolution, referrerSolutionURL));
                    }
                }

                var message  = LocalizedMessage.Get("ExistInSubmitFolderRule.AssetOutOfPackage", assetPath);
                var solution = LocalizedMessage.Get("ExistInSubmitFolderRule.AssetOutOfPackage.Solution");

                AddIssue(new Issue(targetAsset, IssueLevel.Error, message, solution));
            }
        }