Exemple #1
0
        private bool?ShouldTraceBasedOnClassLevelInfo(MethodDefinition definition)
        {
            var attributeInfo = GetTraceAttributeInfoForType(definition.DeclaringType);

            if (attributeInfo != null)
            {
                if (attributeInfo.IsNoTrace)
                {
                    return(false);
                }

                var targetVisibility = attributeInfo.TargetVisibility;
                var methodVisibility = VisibilityHelper.GetMethodVisibilityLevel(definition);
                return((int)targetVisibility >= (int)methodVisibility);
            }

            return(null);
        }
Exemple #2
0
        internal override bool IsMatching(MethodDefinition methodDefinition)
        {
            if (base.IsMatching(methodDefinition))
            {
                var declaringType         = methodDefinition.DeclaringType;
                var typeVisibility        = VisibilityHelper.GetTypeVisibilityLevel(declaringType);
                var methodVisibilityLevel = VisibilityHelper.GetMethodVisibilityLevel(methodDefinition);

                //check type visibility
                if ((int)typeVisibility > (int)_targetClass)
                {
                    return(false);
                }

                //then method visibility will decide
                return((int)methodVisibilityLevel <= (int)_targetMethod);
            }
            return(false);
        }
Exemple #3
0
        public FilterResult?ShouldTraceBasedOnClassLevelInfo(MethodDefinition definition)
        {
            var attributeInfo = GetTraceAttributeInfoForType(definition.DeclaringType);

            if (attributeInfo != null)
            {
                if (attributeInfo.IsNoTrace)
                {
                    return(new FilterResult(false));
                }

                var targetVisibility = attributeInfo.TargetVisibility;
                var methodVisibility = VisibilityHelper.GetMethodVisibilityLevel(definition);
                var shouldTrace      = (int)targetVisibility >= (int)methodVisibility;

                return(new FilterResult(shouldTrace, attributeInfo.Parameters));
            }

            return(null);
        }