Beispiel #1
0
        private bool IsProcessExcluded(string processName)
        {
            if (!ExclusionFilters.Any())
            {
                return(false);
            }

            var matchingExclusionFilters = ExclusionFilters.GetMatchingFiltersForProcessName(processName);

            // Excluded by all filters
            return(matchingExclusionFilters.Any(exclusionFilter => (exclusionFilter.AssemblyName == ".*" && exclusionFilter.ClassName == ".*")));
        }
Beispiel #2
0
        /// <summary>
        /// Should we instrument this asssembly
        /// </summary>
        /// <param name="processPath"></param>
        /// <returns></returns>
        public bool InstrumentProcess(string processPath)
        {
            if (string.IsNullOrEmpty(processPath))
            {
                return(false);
            }
            if (!ExclusionFilters.Any() && !InclusionFilters.Any())
            {
                return(true);
            }

            var processName = Path.GetFileNameWithoutExtension(processPath); // can return null!

            if (ExclusionFilters.Any())
            {
                var matchingExclusionFilters = new List <AssemblyAndClassFilter>(ExclusionFilters.GetMatchingFiltersForProcessName(processPath));
                if (!string.IsNullOrWhiteSpace(processName) && processName != processPath)
                {
                    matchingExclusionFilters.AddRange(ExclusionFilters.GetMatchingFiltersForProcessName(processName));
                }
                if (matchingExclusionFilters.Any
                        (exclusionFilter =>
                        // class-filter is .* and assembly-filter is matching processName
                        // this does not match default exclude filters like {.*}[mscorlib].* or {.*}[system].*
                        // but does match {.*}[.*].* or {.*}[processNa*].* or {.*}[processName].* where assemblyName == processName
                        exclusionFilter.ClassName == ".*" && exclusionFilter.IsMatchingAssemblyName(processName)
                        )
                    )
                {
                    return(false);
                }
            }

            if (InclusionFilters.Any())
            {
                var matchingInclusionFilters = new List <AssemblyAndClassFilter>(InclusionFilters.GetMatchingFiltersForProcessName(processPath));
                if (!string.IsNullOrWhiteSpace(processName) && processName != processPath)
                {
                    matchingInclusionFilters.AddRange(InclusionFilters.GetMatchingFiltersForProcessName(processName));
                }
                return(matchingInclusionFilters.Any());
            }

            return(true); // not excluded and no inclusion filters
        }
Beispiel #3
0
        public bool InstrumentProcess(string processName)
        {
            if (string.IsNullOrEmpty(processName))
            {
                return(false);
            }

            processName = Path.GetFileNameWithoutExtension(processName);
            var matchingExclusionFilters = ExclusionFilters.GetMatchingFiltersForProcessName(processName);

            if (matchingExclusionFilters.Any(exclusionFilter => exclusionFilter.AssemblyName == ".*" && exclusionFilter.ClassName == ".*"))
            {
                return(false);
            }

            var matchingInclusionFilters = InclusionFilters.GetMatchingFiltersForProcessName(processName);

            return(matchingInclusionFilters.Any(inclusionFilter => inclusionFilter.AssemblyName == ".*" || inclusionFilter.ClassName == ".*"));
        }