public static void MapTypeName(this ISymbolMap symbols, string fullyQualifiedName, string frameworkName, TypeKind kind)
        {
            var proxyName = $"{frameworkName}Proxy";

            switch (kind)
            {
            case TypeKind.Interface:
                var defaultName = frameworkName;

                symbols
                .GetInterfaceProxyName(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(proxyName);
                symbols
                .GetInterfaceDefaultName(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(defaultName);
                symbols
                .GetInterfaceProxyNameSyntaxToken(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(SF.ParseToken(proxyName));
                symbols
                .GetInterfaceDefaultNameSyntaxToken(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(SF.ParseToken(defaultName));
                symbols
                .GetInterfaceProxyNameSyntax(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(SF.ParseName(proxyName));
                symbols
                .GetInterfaceDefaultNameSyntax(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(SF.ParseName(defaultName));

                frameworkName = $"I{frameworkName}";
                break;

            case TypeKind.Class:
                symbols
                .GetAbstractClassProxyName(Arg.Is <ClassType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(proxyName);
                break;
            }

            symbols
            .GetName(Arg.Is <Type>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(frameworkName);
            symbols
            .GetName(Arg.Is <string>(fqn => fqn == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(frameworkName);
            symbols
            .GetNameSyntaxToken(Arg.Is <Type>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(SF.ParseToken(frameworkName));
            symbols
            .GetNameSyntaxToken(Arg.Is <string>(fqn => fqn == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(SF.ParseToken(frameworkName));
            symbols
            .GetNameSyntax(Arg.Is <Type>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(SF.ParseName(frameworkName));
            symbols
            .GetNameSyntax(Arg.Is <string>(fqn => fqn == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(SF.ParseName(frameworkName));
            symbols
            .GetTypeSyntax(Arg.Is <TypeReference>(t => t.FullyQualifiedName == fullyQualifiedName), false)
            .Returns(SF.ParseTypeName(frameworkName));
        }
Beispiel #2
0
        public static void MapTypeName(this ISymbolMap symbols, string fullyQualifiedName, string frameworkName, TypeKind kind)
        {
            if (kind == TypeKind.Interface)
            {
                string proxyName   = $"{frameworkName}Proxy";
                string defaultName = frameworkName;

                symbols
                .GetInterfaceProxyName(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(proxyName);
                symbols
                .GetInterfaceDefaultName(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(defaultName);
                symbols
                .GetInterfaceProxyNameSyntaxToken(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(SF.ParseToken(proxyName));
                symbols
                .GetInterfaceDefaultNameSyntaxToken(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(SF.ParseToken(defaultName));
                symbols
                .GetInterfaceProxyNameSyntax(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(SF.ParseName(proxyName));
                symbols
                .GetInterfaceDefaultNameSyntax(Arg.Is <InterfaceType>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
                .Returns(SF.ParseName(defaultName));

                frameworkName = $"I{frameworkName}";
            }

            symbols
            .GetName(Arg.Is <Type>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(frameworkName);
            symbols
            .GetName(Arg.Is <string>(fqn => fqn == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(frameworkName);
            symbols
            .GetNameSyntaxToken(Arg.Is <Type>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(SF.ParseToken(frameworkName));
            symbols
            .GetNameSyntaxToken(Arg.Is <string>(fqn => fqn == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(SF.ParseToken(frameworkName));
            symbols
            .GetNameSyntax(Arg.Is <Type>(t => t.FullyQualifiedName == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(SF.ParseName(frameworkName));
            symbols
            .GetNameSyntax(Arg.Is <string>(fqn => fqn == fullyQualifiedName), disambiguate: Arg.Any <bool>())
            .Returns(SF.ParseName(frameworkName));
            symbols
            .GetTypeSyntax(Arg.Is <TypeReference>(t => t.FullyQualifiedName == fullyQualifiedName))
            .Returns(SF.ParseTypeName(frameworkName));
        }
Beispiel #3
0
        public static ParameterListSyntax GetParameterListSyntax(this Method method, INamespaceSet namespaces, ISymbolMap symbols)
        {
            method     = method ?? throw new ArgumentNullException(nameof(method));
            namespaces = namespaces ?? throw new ArgumentNullException(nameof(namespaces));
            symbols    = symbols ?? throw new ArgumentNullException(nameof(symbols));

            return(SF.ParameterList(SF.SeparatedList(GetParameters())));

            IEnumerable <ParameterSyntax> GetParameters()
            {
                if (method.Parameters == null)
                {
                    yield break;
                }

                foreach (Parameter parameter in method.Parameters)
                {
                    namespaces.Add(parameter.Type);

                    yield return(SF.Parameter(
                                     SF.List <AttributeListSyntax>(),
                                     SF.TokenList(),
                                     symbols.GetTypeSyntax(parameter.Type),
                                     symbols.GetNameSyntaxToken(parameter),
                                     null
                                     ));
                }
            }
        }
 public static void MapPropertyName(this ISymbolMap symbols, string ownerFullyQualifiedName, string jsiiName, string frameworkName)
 {
     symbols.GetName(
         Arg.Is <Type>(t => t.FullyQualifiedName == ownerFullyQualifiedName),
         Arg.Is <Property>(p => p.Name == jsiiName)
         ).Returns(frameworkName);
     symbols.GetNameSyntaxToken(
         Arg.Is <Type>(t => t.FullyQualifiedName == ownerFullyQualifiedName),
         Arg.Is <Property>(p => p.Name == jsiiName)
         ).Returns(SF.ParseToken(frameworkName));
     symbols.GetNameSyntax(
         Arg.Is <Type>(t => t.FullyQualifiedName == ownerFullyQualifiedName),
         Arg.Is <Property>(p => p.Name == jsiiName)
         ).Returns(SF.ParseName(frameworkName));
 }
        public static void MapAssemblyName(this ISymbolMap symbols, string jsiiName, string frameworkName)
        {
            symbols
            .GetName(Arg.Is <Assembly>(a => a.Name == jsiiName))
            .Returns(frameworkName);
            symbols
            .GetNameSyntaxToken(Arg.Is <Assembly>(a => a.Name == jsiiName))
            .Returns(SF.ParseToken(frameworkName));
            symbols
            .GetNameSyntax(Arg.Is <Assembly>(a => a.Name == jsiiName))
            .Returns(SF.ParseName(frameworkName));

            symbols
            .GetAssemblyName(Arg.Is <string>(n => n == jsiiName))
            .Returns(frameworkName);
        }
 public static void MapParameterName(this ISymbolMap symbols, string jsiiName, string frameworkName)
 {
     symbols.GetName(Arg.Is <Parameter>(t => t.Name == jsiiName)).Returns(frameworkName);
     symbols.GetNameSyntaxToken(Arg.Is <Parameter>(t => t.Name == jsiiName)).Returns(SF.ParseToken(frameworkName));
     symbols.GetNameSyntax(Arg.Is <Parameter>(t => t.Name == jsiiName)).Returns(SF.ParseName(frameworkName));
 }