コード例 #1
0
        public void VerifyThatWrapperClassIsPresent(Type wrapperType)
        {
            var wrappedTypeName = $"Microsoft.CodeAnalysis.CSharp.Syntax.{wrapperType.Name.Substring(0, wrapperType.Name.Length - "Wrapper".Length)}";

            if (typeof(CSharpSyntaxNode).Assembly.GetType(wrappedTypeName) is { } expected)
            {
                var wrappedType = SyntaxWrapperHelper.GetWrappedType(wrapperType);
                Assert.Same(expected, wrappedType);
            }
コード例 #2
0
        private static SyntaxNode TransformGenericNameToTuple(SemanticModel semanticModel, GenericNameSyntax genericName)
        {
            var implementationType = typeof(SeparatedSyntaxListWrapper <> .AutoWrapSeparatedSyntaxList <>).MakeGenericType(typeof(TupleElementSyntaxWrapper), SyntaxWrapperHelper.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));
        }