-
-
Notifications
You must be signed in to change notification settings - Fork 158
Merge master v5.2.0 into openapi #1273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…as not applied when determining total resource count via inverse relationship
Simplify assertions (ShouldContainKey already checks for null)
Fixed: incorrect meta:total on secondary endpoint with filter
… of a string value. This effectively moves the type resolving/conversion logic from the EF query production phase to the filter parsing phase. By providing a richer QueryLayer model, it becomes easier to implement non-relational and non-EF Core-based repositories. And it enables to produce better errors earlier. Note we still need to wrap nullable values (see WhereClauseBuilder.ResolveCommonType), due to https://bradwilson.typepad.com/blog/2008/07/creating-nullab.html.
…ibute, so this can never fail)
…any specific record
| Method | Mean | Error | StdDev | Ratio | Gen0 | Allocated | Alloc Ratio | |---------------- |---------:|----------:|----------:|------:|-------:|----------:|------------:| | TrackChanges | 3.741 us | 0.0122 us | 0.0114 us | 1.00 | 0.0229 | 6.41 KB | 1.00 | | NewTrackChanges | 1.359 us | 0.0070 us | 0.0066 us | 0.36 | 0.0095 | 2.62 KB | 0.41 | using BenchmarkDotNet.Attributes; using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.Middleware; using JsonApiDotNetCore.Resources; using JsonApiDotNetCore.Resources.Annotations; using Microsoft.Extensions.Logging.Abstractions; namespace Benchmarks.ChangeTracking; // ReSharper disable once ClassCanBeSealed.Global [MarkdownExporter] [MemoryDiagnoser] public class ChangeTrackerBenchmarks { private readonly JsonApiRequest _request; private readonly TargetedFields _targetedFields; public ChangeTrackerBenchmarks() { IJsonApiOptions options = new JsonApiOptions(); IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<ExampleResource, long>().Build(); ResourceType resourceType = resourceGraph.GetResourceType<ExampleResource>(); _request = new JsonApiRequest { PrimaryResourceType = resourceType, IsCollection = true }; _targetedFields = new TargetedFields(); foreach (AttrAttribute attribute in resourceType.Attributes) { _targetedFields.Attributes.Add(attribute); } } [Benchmark(Baseline = true)] public void TrackChanges() { var changeTracker = new ResourceChangeTracker<ExampleResource>(_request, _targetedFields); var resource = new ExampleResource { Id = 1, Attr1 = "some", Attr2 = "more", Attr3 = "other", Attr4 = false, Attr5 = 123, Attr6 = default, Attr7 = default, Attr8 = default, Attr9 = DayOfWeek.Sunday }; changeTracker.SetInitiallyStoredAttributeValues(resource); resource = new ExampleResource { Id = 1, Attr1 = "new", Attr2 = "change", Attr3 = "this", Attr4 = true, Attr5 = 456, Attr6 = default, Attr7 = default, Attr8 = default, Attr9 = DayOfWeek.Saturday }; changeTracker.SetFinallyStoredAttributeValues(resource); changeTracker.HasImplicitChanges(); } [Benchmark] public void NewTrackChanges() { var changeTracker = new NewResourceChangeTracker<ExampleResource>(_request, _targetedFields); var resource = new ExampleResource { Id = 1, Attr1 = "some", Attr2 = "more", Attr3 = "other", Attr4 = false, Attr5 = 123, Attr6 = default, Attr7 = default, Attr8 = default, Attr9 = DayOfWeek.Sunday }; changeTracker.SetInitiallyStoredAttributeValues(resource); resource = new ExampleResource { Id = 1, Attr1 = "new", Attr2 = "change", Attr3 = "this", Attr4 = true, Attr5 = 456, Attr6 = default, Attr7 = default, Attr8 = default, Attr9 = DayOfWeek.Saturday }; changeTracker.SetFinallyStoredAttributeValues(resource); changeTracker.HasImplicitChanges(); } private sealed class ExampleResource : Identifiable<long> { [Attr] public string? Attr1 { get; set; } [Attr] public string? Attr2 { get; set; } [Attr] public string? Attr3 { get; set; } [Attr] public bool Attr4 { get; set; } [Attr] public int Attr5 { get; set; } [Attr] public DateTime Attr6 { get; set; } [Attr] public DateTimeOffset Attr7 { get; set; } [Attr] public TimeSpan Attr8 { get; set; } [Attr] public DayOfWeek Attr9 { get; set; } } }
Caused by an unintentional breaking change in .NET SDK v7.0.200, which the latest AppVeyor image uses
…n request path ended with a slash. For example: /workItems/ => /workItems//1
Before: Expected element.GetInt32() to be 25, but found 2 (difference of -23). After: Expected responseDocument.Meta to be 25, but found 2 (difference of -23).
Query tweaks
Fix namespace imports in controller source generator
…e service is used
…, demonstrating how to implement a custom read-only resource service and resource repository, which compiles the produced LINQ query and executes it against the dataset.
…tic expression value; fix potential NullReferenceException; use culture-insensitive conversion when no string specified
Update examples
Harden Attr/Relationship attributes against invalid input
1. Owned entity properties are not retrieved when using sparse fieldsets (because they are modeled as navigations in EF Core, instead of scalar properties) 2. When producing a LINQ query that includes an owned entity, EF Core produces an error, indicating that the query must be marked as non-tracked. Due to potential performance impact, a virtual method is provided that enables tweaking the behavior.
Fixes for EF Core owned entities
Codecov Report
@@ Coverage Diff @@
## openapi #1273 +/- ##
===========================================
+ Coverage 92.34% 92.61% +0.26%
===========================================
Files 304 316 +12
Lines 8875 9313 +438
===========================================
+ Hits 8196 8625 +429
- Misses 679 688 +9
|
bkoelman
commented
May 12, 2023
src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs
Show resolved
Hide resolved
maurei
approved these changes
May 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR merges the latest master branch (v5.2.0) into the openapi branch.
Commits to review (the rest originates from merge):
QUALITY CHECKLIST