var propertiesWithCollectionTypes =
	new List<(IPropertySymbol Symbol, PropertyDeclarationSyntax Syntax)>();

foreach (var item in typeNode.Members)
{
    if (item is PropertyDeclarationSyntax pds)
    {
        var symbol = context.Compilation
            .GetSemanticModel(pds.SyntaxTree)
            .GetDeclaredSymbol(pds);
        var property = (symbol as IPropertySymbol);
        var propertyType = property.Type as INamedTypeSymbol;

        if (propertyType.IsGenericType)
        {
            if (property.IsAtleastOneTypeArgumentCustomType())
	    {
    		codeBuilder.AppendLine($"\t\t\t\t\t{property.Name} = entity.{property.Name}.ToDto(),");
    		propertiesWithCollectionTypes.Add((property, pds));
	    }
	    else
    		codeBuilder.AppendLine($"\t\t\t\t\t{property.Name} = entity.{property.Name},");
        }
        else
        {
            // non generic properties
        }
    }
}
...
internal static bool IsAtleastOneTypeArgumentCustomType(
    this IPropertySymbol property)
{
    var typeArgs = (property.Type as INamedTypeSymbol)!.TypeArguments;

    foreach (var type in typeArgs)
    {
        var isCustom = property.IsPropertyTypeCustom(type);

        if (isCustom)
            return true;
    }

    return false;
}

internal static bool IsPropertyTypeCustom(this IPropertySymbol property, 
            ITypeSymbol type) => 
            type.ToDisplayString().StartsWith(
                property.ContainingNamespace.ToDisplayString());