<commit_before>﻿[CmdletBinding()]
Param(
    [Parameter(Mandatory=$True)]
    [string]$image,
	
    [Parameter(Mandatory=$True)]
    [string]$iosProject,

    [Parameter(Mandatory=$False)]
    [string]$iosResources,

    [Parameter(Mandatory=$False)]
    [bool]$move = $False
)

$script:iosResourcesDirectoryName = $iosResources

function Process-Parameters()
{
    $parametersOk = $True

    if (!(Test-Path $image))
    {
        $parametersOk = $False
        Write-Error "Did not find $image"
    }
    if (!($image.EndsWith(".png")))
    {
        $parametersOk = $False
        Write-Error "$image is not a .png"
    }

    if (!(Test-Path $iosProject))
    {
        $parametersOk = $False
        Write-Error "Did not find $iosProject"
    }
    if (!($iosProject.EndsWith(".csproj")))
    {
        $parametersOk = $False
        Write-Error "$iosProject is not a .csproj"
    }

    if (!([string]::IsNullOrEmpty($iosResourcesFolder)))
    {
        if (!(Test-Path $iosResourcesFolder))
        {
            $parametersOk = $False
            Write-Error "Did not find $iosResourcesFolder"
        }
    }
    elseif (Test-Path $iosProject)
    {
        $iosProjectDirectory = Get-Item (Get-Item $iosProject).DirectoryName
        $script:iosResourcesDirectoryName = $iosProjectDirectory.ToString() + "\Resources"
        Write-Host Hello $script:iosResourcesDirectoryName
    }

    return $parametersOk
}

function Copy-Images()
{
    if ($move)
    {
        Move-Item $image $script:iosResourcesDirectoryName
        Write-Host Moved $image to $script:iosResourcesDirectoryName
    }
    else
    {
        Copy-Item $image $script:iosResourcesDirectoryName
        Write-Host Copied $image to $script:iosResourcesDirectoryName

        $image2 = $image.Substring(0, $image.Length - 4) + "@2x.png"
        if (Test-Path $image2)
        {
            Copy-Item $image2 $script:iosResourcesDirectoryName
            Write-Host Copied $image2 to $script:iosResourcesDirectoryName
        }
        else
        {
            Write-Host "Did not find $image2"
        }

        $image3 = $image.Substring(0, $image.Length - 4) + "@3x.png"
        if (Test-Path $image3)
        {
            Copy-Item $image3 $script:iosResourcesDirectoryName
            Write-Host Copied $image3 to $script:iosResourcesDirectoryName
        }
        else
        {
            Write-Host "Did not find $image3"
        }
    }
}

$parametersOk = Process-Parameters
if ($parametersOk)
{
    Copy-Images
}
else
{
    exit 1
}<commit_msg>Writes to .csproj<commit_after>﻿[CmdletBinding()]
Param(
    [Parameter(Mandatory=$True)]
    [string]$image,
	
    [Parameter(Mandatory=$True)]
    [string]$iosProject,

    [Parameter(Mandatory=$False)]
    [string]$iosResources,

    [Parameter(Mandatory=$False)]
    [bool]$move = $False
)

$script:iosResourcesDirectoryName = $iosResources
$script:image2 = ""
$script:image3 = ""

function Process-Parameters()
{
    $parametersOk = $True

    if (!(Test-Path $image))
    {
        $parametersOk = $False
        Write-Error "Did not find $image"
    }
    if (!($image.EndsWith(".png")))
    {
        $parametersOk = $False
        Write-Error "$image is not a .png"
    }

    if (!(Test-Path $iosProject))
    {
        $parametersOk = $False
        Write-Error "Did not find $iosProject"
    }
    if (!($iosProject.EndsWith(".csproj")))
    {
        $parametersOk = $False
        Write-Error "$iosProject is not a .csproj"
    }

    if (!([string]::IsNullOrEmpty($iosResourcesFolder)))
    {
        if (!(Test-Path $iosResourcesFolder))
        {
            $parametersOk = $False
            Write-Error "Did not find $iosResourcesFolder"
        }
    }
    elseif (Test-Path $iosProject)
    {
        $iosProjectDirectory = Get-Item (Get-Item $iosProject).DirectoryName
        $script:iosResourcesDirectoryName = $iosProjectDirectory.ToString() + "\Resources"
    }

    return $parametersOk
}

function Copy-Images()
{
    if ($move)
    {
        Move-Item $image $script:iosResourcesDirectoryName
        Write-Host Moved $image to $script:iosResourcesDirectoryName
    }
    else
    {
        Copy-Item $image $script:iosResourcesDirectoryName
        Write-Host Copied $image to $script:iosResourcesDirectoryName

        $script:image2 = $image.Substring(0, $image.Length - 4) + "@2x.png"
        if (Test-Path $script:image2)
        {
            Copy-Item $script:image2 $script:iosResourcesDirectoryName
            Write-Host Copied $script:image2 to $script:iosResourcesDirectoryName
        }
        else
        {
            Write-Host "Did not find $script:image2"
        }

        $script:image3 = $image.Substring(0, $image.Length - 4) + "@3x.png"
        if (Test-Path $script:image3)
        {
            Copy-Item $script:image3 $script:iosResourcesDirectoryName
            Write-Host Copied $script:image3 to $script:iosResourcesDirectoryName
        }
        else
        {
            Write-Host "Did not find $image3"
        }
    }
}

function Add-ImagesToProject()
{
    $projectXml = [xml](Get-Content $iosProject)

    $imageFile = Get-Item $image
    $filenameIndex = $imageFile.FullName.LastIndexOf("\") + 1
    $filename = "Resources\" + $imageFile.FullName.Substring($filenameIndex)
    if (Test-Path $script:image2)
    {
        $filename2 = "Resources\" + (Get-Item $script:image2).FullName.Substring($filenameIndex)
    }
    if (Test-Path $script:image3)
    {
        $filename3 = "Resources\" + (Get-Item $script:image3).FullName.Substring($filenameIndex)
    }

    $xPath = [string]::Format("//a:BundleResource[@Include='{0}']", $filename)

    $xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
    $itemGroup = $projectXml.CreateElement("ItemGroup", $xmlns);
    $projectXml.Project.AppendChild($itemGroup);

    $bundleResource = $projectXml.CreateElement("BundleResource", $xmlns);
    $bundleResource.SetAttribute("Include", $filename);
    $itemGroup.AppendChild($bundleResource)

    if (Test-Path $script:image2)
    {
        $bundleResource2 = $projectXml.CreateElement("BundleResource", $xmlns);
        $bundleResource2.SetAttribute("Include", $filename2);
        $itemGroup.AppendChild($bundleResource2)
    }

    if (Test-Path $script:image3)
    {
        $bundleResource3 = $projectXml.CreateElement("BundleResource", $xmlns);
        $bundleResource3.SetAttribute("Include", $filename3);
        $itemGroup.AppendChild($bundleResource3)
    }

    $projectXml.Save($iosProject)
}

$parametersOk = Process-Parameters
if ($parametersOk)
{
    Copy-Images
    Add-ImagesToProject
}
else
{
    exit 1
}
{'fraction_non_alphanumeric': 0.13029070643169152, 'fraction_numerical': 0.008736255460159662, 'mean_word_length': 2.626433642818132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1333707', 'n_tokens_mistral': 2040, 'n_tokens_neox': 2002, 'n_words': 378}