Skip to content
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

OCC-245: Upgrade to latest OC preview to test System.Text.Json #454

Merged
merged 128 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 122 commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
6175523
Fix "MD001: heading-increment" and "MD009: no-trailing-spaces".
sarahelsaig May 16, 2024
e019969
Update package versions and use single variable for OC versions.
sarahelsaig May 22, 2024
cd19878
Merge remote-tracking branch 'origin/issue/OFFI-33' into issue/OCC-252
sarahelsaig May 22, 2024
7eebeb6
Fix using.
sarahelsaig May 22, 2024
32b6d2e
Fix xUnit1045 warning.
sarahelsaig May 22, 2024
153a95c
Remove obsolete custom htmlvalidate config file.
sarahelsaig May 23, 2024
b1681db
Add orchardcore-preview to the nuget config.
sarahelsaig May 23, 2024
367ba07
Update references.
sarahelsaig May 23, 2024
86122d1
Remove Newtonsoft from cshtml files.
sarahelsaig May 23, 2024
922dd73
Migrate ProductAttributeValueConverter to STJ.
sarahelsaig May 23, 2024
abd80f1
Fix various OC 2.0 changes (excl. PopulateSettings related stuff).
sarahelsaig May 23, 2024
6545756
Use CopySettingsTo.
sarahelsaig May 23, 2024
7884080
Update to the latest OC preview version.
sarahelsaig May 30, 2024
2d5539f
Merge remote-tracking branch 'origin/main' into issue/OCC-245
sarahelsaig May 30, 2024
e829bab
Remove no longer needed compatibility suppression files.
sarahelsaig May 30, 2024
26b710c
Update Nuget.config.
sarahelsaig May 30, 2024
0887f75
Fix remaining build errors in NEST.
sarahelsaig Jun 3, 2024
0f396fd
Move Payment into abstractions because we can't do arbitrary polymorp…
sarahelsaig Jun 3, 2024
e388924
Remove Legacy*Converter.cs files.
sarahelsaig Jun 4, 2024
8409ebf
Fix errors.
sarahelsaig Jun 4, 2024
9c3d50f
Get rid of remaining `using Newtonsoft.Json`.
sarahelsaig Jun 4, 2024
4210f13
Replace obsolete method call.
sarahelsaig Jun 4, 2024
934808d
Update OC package version in OCC.
sarahelsaig Jun 13, 2024
1c2e2fa
Fix incorrect WhenWritingNull usage.
sarahelsaig Jun 16, 2024
9560f29
update OC version
sarahelsaig Jun 17, 2024
d0d60b1
Update OC version.
sarahelsaig Jun 19, 2024
5144dac
LocalizedHtmlStringConverter is not needed.
sarahelsaig Jun 19, 2024
7795943
Update OC preview version.
sarahelsaig Jun 20, 2024
775d66f
Fix price serialization.
sarahelsaig Jun 20, 2024
cf45fa5
Move NullCurrencySelector to the last injection order.
sarahelsaig Jun 20, 2024
64a526d
Fix strange behavior for ICurrencySelector.
sarahelsaig Jun 20, 2024
2cb9653
Update OC preview version
sarahelsaig Jun 21, 2024
4054dfa
Update package versions and Nuget.config.
sarahelsaig Jun 24, 2024
8558dd1
Merge remote-tracking branch 'origin/issue/OCC-245' into issue/OCC-245
sarahelsaig Jun 24, 2024
a4b4c5c
Autofix all usings.
sarahelsaig Jun 24, 2024
cd5ef56
Fix static various code analysis warnings.
sarahelsaig Jun 24, 2024
86f64f9
Fix versions in OrchardCore.Commerce.Web.csproj.
sarahelsaig Jun 24, 2024
409bc73
Remove lingering Newtonsoft references.
sarahelsaig Jun 24, 2024
01c259c
Update site setting selector.
sarahelsaig Jun 24, 2024
a3f044f
Prevent LocalizedHtmlString deserialization.
sarahelsaig Jun 24, 2024
dfa6bea
Temporarily increase timeout-minutes.
sarahelsaig Jun 24, 2024
ded7562
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jun 24, 2024
6f369a0
Update OC preview version.
sarahelsaig Jun 28, 2024
6ccc73f
Merge branch 'issue/OCC-245' of github.com:OrchardCMS/OrchardCore.Com…
sarahelsaig Jun 28, 2024
e250237
Bug fix settings retrieval.
sarahelsaig Jun 28, 2024
230064b
dummy
sarahelsaig Jun 28, 2024
bf6f668
Update OC preview version.
sarahelsaig Jul 1, 2024
380814e
Update error handling to the new message.
sarahelsaig Jul 1, 2024
d014273
Use Trumbowyg.
sarahelsaig Jul 1, 2024
4c6b75e
Unusing.
sarahelsaig Jul 1, 2024
1aab941
Fix html string deserialization.
sarahelsaig Jul 1, 2024
ace70c7
Fix string price deserialization.
sarahelsaig Jul 1, 2024
cf0448e
Fix error CA1725.
sarahelsaig Jul 1, 2024
64c9d74
Fix formatting.
sarahelsaig Jul 1, 2024
c94656c
Bug fix TextProductAttributeDeserializer deserialization.
sarahelsaig Jul 1, 2024
daa36d4
Make sure ContentLocalizationStartup's Order is higher than OrchardCo…
sarahelsaig Jul 2, 2024
5d6c579
Add test-verbosity for ubuntu.
sarahelsaig Jul 2, 2024
ae1d000
Update to latest OC preview version.
sarahelsaig Jul 2, 2024
ecaae29
Try dotnet-test-process-timeout.
sarahelsaig Jul 9, 2024
f1ad548
Merge remote-tracking branch 'origin/issue/OCC-245' into issue/OCC-245
sarahelsaig Jul 9, 2024
5b83a89
Remove dotnet-test-process-timeout to confirm that it really did just…
sarahelsaig Jul 9, 2024
e0c7de4
Yep, dotnet-test-process-timeout is needed.
sarahelsaig Jul 10, 2024
01d7e42
Test if really only FullSecurityScanShouldPass fails.
sarahelsaig Jul 11, 2024
c8a988c
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jul 11, 2024
6c4e953
Update OC preview version.
sarahelsaig Jul 12, 2024
986e670
Add decimal add/subtract operators to Amount.
sarahelsaig Jul 13, 2024
b019ea2
Clean up AmountConverterFilter.
sarahelsaig Jul 13, 2024
1e94ef8
Rename order_line_item_view_models_and_tax_rates to order_part_to_ord…
sarahelsaig Jul 13, 2024
c407dde
Add amount_to_string filter.
sarahelsaig Jul 13, 2024
c255f51
Update HL and UITT versions.
sarahelsaig Jul 13, 2024
d17faf8
Merge branch 'issue/OCC-245' of github.com:OrchardCMS/OrchardCore.Com…
sarahelsaig Jul 13, 2024
8a44ac4
Fix analyzer warnings.
sarahelsaig Jul 14, 2024
542cf64
Update src/Libraries/OrchardCore.Commerce.MoneyDataType/Serialization…
sarahelsaig Jul 14, 2024
1b7143d
Update src/Libraries/OrchardCore.Commerce.MoneyDataType/Serialization…
sarahelsaig Jul 14, 2024
b9bd11b
Apply suggestions from code review
sarahelsaig Jul 14, 2024
858b037
Fix errors after applying review suggestions.
sarahelsaig Jul 14, 2024
19cafa1
Add JConvert to the dictionary.
sarahelsaig Jul 14, 2024
6fb7f99
Always update the model even if validation failed
sarahelsaig Jul 14, 2024
bee9997
Shortcut GetOutput if it's already in the expected type.
sarahelsaig Jul 14, 2024
5b10bc5
Use constant for configure order.
sarahelsaig Jul 14, 2024
455a80a
Use GetSettingsAsync extension method.
sarahelsaig Jul 14, 2024
4320fff
See if we can force timeout using Task.WhenAny
sarahelsaig Jul 15, 2024
9ff0a75
Format line.
sarahelsaig Jul 15, 2024
78bfa00
Format line.
sarahelsaig Jul 15, 2024
b54e42a
Use fact timeout instead.
sarahelsaig Jul 15, 2024
28ab541
Try with 5 minutes for now.
sarahelsaig Jul 15, 2024
2ddaaeb
Fact timeout doesn't work, stick with dotnet-test-process-timeout.
sarahelsaig Jul 15, 2024
8c738dc
Revert `@JConvert.SerializeObject` back to `@Json.Serialize`.
sarahelsaig Jul 15, 2024
6ccffc6
Use `await app.RunAsync();`
sarahelsaig Jul 15, 2024
86fae3d
Use `await app.RunAsync();`
sarahelsaig Jul 15, 2024
c7c241a
Refactor to get rid of "This method is intentionally not awaited sinc…
sarahelsaig Jul 15, 2024
db096da
Check if it's already done.
sarahelsaig Jul 15, 2024
2e386c6
Add missing maxCount parameter.
sarahelsaig Jul 15, 2024
37cd4fb
Remove locks.
sarahelsaig Jul 15, 2024
cce49d5
Try preloading the shape cache.
sarahelsaig Jul 16, 2024
9208980
Revert previous experimental changes.
sarahelsaig Jul 16, 2024
8f342e6
Update HL version.
sarahelsaig Jul 16, 2024
694697d
Use PrepareShapeTable.
sarahelsaig Jul 16, 2024
42cbdec
Update UITT version to use the new shape table prepare controller.
sarahelsaig Jul 16, 2024
70dd9dd
Update UITT version again.
sarahelsaig Jul 16, 2024
0a57bfa
We don't need build-create-binary-log here any more.
sarahelsaig Jul 17, 2024
fce1111
Update OC preview version.
sarahelsaig Jul 24, 2024
764b8d4
Remove workaround that shouldn't be necessary any more.
sarahelsaig Jul 24, 2024
a51f09b
Fix error IDE0010: Populate switch.
sarahelsaig Jul 24, 2024
57c74b6
Better OC Layers docs link
Piedone Jul 24, 2024
526217d
Update NuGet.config
sarahelsaig Jul 24, 2024
f775cc4
Update src/Modules/OrchardCore.Commerce/Startup.cs
sarahelsaig Jul 24, 2024
9d93e7e
Fix nuget config.
sarahelsaig Jul 24, 2024
12e2685
Re-add dotnet-test-process-timeout.
sarahelsaig Jul 24, 2024
d3cb472
Fix solution item path in unix.
sarahelsaig Jul 24, 2024
c085400
Rename Behaviour to Behavior
sarahelsaig Jul 24, 2024
7b2431e
Remove incorrect comment.
sarahelsaig Jul 24, 2024
2483e96
Add 3.0.0 change notes.
sarahelsaig Jul 25, 2024
92f2609
Get rid of the last shreds of IPayment.
sarahelsaig Jul 25, 2024
2ea9013
Reduce security scan max duration.
sarahelsaig Jul 25, 2024
c62ebb8
Hopefully dotnet-test-process-timeout can be dropped now.
sarahelsaig Jul 25, 2024
d146996
Make active scan single threaded to prevent deadlocks.
sarahelsaig Jul 26, 2024
9afdb73
Converters don't need to be internal.
sarahelsaig Jul 26, 2024
d50e7e2
Revert threadPerHost, it's not effective.
sarahelsaig Jul 26, 2024
b5b8e76
Fix error CA1725
sarahelsaig Jul 26, 2024
e713c5f
Add docs on the Liquid filter changes.
sarahelsaig Jul 26, 2024
b43204e
Typos/grammar
Piedone Jul 26, 2024
55bf922
Apply suggestions from code review
sarahelsaig Jul 26, 2024
409c039
Fix warnings.
sarahelsaig Jul 26, 2024
2babc78
Clean up configuration order usage.
sarahelsaig Jul 26, 2024
5a21eaf
Update HL and UITT preview versions.
sarahelsaig Jul 26, 2024
9e397dd
Update HL and UITT preview versions.
sarahelsaig Jul 27, 2024
f06dd9f
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jul 28, 2024
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
3 changes: 2 additions & 1 deletion .github/actions/spelling/allow/occ.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ foobool
footext
GST
htmlfield
JConvert
LCID
markdownlint
Mastercard
Expand All @@ -39,4 +40,4 @@ testproductvariant
unpublish
vnd
webhooks
webshop
webshop
16 changes: 9 additions & 7 deletions Directory.Packages.props
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@
<!-- The Orchard Core version should always be x.y.0 of the latest minor version for maximum compatibility when
distributed as NuGet packages. On the other hand, the consuming projects (including OrchardCore.Commerce.Web)
should use Orchard Core references for the latest patch version to pull all versions up in the final app. -->
<OrchardCoreVersion>1.8.0</OrchardCoreVersion>
<OrchardCoreVersion>2.0.0-preview-18282</OrchardCoreVersion>

<LombiqHelpfulLibrariesVersion>10.0.1-preview.4.occ-245</LombiqHelpfulLibrariesVersion>
<LombiqTestsUIVersion>10.0.2-preview.3.occ-245</LombiqTestsUIVersion>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Lombiq.Analyzers.OrchardCore" Version="5.0.0" />
<PackageVersion Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.0" />
<PackageVersion Include="Lombiq.HelpfulLibraries.Refit" Version="10.0.0" />
<PackageVersion Include="Lombiq.HelpfulLibraries.OrchardCore" Version="$(LombiqHelpfulLibrariesVersion)" />
<PackageVersion Include="Lombiq.HelpfulLibraries.Refit" Version="$(LombiqHelpfulLibrariesVersion)" />
<PackageVersion Include="Lombiq.NodeJs.Extensions" Version="2.1.0" />
<PackageVersion Include="Lombiq.Tests" Version="3.0.0" />
<PackageVersion Include="Lombiq.Tests.UI" Version="10.0.1" />
<PackageVersion Include="Lombiq.Tests.UI.AppExtensions" Version="10.0.1" />
<PackageVersion Include="Lombiq.Tests.UI.Shortcuts" Version="10.0.1" />
<PackageVersion Include="Lombiq.Tests.UI" Version="$(LombiqTestsUIVersion)" />
<PackageVersion Include="Lombiq.Tests.UI.AppExtensions" Version="$(LombiqTestsUIVersion)" />
<PackageVersion Include="Lombiq.Tests.UI.Shortcuts" Version="$(LombiqTestsUIVersion)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="OrchardCore.Application.Cms.Targets" Version="$(OrchardCoreVersion)" />
<PackageVersion Include="OrchardCore.ContentFields" Version="$(OrchardCoreVersion)" />
<PackageVersion Include="OrchardCore.ContentManagement" Version="$(OrchardCoreVersion)" />
Expand Down
31 changes: 31 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- Ignore global configuration -->
<clear />
<add key="LombiqPreview" value="https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json" />
<add key="OrchardCorePreview" value="https://nuget.cloudsmith.io/orchardcore/preview/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="*" />
<!-- OrchardCore.Translations.All is on a separate repo and doesn't have a preview -->
<package pattern="OrchardCore.Translations.*" />
</packageSource>
<packageSource key="OrchardCorePreview">
<package pattern="OrchardCore*" />
<!-- OrchardCore theme packages -->
<package pattern="SafeMode" />
<package pattern="TheAgencyTheme" />
<package pattern="TheBlogTheme" />
<package pattern="TheComingSoonTheme" />
<package pattern="TheTheme" />
<package pattern="TheAdmin" />
</packageSource>
<packageSource key="LombiqPreview">
<package pattern="Lombiq.HelpfulLibraries*" />
<package pattern="Lombiq.Tests.UI*" />
</packageSource>
</packageSourceMapping>
</configuration>
21 changes: 0 additions & 21 deletions Nuget.config

This file was deleted.

8 changes: 7 additions & 1 deletion OrchardCore.Commerce.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
License.md = License.md
mkdocs.yml = mkdocs.yml
Nuget.config = Nuget.config
Readme.md = Readme.md
Reset-Local.ps1 = Reset-Local.ps1
Directory.Packages.props = Directory.Packages.props
NuGet.config = NuGet.config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B2D057AA-E3F7-404D-A713-C3C59F9DE562}"
Expand Down Expand Up @@ -118,6 +118,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "guides", "guides", "{EF8008
docs\guides\create-webshop.md = docs\guides\create-webshop.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "releases", "releases", "{0A8AB166-9C4F-4161-BD69-362DBC73A11E}"
ProjectSection(SolutionItems) = preProject
docs\releases\3.0.0.md = docs\releases\3.0.0.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -214,6 +219,7 @@ Global
{28DB6CBB-1527-42A1-8EFE-3D95BF185884} = {90913510-3D7F-4BCC-B55E-56343128F049}
{73925C09-BF96-4727-91D8-57A88AD1601F} = {E6C02BDF-EEB0-4ABD-ADEC-9932F60923AE}
{EF8008F1-64F5-4053-A639-6285084AFA52} = {BEBA1764-178A-4722-A193-4DEF26DCE8D1}
{0A8AB166-9C4F-4161-BD69-362DBC73A11E} = {BEBA1764-178A-4722-A193-4DEF26DCE8D1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {456CBC78-579D-483F-A4C3-AF5C12AB3324}
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/create-webshop.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Navigate to _Design > Settings > Zones_ and define the zone where you want the S
_Header, Content, Footer, any zone can be created here. Except for Ozone, that's illegal._

- **Layers**:
A Layer is also going to be necessary for the Widget, so if you don't have one set up yet, see the [relevant documentation page](https://github.com/OrchardCMS/OrchardCore/tree/main/src/docs/reference/modules/Layers/).
A Layer is also going to be necessary for the Widget, so if you don't have one set up yet, see the [relevant documentation page](https://docs.orchardcore.net/en/latest/reference/modules/Layers/).

- **Widget**:
Widgets are content items that have their stereotype set to Widget. The Commerce module creates a simple Shopping Cart Widget when it's enabled, so we'll just use that. For more extensive documentation about Widgets, see the [usual place](https://docs.orchardcore.net/en/main/docs/reference/modules/Widgets/).
Expand Down
30 changes: 30 additions & 0 deletions docs/releases/3.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Orchard Core Commerce 3.0.0

Release date: Not yet released

## Important Upgrade Instructions

Prior to making the leap to Orchard Core Commerce 3.0.0, please read and follow the instructions for the [Orchard Core 2.0.0 release](https://docs.orchardcore.net/en/latest/releases/2.0.0/), as it contains several major breaking changes.

## Breaking Changes

### Dropped `Newtonsoft.Json` Support

The most important breaking change in OC 2.0 is the end of support for [Newtonsoft Json.NET](https://www.newtonsoft.com/json) and the switch to the [System.Text.Json](https://www.nuget.org/packages/System.Text.Json) (STJ) library. For OCC, all Newtonsoft converters are removed, STJ converters were written or updated as necessary. Any models and interfaces that use `JToken` or `JObject` (such as `OrderPart.AdditionalData` and `IUserService.AlterUserSettingAsync()`) now use `JsonNode` and `JsonObject` respectively.

### Replaced `IPayment` with `Payment` Everywhere

We've dropped the [`IPayment`](https://github.com/OrchardCMS/OrchardCore.Commerce/blob/34ae00470e954459f19f688c9bfc51d196c386ca/src/Libraries/OrchardCore.Commerce.Abstractions/Abstractions/IPayment.cs) interface, now services and models use `Payment` directly, which was also moved into the `OrchardCore.Commerce.Abstractions` library. Migrating to STJ meant that to retain the polymorphic deserialization support for models using `IPayment` would've taken on some additional complexity, while we already found the separate interface unnecessary.

Update using references to `OrchardCore.Commerce.Abstractions.Models`. If you have a custom payment processor integration, update it to use `Payment`.

### Liquid Filters

The `order_line_item_view_models_and_tax_rates` Liquid filter has been removed. A new `order_part_to_order_summary` filter has been added instead, which can be treated as a drop-in replacement. It has additional `Amount` type properties: `UnitTax`, `SubTotal`, `TaxTotal`, and `Total`. These contain the calculated and appropriately rounded values.

The new `amount_to_string` filter processes the input object as `Amount` (like the `amount` filter) and correctly formats it just like the `Amount.ToString()` override in C#. You can use `amount_to_string: dot: ","` to make it display a comma as the decimal separator when it would use a dot. Unlike `amount`, you can also use this filter on a number with the `currency: "three-letter-code""` argument (e.g. `{{ value | amount_to_string: currency: "EUR" }}`). This will display any numeric value as the given currency.

## Change Logs

Please check the GitHub release entry [here](https://github.com/OrchardCMS/OrchardCore.Commerce/releases/tag/v3.0.0).

4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,6 @@ nav:
- NumericProductAttributeField: features/numeric-product-attribute-field.md
- Resources:
- Libraries: resources/libraries/README.md
- Releases: https://github.com/OrchardCMS/OrchardCore.Commerce/releases
- Releases and Notes:
- GitHub: https://github.com/OrchardCMS/OrchardCore.Commerce/releases
- 3.0.0: docs/releases/3.0.0.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json.Linq;
using System;
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;

Expand All @@ -23,11 +22,6 @@ public interface IProductAttributeDeserializer
/// </summary>
string AttributeTypeName { get; }

/// <summary>
/// Deserializes using <c>Newtonsoft.Json</c>.
/// </summary>
IProductAttributeValue Deserialize(string attributeName, JObject attribute);

/// <summary>
/// Deserializes using <c>System.Text.Json</c>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Newtonsoft.Json;
using OrchardCore.Commerce.Abstractions.Serialization;
using System;
using System.Globalization;
using System.Linq;
using System.Text.Json.Serialization;

namespace OrchardCore.Commerce.Abstractions.Abstractions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json.Linq;
using OrchardCore.ContentManagement;
using OrchardCore.Users.Models;
using System;
using System.Security.Claims;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace OrchardCore.Commerce.Abstractions.Abstractions;
Expand All @@ -22,7 +22,7 @@ public interface IUserService
/// Alters the JSON of a custom user setting content item and saves the result. If the setting doesn't exist for the
/// user then also creates it.
/// </summary>
Task AlterUserSettingAsync(User user, string contentType, Func<JObject, JObject> updateContentItemJson);
Task AlterUserSettingAsync(User user, string contentType, Func<JsonObject, JsonObject> updateContentItemJson);

/// <summary>
/// Retrieves a <see cref="ContentItem"/> that belongs to the custom user setting.
Expand All @@ -33,8 +33,7 @@ public interface IUserService
public static class UserServiceExtensions
{
public static Task<User> GetCurrentFullUserAsync(this IUserService service, IHttpContextAccessor hca) =>
hca.HttpContext?.User is { } user &&
hca.HttpContext.User.Identity?.IsAuthenticated == true
hca.HttpContext?.User is { Identity.IsAuthenticated: true } user
? service.GetFullUserAsync(user)
: Task.FromResult<User>(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OrchardCore.Commerce.MoneyDataType;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OrchardCore.Commerce.Abstractions.Models;

Expand All @@ -13,10 +14,15 @@ public class OrderLineItem
public Amount UnitPrice { get; set; }
public Amount LinePrice { get; set; }
public string ContentItemVersion { get; set; }
public ISet<IProductAttributeValue> Attributes { get; }
public IDictionary<string, IDictionary<string, string>> SelectedAttributes { get; } =
public ISet<IProductAttributeValue> Attributes { get; init; }
public IDictionary<string, IDictionary<string, string>> SelectedAttributes { get; init; } =
new Dictionary<string, IDictionary<string, string>>();

[JsonConstructor]
private OrderLineItem()
{
}

// These are necessary.
#pragma warning disable S107 // Methods should not have too many parameters
public OrderLineItem(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OrchardCore.Commerce.Abstractions.Abstractions;
using OrchardCore.Commerce.Abstractions.Constants;
using OrchardCore.Commerce.Abstractions.Fields;
using OrchardCore.ContentFields.Fields;
using OrchardCore.ContentManagement;
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;

namespace OrchardCore.Commerce.Abstractions.Models;

Expand All @@ -26,16 +25,9 @@ public class OrderPart : ContentPart
public IList<OrderAdditionalCost> AdditionalCosts { get; } = new List<OrderAdditionalCost>();

/// <summary>
/// Gets the amounts charged for this order. Typically a single credit card charge.
/// Gets the amounts charged for this order. Typically, a single credit card charge.
/// </summary>

// This is a temporary solution, it needs to be reworked in the future!
#pragma warning disable CA2326 // Do not use TypeNameHandling values other than None
#pragma warning disable SCS0028 // TypeNameHandling is set to the other value than 'None'. It may lead to deserialization vulnerability.
[JsonProperty(ItemTypeNameHandling = TypeNameHandling.Auto)]
#pragma warning restore SCS0028 // TypeNameHandling is set to the other value than 'None'. It may lead to deserialization vulnerability.
#pragma warning restore CA2326 // Do not use TypeNameHandling values other than None
public IList<IPayment> Charges { get; } = new List<IPayment>();
public IList<Payment> Charges { get; } = new List<Payment>();

public TextField Email { get; set; } = new();
public TextField Phone { get; set; } = new();
Expand All @@ -46,7 +38,7 @@ public class OrderPart : ContentPart
public BooleanField BillingAndShippingAddressesMatch { get; set; } = new();
public BooleanField IsCorporation { get; set; } = new();

public IDictionary<string, JToken> AdditionalData { get; } = new Dictionary<string, JToken>();
public IDictionary<string, JsonNode> AdditionalData { get; } = new Dictionary<string, JsonNode>();

[JsonIgnore]
public bool IsPending => string.IsNullOrWhiteSpace(Status?.Text) || Status.Text.EqualsOrdinalIgnoreCase(OrderStatusCodes.Pending);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using OrchardCore.Commerce.Abstractions.Abstractions;
using OrchardCore.Commerce.MoneyDataType;
using System;

namespace OrchardCore.Commerce.Payment.Models;
namespace OrchardCore.Commerce.Abstractions.Models;

Copy link
Member

Choose a reason for hiding this comment

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

Abstractions in the name space may be weird. Payments may be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was moved into the OrchardCore.Commerce.Abstractions library which contains all the shared models and interfaces needed across several modules, to avoid unnecessary cross dependency. We don't group namespaces by role inside the Abstractions library at all, because most classes here are hard to categorize and only doing it for some that are easy (like this one) would be even more weird. Also it feels like unnecessary namespace pollution to me.

public record Payment(
string Kind,
string TransactionId,
string ChargeText,
Amount Amount,
DateTime CreatedUtc)
: IPayment;
DateTime CreatedUtc);
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using Newtonsoft.Json;
using OrchardCore.Commerce.Abstractions.Serialization;
using OrchardCore.Commerce.MoneyDataType;
using System.Diagnostics;
using System.Globalization;
using System.Text.Json.Serialization;

namespace OrchardCore.Commerce.Abstractions.Models;

/// <summary>
/// A price and its priority.
/// </summary>
[JsonConverter(typeof(LegacyPrioritizedPriceConverter))]
[System.Text.Json.Serialization.JsonConverter(typeof(PrioritizedPriceConverter))]
[JsonConverter(typeof(PrioritizedPriceConverter))]
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class PrioritizedPrice
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ public class ShoppingCart
/// <summary>
/// Gets the number of lines in the cart.
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[JsonIgnore]
public int Count => Items.Count;

/// <summary>
/// Gets the total number of items (i.e. products) in the cart. In other words, the sum of quantities of all lines.
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[JsonIgnore]
public int ItemCount => Items.Sum(item => item.Quantity);

Expand Down
Loading
Loading