Esempio n. 1
0
        public void VerifyThatAllWrapperClassesArePresent()
        {
            var wrapperTypes = typeof(ISyntaxWrapper <>).Assembly.GetTypes()
                               .Where(t => t.GetTypeInfo().ImplementedInterfaces.Any(i => i.IsGenericType && (i.GetGenericTypeDefinition() == typeof(ISyntaxWrapper <>))));

            foreach (var wrapperType in wrapperTypes)
            {
                var wrappedType = WrapperHelper.GetWrappedType(wrapperType);
                Assert.NotNull(wrapperType);
            }
        }
Esempio n. 2
0
        private static SyntaxNode TransformGenericNameToTuple(SemanticModel semanticModel, GenericNameSyntax genericName)
        {
            var implementationType = typeof(SeparatedSyntaxListWrapper <> .AutoWrapSeparatedSyntaxList <>).MakeGenericType(typeof(TupleElementSyntaxWrapper), WrapperHelper.GetWrappedType(typeof(TupleElementSyntaxWrapper)));
            var tupleElements      = (SeparatedSyntaxListWrapper <TupleElementSyntaxWrapper>)Activator.CreateInstance(implementationType);

            foreach (var typeArgument in genericName.TypeArgumentList.Arguments)
            {
                if (IsValueTuple(semanticModel, typeArgument))
                {
                    var tupleTypeSyntax = (TypeSyntax)GetReplacementNode(semanticModel, typeArgument);
                    tupleElements = tupleElements.Add(SyntaxFactoryEx.TupleElement(tupleTypeSyntax));
                }
                else
                {
                    tupleElements = tupleElements.Add(SyntaxFactoryEx.TupleElement(typeArgument));
                }
            }

            return(SyntaxFactoryEx.TupleType(tupleElements));
        }