Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,4 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/
*-claude*/
40 changes: 40 additions & 0 deletions src/TextCopy/ClipboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ public static partial class ClipboardService
return getFunc();
}

/// <summary>
/// Retrieves text data from the Clipboard and splits it into lines.
/// </summary>
public static async Task<string[]?> GetLinesAsync(Cancellation cancellation = default)
{
var text = await GetTextAsync(cancellation);
if (text == null)
return null;
return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
}

/// <summary>
/// Retrieves text data from the Clipboard and splits it into lines.
/// </summary>
public static string[]? GetLines()
{
var text = GetText();
if (text == null)
return null;
return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
}

static Func<string, Cancellation, Task> setAsyncAction;
static Action<string> setAction;

Expand Down Expand Up @@ -60,4 +82,22 @@ public static void SetText(string text)
{
setAction(text);
}

/// <summary>
/// Clears the Clipboard and then adds lines of text data to it.
/// </summary>
public static Task SetLinesAsync(string[] lines, Cancellation cancellation = default)
{

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method should validate that the lines parameter is not null to prevent a NullReferenceException when calling string.Join().

Suggested change
{
{
if (lines == null)
throw new ArgumentNullException(nameof(lines));

Copilot uses AI. Check for mistakes.
var text = string.Join(Environment.NewLine, lines);
return SetTextAsync(text, cancellation);
}

/// <summary>
/// Clears the Clipboard and then adds lines of text data to it.
/// </summary>
public static void SetLines(string[] lines)
{

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method should validate that the lines parameter is not null to prevent a NullReferenceException when calling string.Join().

Suggested change
{
{
if (lines == null)
throw new ArgumentNullException(nameof(lines));

Copilot uses AI. Check for mistakes.
var text = string.Join(Environment.NewLine, lines);
SetText(text);
}
}
12 changes: 8 additions & 4 deletions src/build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
msbuild.exe src/TextCopy.sln /t:restore /p:Configuration=Release -verbosity:quiet
dotnet restore src/TextCopy/TextCopy.csproj --verbosity quiet

msbuild.exe src/TextCopy.sln /t:build /p:Configuration=Release -verbosity:quiet
dotnet build src/TextCopy/TextCopy.csproj --configuration Release --no-restore --verbosity quiet

msbuild.exe src/TextCopy.sln /t:pack /p:Configuration=Release -verbosity:quiet
dotnet pack src/TextCopy/TextCopy.csproj --configuration Release --no-restore --verbosity quiet

dotnet test src --configuration Release --no-build --no-restore --nologo
dotnet restore src/Tests/Tests.csproj --verbosity quiet

dotnet build src/Tests/Tests.csproj --configuration Release --no-restore --verbosity quiet

dotnet test src/Tests/Tests.csproj --configuration Release --no-build --no-restore --nologo