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)); }
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 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)); }