Example #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());
        }
Example #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()
            });
        }
Example #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
            });
        }