コード例 #1
0
        public static bool IsDeclaredEscaping(Parameter p, out bool owned)
        {
            if (WorstCase)
            {
                owned = true;
                return(true);
            }
            bool res = false;

            owned = false;
            if (p.GetAttribute(SystemTypes.CapturedAttribute) != null)
            {
                owned = true;
                return(true);
            }
            if (p is This)
            {
                Method m = ((This)p).DeclaringMethod;
                return(IsEscaping(m, out owned));
            }
            AttributeNode attr = p.GetAttribute(SystemTypes.EscapesAttribute);

            if (attr != null)
            {
                Microsoft.Contracts.EscapesAttribute escAttr = (Microsoft.Contracts.EscapesAttribute)attr.GetRuntimeAttribute();
                if (escAttr != null)
                {
                    res   = escAttr.Value;
                    owned = escAttr.Owned;
                }
            }
            return(res);
        }
コード例 #2
0
        public static bool IsEscaping(Method m, out bool owned)
        {
            if (WorstCase)
            {
                owned = true;
                return(true);
            }

            bool res = false;

            owned = false;
            if (!m.IsStatic)
            {
                if (m.GetAttribute(SystemTypes.CapturedAttribute) != null)
                {
                    owned = true;
                    return(true);
                }
            }
            AttributeNode attr = m.GetAttribute(SystemTypes.EscapesAttribute);

            if (attr != null)
            {
                Microsoft.Contracts.EscapesAttribute escAttr = (Microsoft.Contracts.EscapesAttribute)attr.GetRuntimeAttribute();
                if (escAttr != null)
                {
                    res   = escAttr.Value;
                    owned = escAttr.Owned;
                }
            }
            return(res && !IsConstructor(m));
        }