コード例 #1
0
        /// <summary>Checks type members.</summary>
        /// <param name="member">Member being checked.</param>
        /// <returns>A collection of problems found in <paramref name="member"/> or null.</returns>
        public override ProblemCollection Check(Member member)
        {
            Method method = member as Method;

            if (method == null)
            {
                return(null);
            }

            methodUnderCheck = method;
            const string     RequestUriName                 = "Microsoft.OData.Service.RequestUriProcessor.ProcessRequestUri(System.String,Microsoft.OData.Service.IDataService)";
            const string     CheckResourceRightsName        = "Microsoft.OData.Service.DataServiceConfiguration.CheckResourceRights(Microsoft.OData.Service.Providers.ResourceContainer,Microsoft.OData.Service.EntitySetRights)";
            const string     CheckResourceRightsForReadName = "Microsoft.OData.Service.DataServiceConfiguration.CheckResourceRightsForRead(Microsoft.OData.Service.Providers.ResourceContainer,System.Boolean)";
            MethodCallFinder finder = new MethodCallFinder(RequestUriName, CheckResourceRightsName, CheckResourceRightsForReadName);

            finder.Visit(method);
            if (finder.Found(RequestUriName) &&
                (!finder.Found(CheckResourceRightsForReadName) &&
                 !finder.Found(CheckResourceRightsName)))
            {
                this.Problems.Add(new Problem(GetResolution(method.FullName)));
            }

            return(Problems.Count > 0 ? Problems : null);
        }
コード例 #2
0
        /// <summary>Checks type members.</summary>
        /// <param name="member">Member being checked.</param>
        /// <returns>A collection of problems found in <paramref name="member"/> or null.</returns>
        public override ProblemCollection Check(Member member)
        {
            Method method = member as Method;

            if (method == null)
            {
                return(null);
            }

            methodUnderCheck = method;
            MethodCallFinder finder = new MethodCallFinder(MethodsNotAllowedOutsideMetadataPath.ToArray());

            finder.Visit(method);
            if (!IsMethodSafeToEnumerateTypes(method.FullName))
            {
                foreach (string metadataOnlyMethod in MethodsNotAllowedOutsideMetadataPath)
                {
                    if (finder.Found(metadataOnlyMethod))
                    {
                        this.Problems.Add(new Problem(GetResolution(method.FullName, metadataOnlyMethod)));
                    }
                }
            }

            return(Problems.Count > 0 ? Problems : null);
        }
コード例 #3
0
 public override void VisitCatch(Microsoft.FxCop.Sdk.CatchNode catchNode)
 {
     if (catchNode.Type == FrameworkTypes.Exception)
     {
         string[] doNotHandleMethods = new string[] { 
             "Microsoft.OData.Service.CommonUtil.IsCatchableExceptionType(System.Exception)", 
             "Microsoft.OData.Client.CommonUtil.IsCatchableExceptionType(System.Exception)",
             "Microsoft.OData.Core.ExceptionUtils.IsCatchableExceptionType(System.Exception)",
             "Microsoft.Spatial.Util.IsCatchableExceptionType(System.Exception)",
         };
         MethodCallFinder finder = new MethodCallFinder(true, doNotHandleMethods);
         finder.Visit(catchNode.Block);
         if(!doNotHandleMethods.Any(m => finder.Found(m)))
         {
             Problems.Add(new Problem(GetResolution(methodUnderCheck.FullName), catchNode));
         }
     }
     base.VisitCatch(catchNode);
 }
コード例 #4
0
 public override void VisitCatch(Microsoft.FxCop.Sdk.CatchNode catchNode)
 {
     if (catchNode.Type == FrameworkTypes.Exception)
     {
         string[] doNotHandleMethods = new string[] {
             "Microsoft.OData.Service.CommonUtil.IsCatchableExceptionType(System.Exception)",
             "Microsoft.OData.Client.CommonUtil.IsCatchableExceptionType(System.Exception)",
             "Microsoft.OData.Core.ExceptionUtils.IsCatchableExceptionType(System.Exception)",
             "Microsoft.Spatial.Util.IsCatchableExceptionType(System.Exception)",
         };
         MethodCallFinder finder = new MethodCallFinder(true, doNotHandleMethods);
         finder.Visit(catchNode.Block);
         if (!doNotHandleMethods.Any(m => finder.Found(m)))
         {
             Problems.Add(new Problem(GetResolution(methodUnderCheck.FullName), catchNode));
         }
     }
     base.VisitCatch(catchNode);
 }
コード例 #5
0
        /// <summary>Checks type members.</summary>
        /// <param name="member">Member being checked.</param>
        /// <returns>A collection of problems found in <paramref name="member"/> or null.</returns>
        public override ProblemCollection Check(Member member)
        {
            Method method = member as Method;
            if (method == null)
            {
                return null;
            }

            methodUnderCheck = method;
            const string RequestUriName = "Microsoft.OData.Service.RequestUriProcessor.ProcessRequestUri(System.String,Microsoft.OData.Service.IDataService)";
            const string CheckResourceRightsName = "Microsoft.OData.Service.DataServiceConfiguration.CheckResourceRights(Microsoft.OData.Service.Providers.ResourceContainer,Microsoft.OData.Service.EntitySetRights)";
            const string CheckResourceRightsForReadName = "Microsoft.OData.Service.DataServiceConfiguration.CheckResourceRightsForRead(Microsoft.OData.Service.Providers.ResourceContainer,System.Boolean)";
            MethodCallFinder finder = new MethodCallFinder(RequestUriName, CheckResourceRightsName, CheckResourceRightsForReadName);
            finder.Visit(method);
            if (finder.Found(RequestUriName) &&
                (!finder.Found(CheckResourceRightsForReadName) &&
                 !finder.Found(CheckResourceRightsName)))
            {
                this.Problems.Add(new Problem(GetResolution(method.FullName)));
            }

            return Problems.Count > 0 ? Problems : null;
        }
コード例 #6
0
        /// <summary>Checks type members.</summary>
        /// <param name="member">Member being checked.</param>
        /// <returns>A collection of problems found in <paramref name="member"/> or null.</returns>
        public override ProblemCollection Check(Member member)
        {
            Method method = member as Method;
            if (method == null)
            {
                return null;
            }

            methodUnderCheck = method;
            MethodCallFinder finder = new MethodCallFinder(MethodsNotAllowedOutsideMetadataPath.ToArray());
            finder.Visit(method);
            if (!IsMethodSafeToEnumerateTypes(method.FullName))
            {
                foreach (string metadataOnlyMethod in MethodsNotAllowedOutsideMetadataPath)
                {
                    if (finder.Found(metadataOnlyMethod))
                    {
                        this.Problems.Add(new Problem(GetResolution(method.FullName, metadataOnlyMethod)));
                    }
                }
            }

            return Problems.Count > 0 ? Problems : null;
        }