Beispiel #1
0
        private static TypeSymbol DelegateReturnType(NamedTypeSymbol delegateType, out RefKind refKind)
        {
            NamedTypeSymbol d = delegateType.GetDelegateType();

            if ((object)d == null || (object)d.DelegateInvokeMethod == null)
            {
                refKind = Microsoft.CodeAnalysis.RefKind.None;
                return(null);
            }
            refKind = d.DelegateInvokeMethod.RefKind;
            return(d.DelegateInvokeMethod.ReturnType);
        }
Beispiel #2
0
        private bool DelegateNeedsReturn(NamedTypeSymbol delegateType)
        {
            NamedTypeSymbol d = delegateType.GetDelegateType();

            if ((object)d == null || (object)d.DelegateInvokeMethod == null || d.DelegateInvokeMethod.ReturnsVoid)
            {
                return(false);
            }

            if (IsAsync && this.binder.Compilation.GetWellKnownType(WellKnownType.System_Threading_Tasks_Task) == d.DelegateInvokeMethod.ReturnType)
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        private static MethodSymbol GetCacheKey(NamedTypeSymbol delegateType)
        {
            delegateType = delegateType.GetDelegateType();

            if (delegateType != null)
            {
                var invoke = delegateType.DelegateInvokeMethod;
                if (invoke != null)
                {
                    return(invoke);
                }
            }

            // delegateType or DelegateInvokeMethod can be null in cases of malformed delegates
            // in such case we would want something trivial with no parameters, like a fake static ctor
            return(new SynthesizedStaticConstructor(delegateType));
        }
Beispiel #4
0
        private static TypeSymbol DelegateReturnType(NamedTypeSymbol delegateType)
        {
            NamedTypeSymbol d = delegateType.GetDelegateType();

            return(((object)d == null || (object)d.DelegateInvokeMethod == null) ? null : d.DelegateInvokeMethod.ReturnType);
        }
Beispiel #5
0
        private static ImmutableArray <ParameterSymbol> DelegateParameters(NamedTypeSymbol delegateType)
        {
            NamedTypeSymbol d = delegateType.GetDelegateType();

            return(((object)d == null || (object)d.DelegateInvokeMethod == null) ? ImmutableArray <ParameterSymbol> .Empty : d.DelegateInvokeMethod.Parameters);
        }
Beispiel #6
0
 private static MethodSymbol DelegateInvokeMethod(NamedTypeSymbol delegateType)
 {
     return(delegateType.GetDelegateType()?.DelegateInvokeMethod);
 }