Ejemplo n.º 1
0
        // Private Methods 

        private static ConstraintInfo Convert2(TypeParameterConstraintSyntax src, LangParseContext context)
        {
            if (src is ConstructorConstraintSyntax)
            {
                return new ConstraintInfo
                       {
                           Kind = ConstraintKind.ParameterlessConstructor
                       }
            }
            ;
            throw new NotSupportedException(src.GetType().ToString());
        }
Ejemplo n.º 2
0
        private static TypeParameterConstraintInfo ConvertTypeParameterConstraints(
            TypeParameterConstraintClauseSyntax x, LangParseContext context)
        {
            var info = context.RoslynModel.GetTypeInfo(x.Name);

            if (info.Type == null)
            {
                throw new NullReferenceException("info.Type");
            }
            var ti = context.Roslyn_ResolveType(info.Type);

            return(new TypeParameterConstraintInfo
            {
                Type = ti,
                Constr = x.Constraints.Select(a => Convert2(a, context)).ToArray()
            });
        }
Ejemplo n.º 3
0
        // Public Methods 

        public static MethodHeaderInfo Get(LangParseContext context, MethodDeclarationSyntax node)
        {
            var methodSymbol = (IMethodSymbol)context.RoslynModel.GetDeclaredSymbol(node);

            var methodInfo = context.Roslyn_ResolveMethod(methodSymbol) as MethodInfo;

            if (methodInfo == null)
            {
                throw new NotSupportedException();
            }

            var tmp = node.ConstraintClauses
                      .Select(a => ConvertTypeParameterConstraints(a, context))
                      .ToArray();

            return(new MethodHeaderInfo
            {
                MethodInfo = methodInfo,
                TypeParameterConstraints = tmp
            });
        }