Skip to content

Frends.JSON.Query: fix compliance findings (net8, static class, CancellationToken, error handling) - #40

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

Frends.JSON.Query: fix compliance findings (net8, static class, CancellationToken, error handling)#40
MichalFrends1 with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-compliance-findings-frends-json-query

Conversation

Copilot AI commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Resolves five task-analyzer findings (FT0004, FT0007, FT0011, FT0015 ×2) plus csproj compliance gaps in Frends.JSON.Query. Bumps target framework to net8 and version to 1.3.0.

csproj

  • Frends.JSON.Query.csproj: net6.0net8.0, version 1.2.01.3.0
  • Frends.JSON.Query.UnitTests.csproj: net6.0net8.0, added <PackageProjectUrl> and <Product>Frends</Product> (the UnitTests suffix is not matched by the *.Test*.csproj exclude pattern)

Definitions

  • Options: added ThrowErrorOnFailure (bool, default true) and ErrorMessageOnFailure (string, default "") — FT0015
  • Error (new): Message + AdditionalInfo (Exception)
  • Result: added Error property; added internal constructor for the failure path — FT0011

Task class (Query.cs)

  • JSON made static — FT0004
  • Query gains a CancellationToken parameter — FT0007
  • Method body wrapped in try/catch following the standard ErrorHandler pattern:
    • OperationCanceledException is always rethrown
    • Other exceptions: thrown (wrapped) when ThrowErrorOnFailure = true (default, preserves existing behaviour); returned as Result { Success=false, Error=… } when false
// New signature
public static Result Query(
    [PropertyTab] Input input,
    [PropertyTab] Options options,
    CancellationToken cancellationToken)

// Non-throwing path
var options = new Options { ThrowErrorOnFailure = false };
var result = JSON.Query(input, options, cancellationToken);
// result.Success == false, result.Error.Message populated

Tests

  • Existing calls updated with CancellationToken.None
  • QueryShouldThrowIfOptionSetAndFilterMatchesNothing updated to assert Exception (error handler wraps the original JsonException)
  • Added QueryShouldReturnErrorResultWhenThrowErrorOnFailureIsFalse

…lationToken, error handling, csproj properties
Copilot AI changed the title [WIP] Fix compliance findings in Frends.JSON.Query Frends.JSON.Query: fix compliance findings (net8, static class, CancellationToken, error handling) Jul 31, 2026
Copilot AI requested a review from MichalFrends1 July 31, 2026 09:44
Comment thread Frends.JSON.Query/Frends.JSON.Query/Query.cs
Comment on lines +121 to +140
[TestMethod]
public void QueryShouldReturnErrorResultWhenThrowErrorOnFailureIsFalse()
{
var input = new Input()
{
Json = jsonString,
Query = "$..Products[?(@.Price >= 1000)].Name"
};

var options = new Options()
{
ErrorWhenNotMatched = true,
ThrowErrorOnFailure = false,
};

var result = JSON.Query(input, options, CancellationToken.None);
Assert.IsFalse(result.Success);
Assert.IsNotNull(result.Error);
Assert.IsFalse(string.IsNullOrEmpty(result.Error.Message));
Assert.IsNotNull(result.Error.AdditionalInfo);

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 AI requested a review from MichalFrends1 August 3, 2026 08:32
@MichalFrends1
MichalFrends1 marked this pull request as ready for review August 3, 2026 09:26
@@ -0,0 +1,49 @@
using Frends.JSON.Query.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.

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.

Done — ErrorHandlerTests.cs now uses NUnit ([TestFixture]/[Test]/Assert.That). Added NUnit 4.3.2 and NUnit3TestAdapter 5.0.0 packages to the test csproj.

Comment thread Frends.JSON.Query/CHANGELOG.md Outdated

## [1.3.0] - 2026-07-31
### Changed
- The task class is now properly declared as static, as required by 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, 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.

Removed that line from the CHANGELOG.

@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 resolve review comments

…GELOG

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