示例#1
0
        /// White list check for a given syntax context (check its node)
        public static bool IsExcluded(this SyntaxNodeAnalysisContext context, string diagnosticID)
        {
            UEASettingReader uEASettingReader = new UEASettingReader();

            uEASettingReader.ReadConfigFile();
            string assembly = context.SemanticModel.Compilation.AssemblyName;

            if (assembly != "Assembly-CSharp.dll" &&
                assembly != "Assembly-CSharp" &&
                assembly != "com.unity.postprocessing.Runtime" &&
                assembly != "com.unity.postprocessing.Runtime.dll")
            {
                return(true);
            }
            if (IsInDebugInvocation(context.Node, context.SemanticModel))
            {
                return(true);
            }
            if (CheckWhiteList(context, uEASettingReader))
            {
                return(true);
            }


            return(IsExcluded(context.Node, diagnosticID));
        }
示例#2
0
        public static bool CheckWhiteList(SyntaxNodeAnalysisContext context, UEASettingReader uEASettingReader)
        {
            var root = context.SemanticModel.SyntaxTree.GetRoot() as CompilationUnitSyntax;

            if (root == null)
            {
                return(true);
            }

            // check if in UnityEditor directory
            var         filePath    = root.GetLocation().ToString();
            UEASettings uEASettings = uEASettingReader.ReadConfigFile();

            foreach (var regexStatement in uEASettings.ignoreFoldeRegexStrings)
            {
                var regex = new System.Text.RegularExpressions.Regex(regexStatement);
                if (regex.IsMatch(filePath))
                {
                    return(true);
                }
            }
            return(false);
        }