public CtrlSpaceCompletionProvider(ICompletionDataGenerator cdg, IBlockNode b, IStatement stmt, MemberFilter vis = MemberFilter.All)
     : base(cdg)
 {
     this.curBlock = b;
     this.curStmt = stmt;
     visibleMembers = vis;
 }
 static Type()
 {
     System.__Filters filters = new System.__Filters();
     FilterAttribute = new MemberFilter(filters.FilterAttribute);
     FilterName = new MemberFilter(filters.FilterName);
     FilterNameIgnoreCase = new MemberFilter(filters.FilterIgnoreCase);
 }
        public static void EnumChildren(ICompletionDataGenerator cdgen,ResolutionContext ctxt, UserDefinedType udt, bool isVarInstance, 
			MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums)
        {
            var scan = new MemberCompletionEnumeration(ctxt, cdgen) { isVarInst = isVarInstance };

            scan.DeepScanClass(udt, vis);
        }
        public static void EnumChildren(ICompletionDataGenerator cdgen,ResolutionContext ctxt, IBlockNode block, bool isVarInstance,
			MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums, bool publicImports = false)
        {
            var scan = new MemberCompletionEnumeration(ctxt, cdgen) { isVarInst = isVarInstance };

            scan.ScanBlock(block, CodeLocation.Empty, vis, publicImports);
        }
示例#5
0
		public static List<INode> EnumScopedBlockChildren (ResolutionContext ctxt,MemberFilter VisibleMembers)
		{
			var en = new ItemEnumeration (ctxt);

			en.ScanBlock(ctxt.ScopedBlock, ctxt.ScopedBlock.EndLocation, VisibleMembers);

			return en.Nodes;
		}
示例#6
0
		public static List<INode> EnumChildren(UserDefinedType ds,ResolutionContext ctxt, MemberFilter VisibleMembers)
		{
			var en = new ItemEnumeration(ctxt);

			en.DeepScanClass(ds, new ItemCheckParameters(VisibleMembers));

			return en.Nodes;
		}
        public static void EnumChildren(ICompletionDataGenerator cdgen,ResolutionContext ctxt, UserDefinedType udt, 
			MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums)
        {
            vis ^= MemberFilter.TypeParameters;

            var scan = new MemberCompletionEnumeration(ctxt, cdgen) { isVarInst = udt.NonStaticAccess };

            scan.DeepScanClass(udt, vis);
        }
 static SafeInvokeHelper()
 {
     AssemblyName name = new AssemblyName();
     name.Name = "temp";
     myAsmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run);
     builder = myAsmBuilder.DefineDynamicModule("TempModule");
     methodLookup = new Hashtable();
     delLookup=new Hashtable();
     methodFilter = new MemberFilter(FiltByMethodName);
     lastCleanTime = DateTime.Now;
 }
示例#9
0
        public static IEnumerable<INode> EnumAllAvailableMembers(
			ResolverContextStack ctxt,
			CodeLocation Caret,
			MemberFilter VisibleMembers)
        {
            var en = new ItemEnumeration(ctxt);

            en.IterateThroughScopeLayers(Caret, VisibleMembers);

            return en.Nodes.Count <1 ? null : en.Nodes;
        }
示例#10
0
        public static bool CanAddMemberOfType(MemberFilter vis, INode n)
        {
            if (n is DMethod)
                return n.NameHash != 0 && ((vis & MemberFilter.Methods) == MemberFilter.Methods);

            else if (n is DVariable)
            {
                var d = n as DVariable;

                if (d.IsAliasThis)
                    return false;

                // Only add aliases if at least types,methods or variables shall be shown.
                if (d.IsAlias)
                    return
                        vis.HasFlag(MemberFilter.Methods) ||
                        vis.HasFlag(MemberFilter.Types) ||
                        vis.HasFlag(MemberFilter.Variables);

                return (vis & MemberFilter.Variables) == MemberFilter.Variables;
            }

            else if (n is DClassLike)
            {
                var dc = n as DClassLike;
                switch (dc.ClassType)
                {
                    case DTokens.Class:
                        return (vis & MemberFilter.Classes) != 0;
                    case DTokens.Interface:
                        return (vis & MemberFilter.Interfaces) != 0;
                    case DTokens.Template:
                        return (vis & MemberFilter.Templates) != 0;
                    case DTokens.Struct:
                    case DTokens.Union:
                        return (vis & MemberFilter.StructsAndUnions) != 0;
                }
            }

            else if (n is DEnum)
            {
                var d = n as DEnum;

                // Only show enums if a) they're named and enums are allowed or b) variables are allowed
                return d.IsAnonymous ?
                    (vis & MemberFilter.Variables) != 0 :
                    (vis & MemberFilter.Enums) != 0;
            }
            else if (n is NamedTemplateMixinNode)
                return (vis & (MemberFilter.Variables | MemberFilter.Types)) == (MemberFilter.Variables | MemberFilter.Types);

            return false;
        }
示例#11
0
		Parser(ParserArguments arguments)
		{
			_arguments = arguments;

			_bindingCase = arguments.Settings.CaseInsensitive ? BindingFlags.IgnoreCase : BindingFlags.Default;
			_memberFilterCase = arguments.Settings.CaseInsensitive ? Type.FilterNameIgnoreCase : Type.FilterName;

			_expressionText = arguments.ExpressionText ?? string.Empty;
			_expressionTextLength = _expressionText.Length;
			SetTextPos(0);
			NextToken();
		}
        public static void EnumAllAvailableMembers(ICompletionDataGenerator cdgen, IBlockNode ScopedBlock
			, IStatement ScopedStatement,
			CodeLocation Caret,
		    ParseCacheView CodeCache,
			MemberFilter VisibleMembers,
			ConditionalCompilationFlags compilationEnvironment = null)
        {
            var ctxt = ResolutionContext.Create(CodeCache, compilationEnvironment, ScopedBlock, ScopedStatement);

            var en = new MemberCompletionEnumeration(ctxt, cdgen) {isVarInst = true};

            en.IterateThroughScopeLayers(Caret, VisibleMembers);
        }
示例#13
0
文件: test-19.cs 项目: nobled/mono
	public static int Main ()
	{
		I.GetTextFn _ = I.GetText;

	Console.WriteLine ("Value: " + I.GetText);
		X x = new X ();

		Thread thr = new Thread (new ThreadStart (x.Thread_func));

		thr.Start ();
		Console.WriteLine ("Inside main ");
		thr.Join ();

		Console.WriteLine (_("Hello"));

		x.Bar ();

		MemberFilter filter = new MemberFilter (MyFilter);

		Type t = x.GetType ();

		MemberInfo [] mi = t.FindMembers (MemberTypes.Method, BindingFlags.Static | BindingFlags.NonPublic,
						  Type.FilterName, "MyFilter");

		Console.WriteLine ("FindMembers called, mi = " + mi);
		Console.WriteLine ("   Count: " + mi.Length);
		if (!filter (mi [0], "MyFilter"))
			return 1;

		//
		// This test is used to call into a delegate defined in a separate
		// namespace, but which is still not a nested delegate inside a class
		//
		NameSpace.TestDelegate td = new NameSpace.TestDelegate (multiply_by_three);

		if (td (8) != 24)
			return 30;

		//
		// Check the names that were used to define the delegates
		//
		if (td.GetType ().FullName != "NameSpace.TestDelegate")
			return 31;

		if (_.GetType ().FullName != "I+GetTextFn")
			return 32;
		
		Console.WriteLine ("Test passes");

		return 0;
	}
示例#14
0
        public static IEnumerable<INode> EnumAllAvailableMembers(IBlockNode ScopedBlock
			, IStatement ScopedStatement,
			CodeLocation Caret,
			ParseCacheList CodeCache,
			MemberFilter VisibleMembers)
        {
            return EnumAllAvailableMembers(new ResolverContextStack(CodeCache,new ResolverContext
            {
                ScopedBlock = ScopedBlock,
                ScopedStatement = ScopedStatement
            }),
            Caret,
            VisibleMembers);
        }
示例#15
0
		public virtual void IterateThroughScopeLayers(CodeLocation Caret, MemberFilter VisibleMembers = MemberFilter.All)
		{
			if (ctxt.ScopedStatement != null &&
				ScanStatementHierarchy(ctxt.ScopedStatement, Caret, VisibleMembers))
			{
				if (ctxt.ScopedBlock is DMethod &&
					ScanBlock(ctxt.ScopedBlock, Caret, VisibleMembers))
				{
					// Error: Locals are shadowing parameters!
				}
				
				return;
			}

			if(ctxt.ScopedBlock != null && 
			   ScanBlockUpward(ctxt.ScopedBlock, Caret, VisibleMembers))
				return;
			
			// Handle available modules/packages
			var nameStubs = new List<string>();
			if(ctxt.ParseCache != null)
				foreach(var root in ctxt.ParseCache)
				{
					ModulePackage[] packs;
					var mods = PrefilterSubnodes(root, out packs);
					
					if(packs != null){
						foreach(var pack in packs)
						{
							if(nameStubs.Contains(pack.Name))
								continue;
							
							HandleItem(new PackageSymbol(pack, null));
							nameStubs.Add(pack.Name);
						}
					}
					
					if(mods != null)
					{
						HandleItems(mods);
					}
				}

			// On the root level, handle __ctfe variable
			if (CanAddMemberOfType(VisibleMembers, __ctfe) &&
				HandleItem(__ctfe))
				return;
		}
        public ExpressionParser(string expression, Type expressionType, ParameterExpression[] parameters, ParserSettings settings)
        {
            _settings = settings;
            _expressionType = expressionType;

            _parameters = new Dictionary<string, Expression>(settings.SettingsKeyComparer);

            _bindingCase = settings.CaseInsensitive ? BindingFlags.IgnoreCase : BindingFlags.Default;
            _memberFilterCase = settings.CaseInsensitive ? Type.FilterNameIgnoreCase : Type.FilterName;

            AddParameters(parameters);

            _expressionText = expression ?? string.Empty;
            _expressionTextLength = _expressionText.Length;
            SetTextPos(0);
            NextToken();
        }
 protected DataService() {
     Type type = this.GetType();
     AttributeCollection attrs = TypeDescriptor.GetAttributes(type);
     DataAdapterAttribute attr = (DataAdapterAttribute)attrs[typeof(DataAdapterAttribute)];
     if (attr != null) {
         _adapter = Activator.CreateInstance(attr.DataAdapterType);
     }
     _fillMethods = _fillMethodCache[type] as Hashtable;
     if (_fillMethods == null) {
         if (attr != null) {
             string[] methodNames = attr.GetDataMethodNames;
             _fillMethods = Hashtable.Synchronized(new Hashtable(methodNames.Length));
             foreach (string methodName in methodNames) {
                 MethodInfo method = attr.DataAdapterType.GetMethod(methodName, PublicIgnoreCaseBindingFlags);
                 _fillMethods[methodName] = method;
                 if (_defaultFillMethod == null) {
                     _defaultFillMethod = method;
                 }
             }
             if (!String.IsNullOrEmpty(attr.UpdateMethodName)) {
                 MemberFilter filter = new MemberFilter(FilterMethodWithDataTableParameter);
                 MemberInfo[] updateMethods = attr.DataAdapterType.FindMembers(
                     MemberTypes.Method,
                     PublicIgnoreCaseBindingFlags,
                     filter,
                     attr.UpdateMethodName);
                 if (updateMethods.Length != 0) {
                     _updateMethod = (MethodInfo)updateMethods[0];
                 }
             }
         }
         else {
             _fillMethods = Hashtable.Synchronized(new Hashtable());
         }
         _updateMethodCache[type] = _updateMethod;
         _defaultFillMethodCache[type] = _defaultFillMethod;
         _fillMethodCache[type] = _fillMethods;
     }
     else {
         _updateMethod = _updateMethodCache[type] as MethodInfo;
         _defaultFillMethod = _defaultFillMethodCache[type] as MethodInfo;
     }
 }
示例#18
0
        /// <summary>
        /// Gets a singleton method group from the provided type.
        /// 
        /// The provided method group will be unique based upon the methods defined, not based upon the type/name
        /// combination.  In other words calling GetMethodGroup on a base type and a derived type that introduces
        /// no new methods under a given name will result in the same method group for both types.
        /// </summary>
        public static MethodGroup GetMethodGroup(Type type, string name, BindingFlags bindingFlags, MemberFilter filter) {
            ContractUtils.RequiresNotNull(type, "type");
            ContractUtils.RequiresNotNull(name, "name");

            MemberInfo[] mems = type.FindMembers(MemberTypes.Method,
                bindingFlags,
                filter ?? delegate(MemberInfo mem, object filterCritera) {
                    return mem.Name == name;
                },
                null);

            MethodGroup res = null;
            if (mems.Length != 0) {
                MethodInfo[] methods = ArrayUtils.ConvertAll<MemberInfo, MethodInfo>(
                    mems,
                    delegate(MemberInfo x) { return (MethodInfo)x; }
                );
                res = GetMethodGroup(name, methods);
            }
            return res;
        }
示例#19
0
 public static PropertySpec GetPredefinedProperty(TypeSpec t, string name, Location loc, TypeSpec type)
 {
     return(GetPredefinedMember(t, MemberFilter.Property(name, type), false, loc) as PropertySpec);
 }
示例#20
0
 public override MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria) => throw Unexpected;
示例#21
0
 public override MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria)
 {
     
     Debug.Assert(false, "NYI");
     return base.FindMembers(memberType, bindingAttr, filter, filterCriteria);
 }
示例#22
0
文件: iterators.cs 项目: speier/shake
                public override bool Resolve(BlockContext ec)
                {
                    TypeExpression storey_type_expr = new TypeExpression (host.Definition, loc);
                    List<Expression> init = null;
                    if (host.hoisted_this != null) {
                        init = new List<Expression> (host.hoisted_params == null ? 1 : host.HoistedParameters.Count + 1);
                        HoistedThis ht = host.hoisted_this;
                        FieldExpr from = new FieldExpr (ht.Field, loc);
                        from.InstanceExpression = CompilerGeneratedThis.Instance;
                        init.Add (new ElementInitializer (ht.Field.Name, from, loc));
                    }

                    if (host.hoisted_params != null) {
                        if (init == null)
                            init = new List<Expression> (host.HoistedParameters.Count);

                        for (int i = 0; i < host.hoisted_params.Count; ++i) {
                            HoistedParameter hp = (HoistedParameter) host.hoisted_params [i];
                            HoistedParameter hp_cp = (HoistedParameter) host.hoisted_params_copy [i];

                            FieldExpr from = new FieldExpr (hp_cp.Field, loc);
                            from.InstanceExpression = CompilerGeneratedThis.Instance;

                            init.Add (new ElementInitializer (hp.Field.Name, from, loc));
                        }
                    }

                    if (init != null) {
                        new_storey = new NewInitialize (storey_type_expr, null,
                            new CollectionOrObjectInitializers (init, loc), loc);
                    } else {
                        new_storey = new New (storey_type_expr, null, loc);
                    }

                    new_storey = new_storey.Resolve (ec);
                    if (new_storey != null)
                        new_storey = Convert.ImplicitConversionRequired (ec, new_storey, host_method.MemberType, loc);

                    if (TypeManager.int_interlocked_compare_exchange == null) {
                        TypeSpec t = TypeManager.CoreLookupType (ec.Compiler, "System.Threading", "Interlocked", MemberKind.Class, true);
                        if (t != null) {
                            var p = ParametersCompiled.CreateFullyResolved (
                                new[] {
                                    new ParameterData (null, Parameter.Modifier.REF),
                                    new ParameterData (null, Parameter.Modifier.NONE),
                                    new ParameterData (null, Parameter.Modifier.NONE)
                                },
                                new[] {
                                    TypeManager.int32_type, TypeManager.int32_type, TypeManager.int32_type
                                }
                                );
                            var f = new MemberFilter ("CompareExchange", 0, MemberKind.Method, p, TypeManager.int32_type);
                            TypeManager.int_interlocked_compare_exchange = TypeManager.GetPredefinedMethod (t, f, loc);
                        }
                    }

                    ec.CurrentBranching.CurrentUsageVector.Goto ();
                    return true;
                }
示例#23
0
        public static MethodSpec GetConstructor(TypeSpec delType)
        {
            var ctor = MemberCache.FindMember(delType, MemberFilter.Constructor(null), BindingRestriction.DeclaredOnly);

            return((MethodSpec)ctor);
        }
示例#24
0
        //
        // Returns the method specification for a method named `name' defined
        // in type `t' which takes arguments of types `args'
        //
        public static MethodSpec GetPredefinedMethod(TypeSpec t, string name, Location loc, params TypeSpec [] args)
        {
            var pc = ParametersCompiled.CreateFullyResolved(args);

            return(GetPredefinedMethod(t, MemberFilter.Method(name, 0, pc, null), false, loc));
        }
示例#25
0
 public static MethodSpec GetPredefinedMethod(TypeSpec t, MemberFilter filter, bool optional, Location loc)
 {
     return(GetPredefinedMember(t, filter, optional, loc) as MethodSpec);
 }
示例#26
0
        public virtual MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria)
        {
            // Define the work arrays
            MethodInfo[]      m = null;
            ConstructorInfo[] c = null;
            FieldInfo[]       f = null;
            PropertyInfo[]    p = null;
            EventInfo[]       e = null;
            Type[]            t = null;

            int i   = 0;
            int cnt = 0;            // Total Matchs

            // Check the methods
            if ((memberType & MemberTypes.Method) != 0)
            {
                m = GetMethods(bindingAttr);
                if (filter != null)
                {
                    for (i = 0; i < m.Length; i++)
                    {
                        if (!filter(m[i], filterCriteria))
                        {
                            m[i] = null;
                        }
                        else
                        {
                            cnt++;
                        }
                    }
                }
                else
                {
                    cnt += m.Length;
                }
            }

            // Check the constructors
            if ((memberType & MemberTypes.Constructor) != 0)
            {
                c = GetConstructors(bindingAttr);
                if (filter != null)
                {
                    for (i = 0; i < c.Length; i++)
                    {
                        if (!filter(c[i], filterCriteria))
                        {
                            c[i] = null;
                        }
                        else
                        {
                            cnt++;
                        }
                    }
                }
                else
                {
                    cnt += c.Length;
                }
            }

            // Check the fields
            if ((memberType & MemberTypes.Field) != 0)
            {
                f = GetFields(bindingAttr);
                if (filter != null)
                {
                    for (i = 0; i < f.Length; i++)
                    {
                        if (!filter(f[i], filterCriteria))
                        {
                            f[i] = null;
                        }
                        else
                        {
                            cnt++;
                        }
                    }
                }
                else
                {
                    cnt += f.Length;
                }
            }

            // Check the Properties
            if ((memberType & MemberTypes.Property) != 0)
            {
                p = GetProperties(bindingAttr);
                if (filter != null)
                {
                    for (i = 0; i < p.Length; i++)
                    {
                        if (!filter(p[i], filterCriteria))
                        {
                            p[i] = null;
                        }
                        else
                        {
                            cnt++;
                        }
                    }
                }
                else
                {
                    cnt += p.Length;
                }
            }

            // Check the Events
            if ((memberType & MemberTypes.Event) != 0)
            {
                e = GetEvents(bindingAttr);
                if (filter != null)
                {
                    for (i = 0; i < e.Length; i++)
                    {
                        if (!filter(e[i], filterCriteria))
                        {
                            e[i] = null;
                        }
                        else
                        {
                            cnt++;
                        }
                    }
                }
                else
                {
                    cnt += e.Length;
                }
            }

            // Check the Types
            if ((memberType & MemberTypes.NestedType) != 0)
            {
                t = GetNestedTypes(bindingAttr);
                if (filter != null)
                {
                    for (i = 0; i < t.Length; i++)
                    {
                        if (!filter(t[i], filterCriteria))
                        {
                            t[i] = null;
                        }
                        else
                        {
                            cnt++;
                        }
                    }
                }
                else
                {
                    cnt += t.Length;
                }
            }

            // Allocate the Member Info
            MemberInfo[] ret = new MemberInfo[cnt];

            // Copy the Methods
            cnt = 0;
            if (m != null)
            {
                for (i = 0; i < m.Length; i++)
                {
                    if (m[i] != null)
                    {
                        ret[cnt++] = m[i];
                    }
                }
            }

            // Copy the Constructors
            if (c != null)
            {
                for (i = 0; i < c.Length; i++)
                {
                    if (c[i] != null)
                    {
                        ret[cnt++] = c[i];
                    }
                }
            }

            // Copy the Fields
            if (f != null)
            {
                for (i = 0; i < f.Length; i++)
                {
                    if (f[i] != null)
                    {
                        ret[cnt++] = f[i];
                    }
                }
            }

            // Copy the Properties
            if (p != null)
            {
                for (i = 0; i < p.Length; i++)
                {
                    if (p[i] != null)
                    {
                        ret[cnt++] = p[i];
                    }
                }
            }

            // Copy the Events
            if (e != null)
            {
                for (i = 0; i < e.Length; i++)
                {
                    if (e[i] != null)
                    {
                        ret[cnt++] = e[i];
                    }
                }
            }

            // Copy the Types
            if (t != null)
            {
                for (i = 0; i < t.Length; i++)
                {
                    if (t[i] != null)
                    {
                        ret[cnt++] = t[i];
                    }
                }
            }

            return(ret);
        }
示例#27
0
文件: Type.cs 项目: ngraziano/mono
		private static void AddMembers(List<MemberInfo> list, MemberFilter filter, object filterCriteria, MemberInfo[] members)
		{
			foreach (MemberInfo member in members)
			{
				if (filter == null || filter(member, filterCriteria))
				{
					list.Add(member);
				}
			}
		}
示例#28
0
        /// <summary>
        /// Filters a <see cref="ReadOnlyMemberCollection"/> for a given <see cref="MemberFilter"/>.
        /// </summary>
        /// <param name="members">The <see cref="ReadOnlyMemberCollection"/></param>
        /// <param name="filter">The new <see cref="MemberFilter"/> by which to filter.</param>
        /// <returns>The filtered collection.</returns>
        /// <remarks>The new filter parameter will function as an OR parameter.</remarks>
        public static ReadOnlyMemberCollection Filter(this ReadOnlyMemberCollection members, MemberFilter filter)
        {
            var collection = new ReadOnlyMemberCollection(members, members.Auth);

            collection.AddFilter(new[] { filter });
            return(collection);
        }
示例#29
0
        /// <summary>
        /// Gets a singleton method group from the provided type.
        ///
        /// The provided method group will be unique based upon the methods defined, not based upon the type/name
        /// combination.  In other words calling GetMethodGroup on a base type and a derived type that introduces
        /// no new methods under a given name will result in the same method group for both types.
        /// </summary>
        public static MethodGroup GetMethodGroup(Type type, string name, BindingFlags bindingFlags, MemberFilter filter)
        {
            ContractUtils.RequiresNotNull(type, "type");
            ContractUtils.RequiresNotNull(name, "name");

            MemberInfo[] mems = type.FindMembers(MemberTypes.Method,
                                                 bindingFlags,
                                                 filter ?? delegate(MemberInfo mem, object filterCritera) {
                return(mem.Name == name);
            },
                                                 null);

            MethodGroup res = null;

            if (mems.Length != 0)
            {
                MethodInfo[] methods = ArrayUtils.ConvertAll <MemberInfo, MethodInfo>(
                    mems,
                    delegate(MemberInfo x) { return((MethodInfo)x); }
                    );
                res = GetMethodGroup(name, methods);
            }
            return(res);
        }
        public override bool Resolve(BlockContext bc)
        {
            if (bc.CurrentBlock is Linq.QueryBlock)
            {
                bc.Report.Error(1995, loc,
                                "The `await' operator may only be used in a query expression within the first collection expression of the initial `from' clause or within the collection expression of a `join' clause");
                return(false);
            }

            if (!base.Resolve(bc))
            {
                return(false);
            }

            Arguments args = new Arguments(0);

            type = expr.Type;

            //
            // The await expression is of dynamic type
            //
            if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
            {
                result_type = type;
                expr        = new Invocation(new MemberAccess(expr, "GetAwaiter"), args).Resolve(bc);
                return(true);
            }

            //
            // Check whether the expression is awaitable
            //
            Expression ama = new AwaitableMemberAccess(expr).Resolve(bc);

            if (ama == null)
            {
                return(false);
            }

            var errors_printer = new SessionReportPrinter();
            var old            = bc.Report.SetPrinter(errors_printer);

            ama = new Invocation(ama, args).Resolve(bc);
            bc.Report.SetPrinter(old);

            if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression(ama.Type))
            {
                bc.Report.Error(1986, expr.Location,
                                "The `await' operand type `{0}' must have suitable GetAwaiter method",
                                expr.Type.GetSignatureForError());

                return(false);
            }

            var awaiter_type = ama.Type;

            expr = ama;

            //
            // Predefined: bool IsCompleted { get; }
            //
            is_completed = MemberCache.FindMember(awaiter_type, MemberFilter.Property("IsCompleted", bc.Module.Compiler.BuiltinTypes.Bool),
                                                  BindingRestriction.InstanceOnly) as PropertySpec;

            if (is_completed == null || !is_completed.HasGet)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            //
            // Predefined: GetResult ()
            //
            // The method return type is also result type of await expression
            //
            get_result = MemberCache.FindMember(awaiter_type, MemberFilter.Method("GetResult", 0,
                                                                                  ParametersCompiled.EmptyReadOnlyParameters, null),
                                                BindingRestriction.InstanceOnly) as MethodSpec;

            if (get_result == null)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            //
            // Predefined: INotifyCompletion.OnCompleted (System.Action)
            //
            var nc = bc.Module.PredefinedTypes.INotifyCompletion;

            if (nc.Define() && !awaiter_type.ImplementsInterface(nc.TypeSpec, false))
            {
                bc.Report.Error(4027, loc, "The awaiter type `{0}' must implement interface `{1}'",
                                awaiter_type.GetSignatureForError(), nc.GetSignatureForError());
                return(false);
            }

            result_type = get_result.ReturnType;

            return(true);
        }
示例#31
0
 public sealed override MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria) => base.FindMembers(memberType, bindingAttr, filter, filterCriteria);
示例#32
0
 public void FindMembers_Invoke_ReturnsExpected(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria, int expectedLength)
 {
     Assert.Equal(expectedLength, typeof(TypeTests).FindMembers(memberType, bindingAttr, filter, filterCriteria).Length);
 }
示例#33
0
 public IEnumerable<Member> ForBoard(IBoardId board, MemberFilter filter = MemberFilter.Default)
 {
     return _restClient.Request<List<Member>>(new MembersForBoardRequest(board, filter));
 }
示例#34
0
 public static FieldSpec GetPredefinedField(TypeSpec t, string name, Location loc, TypeSpec type)
 {
     return(GetPredefinedMember(t, MemberFilter.Field(name, type), false, loc) as FieldSpec);
 }
示例#35
0
	static MemberSpec GetPredefinedMember (TypeSpec t, MemberFilter filter, bool optional, Location loc)
	{
		var member = MemberCache.FindMember (t, filter, BindingRestriction.DeclaredOnly);

		if (member != null && member.IsAccessible (InternalType.FakeInternalType))
			return member;

		if (optional)
			return member;

		string method_args = null;
		if (filter.Parameters != null)
			method_args = filter.Parameters.GetSignatureForError ();

		RootContext.ToplevelTypes.Compiler.Report.Error (656, loc, "The compiler required member `{0}.{1}{2}' could not be found or is inaccessible",
			TypeManager.CSharpName (t), filter.Name, method_args);

		return null;
	}
示例#36
0
 public static MethodSpec GetPredefinedMethod(TypeSpec t, MemberFilter filter, Location loc)
 {
     return(GetPredefinedMethod(t, filter, false, loc));
 }
示例#37
0
	public static MethodSpec GetPredefinedMethod (TypeSpec t, MemberFilter filter, bool optional, Location loc)
	{
		return GetPredefinedMember (t, filter, optional, loc) as MethodSpec;
	}
示例#38
0
        //
        // Returns the ConstructorInfo for "args"
        //
        public static MethodSpec GetPredefinedConstructor(TypeSpec t, Location loc, params TypeSpec [] args)
        {
            var pc = ParametersCompiled.CreateFullyResolved(args);

            return(GetPredefinedMember(t, MemberFilter.Constructor(pc), false, loc) as MethodSpec);
        }
 public static MethodSpec GetValue(TypeSpec nullableType)
 {
     return((MethodSpec)MemberCache.FindMember(nullableType,
                                               MemberFilter.Method("get_Value", 0, ParametersCompiled.EmptyReadOnlyParameters, null), BindingRestriction.None));
 }
示例#40
0
 public IEnumerable<Member> ForOrganization(IOrganizationId organization, MemberFilter filter = MemberFilter.Default)
 {
     return _restClient.Request<List<Member>>(new MembersForOrganizationRequest(organization, filter));
 }
示例#41
0
 public PredefinedMember(ModuleContainer module, BuiltinTypeSpec type, string name, params TypeSpec[] types)
     : this(module, type, MemberFilter.Method(name, 0, ParametersCompiled.CreateFullyResolved(types), null))
 {
 }
示例#42
0
	public static MethodSpec GetPredefinedMethod (TypeSpec t, MemberFilter filter, Location loc)
	{
		return GetPredefinedMethod (t, filter, false, loc);
	}
示例#43
0
 public PredefinedMember(ModuleContainer module, TypeSpec type, MemberFilter filter)
 {
     this.module         = module;
     this.declaring_type = type;
     this.filter         = filter;
 }
示例#44
0
文件: Type.cs 项目: runefs/Marvin
		public virtual MemberInfo[] FindMembers (MemberTypes memberType, BindingFlags bindingAttr,
							 MemberFilter filter, object filterCriteria)
		{
			MemberInfo[] result;
			ArrayList l = new ArrayList ();

			// Console.WriteLine ("FindMembers for {0} (Type: {1}): {2}",
			// this.FullName, this.GetType().FullName, this.obj_address());
			if ((memberType & MemberTypes.Method) != 0) {
				MethodInfo[] c = GetMethods (bindingAttr);
				if (filter != null) {
					foreach (MemberInfo m in c) {
						if (filter (m, filterCriteria))
							l.Add (m);
					}
				} else {
					l.AddRange (c);
				}
			}
			if ((memberType & MemberTypes.Constructor) != 0) {
				ConstructorInfo[] c = GetConstructors (bindingAttr);
				if (filter != null) {
					foreach (MemberInfo m in c) {
						if (filter (m, filterCriteria))
							l.Add (m);
					}
				} else {
					l.AddRange (c);
				}
			}
			if ((memberType & MemberTypes.Property) != 0) {
				PropertyInfo[] c;
				int count = l.Count;
				Type ptype;
				if (filter != null) {
					ptype = this;
					while ((l.Count == count) && (ptype != null)) {
						c = ptype.GetProperties (bindingAttr);
						foreach (MemberInfo m in c) {
							if (filter (m, filterCriteria))
								l.Add (m);
						}
						ptype = ptype.BaseType;
					}
				} else {
					c = GetProperties (bindingAttr);
					l.AddRange (c);
				}
			}
			if ((memberType & MemberTypes.Event) != 0) {
				EventInfo[] c = GetEvents (bindingAttr);
				if (filter != null) {
					foreach (MemberInfo m in c) {
						if (filter (m, filterCriteria))
							l.Add (m);
					}
				} else {
					l.AddRange (c);
				}
			}
			if ((memberType & MemberTypes.Field) != 0) {
				FieldInfo[] c = GetFields (bindingAttr);
				if (filter != null) {
					foreach (MemberInfo m in c) {
						if (filter (m, filterCriteria))
							l.Add (m);
					}
				} else {
					l.AddRange (c);
				}
			}
			if ((memberType & MemberTypes.NestedType) != 0) {
				Type[] c = GetNestedTypes (bindingAttr);
				if (filter != null) {
					foreach (MemberInfo m in c) {
						if (filter (m, filterCriteria)) {
							l.Add (m);
						}
					}
				} else {
					l.AddRange (c);
				}
			}

			switch (memberType) {
			case MemberTypes.Constructor :
				result = new ConstructorInfo [l.Count];
				break;
			case MemberTypes.Event :
				result = new EventInfo [l.Count];
				break;
			case MemberTypes.Field :
				result = new FieldInfo [l.Count];
				break;
			case MemberTypes.Method :
				result = new MethodInfo [l.Count];
				break;
			case MemberTypes.NestedType :
			case MemberTypes.TypeInfo :
				result = new Type [l.Count];
				break;
			case MemberTypes.Property :
				result = new PropertyInfo [l.Count];
				break;
			default :
				result = new MemberInfo [l.Count];
				break;
			}
			l.CopyTo (result);
			return result;
		}
示例#45
0
        public PredefinedMembers(ModuleContainer module)
        {
            var types  = module.PredefinedTypes;
            var atypes = module.PredefinedAttributes;
            var btypes = module.Compiler.BuiltinTypes;

            ActivatorCreateInstance = new PredefinedMember <MethodSpec> (module, types.Activator,
                                                                         MemberFilter.Method("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null));

            DecimalCtor = new PredefinedMember <MethodSpec> (module, btypes.Decimal,
                                                             MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(
                                                                                          btypes.Int, btypes.Int, btypes.Int, btypes.Bool, btypes.Byte)));

            DecimalCtorInt = new PredefinedMember <MethodSpec> (module, btypes.Decimal,
                                                                MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(btypes.Int)));

            DecimalCtorLong = new PredefinedMember <MethodSpec> (module, btypes.Decimal,
                                                                 MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(btypes.Long)));

            DecimalConstantAttributeCtor = new PredefinedMember <MethodSpec> (module, atypes.DecimalConstant,
                                                                              MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(
                                                                                                           btypes.Byte, btypes.Byte, btypes.UInt, btypes.UInt, btypes.UInt)));

            DefaultMemberAttributeCtor = new PredefinedMember <MethodSpec> (module, atypes.DefaultMember,
                                                                            MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(btypes.String)));

            DelegateCombine = new PredefinedMember <MethodSpec> (module, btypes.Delegate, "Combine", btypes.Delegate, btypes.Delegate);
            DelegateRemove  = new PredefinedMember <MethodSpec> (module, btypes.Delegate, "Remove", btypes.Delegate, btypes.Delegate);

            DelegateEqual = new PredefinedMember <MethodSpec> (module, btypes.Delegate,
                                                               new MemberFilter(Operator.GetMetadataName(Operator.OpType.Equality), 0, MemberKind.Operator, null, btypes.Bool));

            DelegateInequal = new PredefinedMember <MethodSpec> (module, btypes.Delegate,
                                                                 new MemberFilter(Operator.GetMetadataName(Operator.OpType.Inequality), 0, MemberKind.Operator, null, btypes.Bool));

            DynamicAttributeCtor = new PredefinedMember <MethodSpec> (module, atypes.Dynamic,
                                                                      MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(
                                                                                                   ArrayContainer.MakeType(module, btypes.Bool))));

            FieldInfoGetFieldFromHandle = new PredefinedMember <MethodSpec> (module, types.FieldInfo,
                                                                             "GetFieldFromHandle", MemberKind.Method, types.RuntimeFieldHandle);

            FieldInfoGetFieldFromHandle2 = new PredefinedMember <MethodSpec> (module, types.FieldInfo,
                                                                              "GetFieldFromHandle", MemberKind.Method, types.RuntimeFieldHandle, new PredefinedType(btypes.RuntimeTypeHandle));

            FixedBufferAttributeCtor = new PredefinedMember <MethodSpec> (module, atypes.FixedBuffer,
                                                                          MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(btypes.Type, btypes.Int)));

            IDisposableDispose = new PredefinedMember <MethodSpec> (module, btypes.IDisposable, "Dispose", TypeSpec.EmptyTypes);

            IEnumerableGetEnumerator = new PredefinedMember <MethodSpec> (module, btypes.IEnumerable,
                                                                          "GetEnumerator", TypeSpec.EmptyTypes);

            InterlockedCompareExchange = new PredefinedMember <MethodSpec> (module, types.Interlocked,
                                                                            MemberFilter.Method("CompareExchange", 0,
                                                                                                new ParametersImported(
                                                                                                    new[] {
                new ParameterData(null, Parameter.Modifier.REF),
                new ParameterData(null, Parameter.Modifier.NONE),
                new ParameterData(null, Parameter.Modifier.NONE)
            },
                                                                                                    new[] {
                btypes.Int, btypes.Int, btypes.Int
            },
                                                                                                    false),
                                                                                                btypes.Int));

            InterlockedCompareExchange_T = new PredefinedMember <MethodSpec> (module, types.Interlocked,
                                                                              MemberFilter.Method("CompareExchange", 1,
                                                                                                  new ParametersImported(
                                                                                                      new[] {
                new ParameterData(null, Parameter.Modifier.REF),
                new ParameterData(null, Parameter.Modifier.NONE),
                new ParameterData(null, Parameter.Modifier.NONE)
            },
                                                                                                      new[] {
                new TypeParameterSpec(0, null, SpecialConstraint.None, Variance.None, null),
                new TypeParameterSpec(0, null, SpecialConstraint.None, Variance.None, null),
                new TypeParameterSpec(0, null, SpecialConstraint.None, Variance.None, null),
            }, false),
                                                                                                  null));

            MethodInfoGetMethodFromHandle = new PredefinedMember <MethodSpec> (module, types.MethodBase,
                                                                               "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle);

            MethodInfoGetMethodFromHandle2 = new PredefinedMember <MethodSpec> (module, types.MethodBase,
                                                                                "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle, new PredefinedType(btypes.RuntimeTypeHandle));

            MonitorEnter = new PredefinedMember <MethodSpec> (module, types.Monitor, "Enter", btypes.Object);

            MonitorEnter_v4 = new PredefinedMember <MethodSpec> (module, types.Monitor,
                                                                 MemberFilter.Method("Enter", 0,
                                                                                     new ParametersImported(new[] {
                new ParameterData(null, Parameter.Modifier.NONE),
                new ParameterData(null, Parameter.Modifier.REF)
            },
                                                                                                            new[] {
                btypes.Object, btypes.Bool
            }, false), null));

            MonitorExit = new PredefinedMember <MethodSpec> (module, types.Monitor, "Exit", btypes.Object);

            RuntimeCompatibilityWrapNonExceptionThrows = new PredefinedMember <PropertySpec> (module, atypes.RuntimeCompatibility,
                                                                                              MemberFilter.Property("WrapNonExceptionThrows", btypes.Bool));

            RuntimeHelpersInitializeArray = new PredefinedMember <MethodSpec> (module, types.RuntimeHelpers,
                                                                               "InitializeArray", btypes.Array, btypes.RuntimeFieldHandle);

            RuntimeHelpersOffsetToStringData = new PredefinedMember <PropertySpec> (module, types.RuntimeHelpers,
                                                                                    MemberFilter.Property("OffsetToStringData", btypes.Int));

            SecurityActionRequestMinimum = new PredefinedMember <ConstSpec> (module, types.SecurityAction, "RequestMinimum",
                                                                             MemberKind.Field, types.SecurityAction);

            StringEmpty = new PredefinedMember <FieldSpec> (module, btypes.String, MemberFilter.Field("Empty", btypes.String));

            StringEqual = new PredefinedMember <MethodSpec> (module, btypes.String,
                                                             new MemberFilter(Operator.GetMetadataName(Operator.OpType.Equality), 0, MemberKind.Operator, null, btypes.Bool));

            StringInequal = new PredefinedMember <MethodSpec> (module, btypes.String,
                                                               new MemberFilter(Operator.GetMetadataName(Operator.OpType.Inequality), 0, MemberKind.Operator, null, btypes.Bool));

            StructLayoutAttributeCtor = new PredefinedMember <MethodSpec> (module, atypes.StructLayout,
                                                                           MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(btypes.Short)));

            StructLayoutCharSet = new PredefinedMember <FieldSpec> (module, atypes.StructLayout, "CharSet",
                                                                    MemberKind.Field, types.CharSet);

            StructLayoutPack = new PredefinedMember <FieldSpec> (module, atypes.StructLayout,
                                                                 MemberFilter.Field("Pack", btypes.Int));

            StructLayoutSize = new PredefinedMember <FieldSpec> (module, atypes.StructLayout,
                                                                 MemberFilter.Field("Size", btypes.Int));

            TypeGetTypeFromHandle = new PredefinedMember <MethodSpec> (module, btypes.Type, "GetTypeFromHandle", btypes.RuntimeTypeHandle);
        }
示例#46
0
		void CheckMissingAccessor (MemberKind kind, ParametersCompiled parameters, bool get)
		{
			if (IsExplicitImpl) {
				MemberFilter filter;
				if (kind == MemberKind.Indexer)
					filter = new MemberFilter (MemberCache.IndexerNameAlias, 0, kind, parameters, null);
				else
					filter = new MemberFilter (MemberName.Name, 0, kind, null, null);

				var implementing = MemberCache.FindMember (InterfaceType, filter, BindingRestriction.DeclaredOnly) as PropertySpec;

				if (implementing == null)
					return;

				var accessor = get ? implementing.Get : implementing.Set;
				if (accessor != null) {
					Report.SymbolRelatedToPreviousError (accessor);
					Report.Error (551, Location, "Explicit interface implementation `{0}' is missing accessor `{1}'",
						GetSignatureForError (), accessor.GetSignatureForError ());
				}
			}
		}
示例#47
0
文件: nullable.cs 项目: nuxleus/mono
 public static MethodSpec GetConstructor(TypeSpec nullableType)
 {
     return((MethodSpec)MemberCache.FindMember(nullableType,
                                               MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(GetUnderlyingType(nullableType))), BindingRestriction.DeclaredOnly));
 }
示例#48
0
文件: TypeInfo.cs 项目: pars87/Catel
 /// <summary>
 /// Returns a filtered array of <see cref="T:System.Reflection.MemberInfo"/> objects of the specified member type.
 /// </summary>
 /// <returns>
 /// A filtered array of <see cref="T:System.Reflection.MemberInfo"/> objects of the specified member type.
 /// -or- 
 /// An empty array of type <see cref="T:System.Reflection.MemberInfo"/>, if the current <see cref="T:System.Type"/> does not have members of type <paramref name="memberType"/> that match the filter criteria.
 /// </returns>
 /// <param name="memberType">
 /// A MemberTypes object indicating the type of member to search for. 
 /// </param>
 /// <param name="bindingAttr">
 /// A bitmask comprised of one or more <see cref="T:System.Reflection.BindingFlags"/> that specify how the search is conducted.
 /// -or- 
 /// Zero, to return null. 
 /// </param>
 /// <param name="filter">
 /// The delegate that does the comparisons, returning true if the member currently being inspected matches the <paramref name="filterCriteria"/> and false otherwise. You can use the FilterAttribute, FilterName, and FilterNameIgnoreCase delegates supplied by this class. The first uses the fields of FieldAttributes, MethodAttributes, and MethodImplAttributes as search criteria, and the other two delegates use String objects as the search criteria. 
 /// </param>
 /// <param name="filterCriteria">
 /// The search criteria that determines whether a member is returned in the array of MemberInfo objects.
 /// The fields of FieldAttributes, MethodAttributes, and MethodImplAttributes can be used in conjunction with the FilterAttribute delegate supplied by this class. 
 /// </param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="filter"/> is null. 
 /// </exception>
 /// <filterpriority>2</filterpriority>
 public MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria)
 {
     return _type.FindMembers(memberType, bindingAttr, filter, filterCriteria);
 }
示例#49
0
 public override MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria)
 {
     Debug.Assert(false, "NYI");
     return(base.FindMembers(memberType, bindingAttr, filter, filterCriteria));
 }
示例#50
0
文件: Type.cs 项目: ngraziano/mono
		public MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria)
		{
			List<MemberInfo> members = new List<MemberInfo>();
			if ((memberType & MemberTypes.Constructor) != 0)
			{
				AddMembers(members, filter, filterCriteria, GetConstructors(bindingAttr));
			}
			if ((memberType & MemberTypes.Method) != 0)
			{
				AddMembers(members, filter, filterCriteria, GetMethods(bindingAttr));
			}
			if ((memberType & MemberTypes.Field) != 0)
			{
				AddMembers(members, filter, filterCriteria, GetFields(bindingAttr));
			}
			if ((memberType & MemberTypes.Property) != 0)
			{
				AddMembers(members, filter, filterCriteria, GetProperties(bindingAttr));
			}
			if ((memberType & MemberTypes.Event) != 0)
			{
				AddMembers(members, filter, filterCriteria, GetEvents(bindingAttr));
			}
			if ((memberType & MemberTypes.NestedType) != 0)
			{
				AddMembers(members, filter, filterCriteria, GetNestedTypes(bindingAttr));
			}
			return members.ToArray();
		}
示例#51
0
        public override bool Resolve(BlockContext bc)
        {
            if (!base.Resolve(bc))
            {
                return(false);
            }

            Arguments args = new Arguments(0);

            type = expr.Type;

            //
            // The await expression is of dynamic type
            //
            if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
            {
                result_type = type;

                awaiter = ((AsyncTaskStorey)machine_initializer.Storey).AddAwaiter(type, loc);

                expr = new Invocation(new MemberAccess(expr, "GetAwaiter"), args).Resolve(bc);
                return(true);
            }

            //
            // Check whether the expression is awaitable
            //
            Expression ama = new AwaitableMemberAccess(expr).Resolve(bc);

            if (ama == null)
            {
                return(false);
            }

            var errors_printer = new SessionReportPrinter();
            var old            = bc.Report.SetPrinter(errors_printer);

            ama = new Invocation(ama, args).Resolve(bc);
            bc.Report.SetPrinter(old);

            if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression(ama.Type))
            {
                bc.Report.Error(1986, expr.Location,
                                "The `await' operand type `{0}' must have suitable GetAwaiter method",
                                expr.Type.GetSignatureForError());

                return(false);
            }

            var awaiter_type = ama.Type;

            awaiter = ((AsyncTaskStorey)machine_initializer.Storey).AddAwaiter(awaiter_type, loc);

            expr = ama;

            //
            // Predefined: bool IsCompleted { get; }
            //
            is_completed = MemberCache.FindMember(awaiter_type, MemberFilter.Property("IsCompleted", bc.Module.Compiler.BuiltinTypes.Bool),
                                                  BindingRestriction.InstanceOnly) as PropertySpec;

            if (is_completed == null || !is_completed.HasGet)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            //
            // Predefined: OnCompleted (Action)
            //
            if (bc.Module.PredefinedTypes.Action.Define())
            {
                on_completed = MemberCache.FindMember(awaiter_type, MemberFilter.Method("OnCompleted", 0,
                                                                                        ParametersCompiled.CreateFullyResolved(bc.Module.PredefinedTypes.Action.TypeSpec), bc.Module.Compiler.BuiltinTypes.Void),
                                                      BindingRestriction.InstanceOnly) as MethodSpec;

                if (on_completed == null)
                {
                    Error_WrongAwaiterPattern(bc, awaiter_type);
                    return(false);
                }
            }

            //
            // Predefined: GetResult ()
            //
            // The method return type is also result type of await expression
            //
            get_result = MemberCache.FindMember(awaiter_type, MemberFilter.Method("GetResult", 0,
                                                                                  ParametersCompiled.EmptyReadOnlyParameters, null),
                                                BindingRestriction.InstanceOnly) as MethodSpec;

            if (get_result == null)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            result_type = get_result.ReturnType;

            return(true);
        }