Пример #1
0
        /// <summary>
        /// Trys to add a type declaration node to the extract depending on whether it has
        /// the <see cref="ScriptObjectAttribute"/>
        /// </summary>
        /// <param name="node">The type declaration node</param>
        private void TryAddTypeDeclaration(TypeDeclarationSyntax node)
        {
            INamedTypeSymbol namedType = Compilation.GetSemanticModel(node.SyntaxTree).GetDeclaredSymbol(node);

            RoslynNamedType namedTypeResult = RoslynType.CreateNamedType(
                namedType,
                new ParseContext(Compilation, new SourceCommentsDocumentationProvider(), _options)
                );

            _visitor.Visit(namedTypeResult);
        }
Пример #2
0
 public static void VisitType(SyntaxNode node)
 {
     if (_instance == null)
     {
         _instance = new TypeVisitor();
     }
     _instance.Visit(node);
 }
Пример #3
0
        public void TypeVisitor_ArgumentChecks()
        {
            var tv = new TypeVisitor();

            AssertEx.ThrowsException <ArgumentNullException>(() => tv.Visit(type: null), ex => Assert.AreEqual("type", ex.ParamName));

            var actv = new ArgumentChecksTypeVisitor();

            actv.RunTests();
        }
Пример #4
0
        public void TypeVisitor_RoundtripTypes()
        {
            var tv = new TypeVisitor();

            foreach (var t in new[] {
                typeof(int),
                typeof(int[]), typeof(int[][]), typeof(int[, ]), typeof(int).MakeArrayType(1),
                typeof(Func <int>), typeof(Func <Func <int> >), typeof(Func <>), typeof(Func <>).GetGenericArguments()[0],
                typeof(int *), typeof(int **),
                typeof(int).MakeByRefType(),
                new { a = 42 }.GetType(),
            })
            {
                Assert.AreSame(tv.Visit(t), t);
            }
        }
Пример #5
0
        public void VisitCorrectlyTransformsParameterExpression()
        {
            IStructureService service = Substitute.For <IStructureService>();

            service.TranslateType(typeof(ClassA)).Returns(typeof(ClassB));
            TypeVisitor visitor = new TypeVisitor(service)
            {
                TypeVerifiers = new ITypeVerifier[0]
            };

            Expression input    = Expression.Parameter(typeof(ClassA));
            Expression expected = Expression.Parameter(typeof(ClassB));

            Expression actual = visitor.Visit(input);

            AssertAreEqualExpressions(expected, actual);
        }
Пример #6
0
        public override Func <Context, ITerm> VisitAbs([NotNull] TaplParser.AbsContext context)
        {
            var boundVar = context.VAR().GetText();
            var body     = Visit(context.term());
            var info     = context.GetFileInfo();

            ITerm result(Context c) => new Abs(info, body(c.AddName(boundVar)), boundVar, _typeVisitor.Visit(context.type()));

            return(result);
        }