Skip to content

Fix Frends.JSON.QuerySingle compliance findings: net8, static class, CancellationToken, error handling - #43

Open
MichalFrends1 with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-compliance-findings-frends-json-querysingle
Open

Fix Frends.JSON.QuerySingle compliance findings: net8, static class, CancellationToken, error handling#43
MichalFrends1 with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-compliance-findings-frends-json-querysingle

Conversation

Copilot AI commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Resolves 5 task analyzer findings (FT0004, FT0007, FT0011, FT0015×2) plus framework and project metadata requirements for Frends.JSON.QuerySingle.

Changes

Frends.JSON.QuerySingle.csproj

  • Target framework: net6.0net8.0
  • Version bump: 1.3.01.4.0

QuerySingle.cs

  • JSON class made static (FT0004)
  • CancellationToken added as required parameter (FT0007)
  • Logic wrapped in try/catch delegating to ErrorHandler.Handle(options)

Definitions/Options.cs (FT0015)

  • Added ThrowErrorOnFailure (bool, default true)
  • Added ErrorMessageOnFailure (string, default "")

Definitions/Result.cs (FT0011)

  • Added Error property of new Error class (Message, AdditionalInfo)

Helpers/ErrorHandler.cs (new)

  • Standard Frends error handler: rethrows on cancellation, throws wrapped exception or returns failed Result based on ThrowErrorOnFailure

Frends.JSON.QuerySingle.UnitTests.csproj

  • Target framework: net6.0net8.0

Tests

  • Existing tests updated for new CancellationToken parameter and Exception (vs JsonException) throw type
  • New ErrorHandlerTests.cs covering throw-on-failure, return-failed-result, and custom error message paths
// New signature
var result = JSON.QuerySingle(input, new Options { ThrowErrorOnFailure = false }, CancellationToken.None);
// On error: result.Success == false, result.Error.Message contains details

// Or throw on failure (default)
var result = JSON.QuerySingle(input, new Options { ErrorMessageOnFailure = "My error" }, CancellationToken.None);
// Throws Exception("My error", innerEx) on failure

Co-authored-by: MichalFrends1 <167774394+MichalFrends1@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compliance findings in Frends.JSON.QuerySingle Fix Frends.JSON.QuerySingle compliance findings: net8, static class, CancellationToken, error handling Aug 5, 2026
Copilot AI requested a review from MichalFrends1 August 5, 2026 08:53
Co-authored-by: MichalFrends1 <167774394+MichalFrends1@users.noreply.github.com>
@MichalFrends1
MichalFrends1 marked this pull request as ready for review August 5, 2026 10:00
Comment thread Frends.JSON.QuerySingle/CHANGELOG.md Outdated
## [1.4.0] - 2026-08-05
### Updated
- Upgraded target framework from .NET 6 to .NET 8.
- Made the task class static to comply with Frends task standards.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this note, it is not important for a user

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — removed that line from the CHANGELOG entry.

@@ -0,0 +1,54 @@
using Frends.JSON.QuerySingle.Definitions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lets use nunit for new tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Converted ErrorHandlerTests.cs to NUnit ([TestFixture], [Test], Assert.That style) and added the NUnit + NUnit3TestAdapter packages to the test project.

@MatteoDelOmbra MatteoDelOmbra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot check review comments and resolve them properly

…o NUnit

Co-authored-by: MatteoDelOmbra <44415151+MatteoDelOmbra@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants