Conversation
added 5 commits
November 28, 2026 12:06
The 20 shipped plugins now compile with nullable enabled and nullable warnings as errors, like the core projects. Models and settings strings are nullable; no warning is suppressed and no `!` is left: the ones BrainTree, OnAccount and Google Analytics carried from before are gone. Contract changes: - DiscountRuleValidationRequest: Discount, DiscountRule, Customer and Store are required and not null. The one caller always set all four. - PanelStoreId() moved from AdminShared to Grand.Web.Common, so the plugins' Store-area controllers read the staff store id the way Grand.Web.Store does, and throw when it is missing. Behaviour where develop would throw a NullReferenceException: - Facebook/Google sign-in without a NameIdentifier claim goes back to the login page. - Stripe webhook without a Stripe-Signature header answers 400 as before, from an explicit check. - Explicit exceptions with a message instead: ECB/NBP response without the expected nodes, BrainTree payment whose customer or billing address is missing or which runs outside a request, Stripe without an API key or order line, Stripe redirect for a missing order. - Admin shipping point edit/delete and admin tax rate update of a missing record redirect or answer empty, as the Store-area ones do. - Shipping point checkout without offered options asks to select a point again.
With the tests compiled under nullable, they showed parameters that take null by design while their type said otherwise. Each one below is already handled where it is used, and a test pins that behaviour: - FormatAttributes host (IContactAttributeParser): documented as optional, read with host?.Url. - LiquidCustomer, LiquidOrder, LiquidMerchandiseReturn host: kept as DomainHost? and replaced by the store URL when missing. - DataSettingsManager.LoadDataSettings: null forgets the loaded settings, so the next read takes them from the file. - PluginInfo constructor: a plugin that failed to load has no assembly or type; the properties were already nullable. - Audit log List, HistoryPopup, HistoryList: query parameters a request may leave out, checked with IsNullOrEmpty. - CustomerList searchCustomerTagIds: the store panel passes null to mean no tag filter. - Knowledgebase PrepareKnowledgebaseNodeGridModel: null is the root, read as parentCategoryId ?? "". - Merchandise return note: a note without an attached file binds the file as null; InsertMerchandiseReturnNoteCommand.File is no longer required and the handler already checks it. No behaviour changes.
The 22 test projects compile with nullable enabled and nullable warnings
as errors. Nothing is suppressed; a test passes null! only where the
null exercises the guard of the code under test (a test about a missing
value), as for the production code.
How the tests changed:
- [TestInitialize] became the constructor (MSTest builds an instance per
test), so the fields it sets are definitely assigned. An async
initializer keeps only its awaits; a field that only an async start
sets is nullable behind a property that throws until it is set.
- A value that may be null is asserted before use: Assert.IsNotNull
before a dereference, Assert.IsInstanceOfType<T> for a cast of a
view model or JSON value, First instead of FirstOrDefault where the
test expects the element, x?.Y inside Assert.AreEqual.
- Moq setups of methods returning Task<T?> use ReturnsAsync, which
takes T? from the method.
- A null passed where the parameter takes none became the neutral
value of the type ("" , [], new()), or null! in a test about the
missing value.
- Fields a Moq callback fills during the test are nullable.
Fixed on the way, in the tests only:
- PriceServiceTests set up the working currency before creating it, so
the mock returned null; the currency is now created first.
- SeNameServiceTests (NUnit) runs an instance per test case, so its
constructor replaces [SetUp].
Every project that imports Grand.Common.props now compiles with Nullable enabled and nullable warnings as errors, so a new project or plugin starts the same way. The per-project settings and the #nullable enable directives are gone. The two Aspire projects do not import the props and keep their own setting.
added 3 commits
November 28, 2026 12:46
… constructor dotnet.md still said the plugins and tests were left out and that each project sets Nullable in its csproj; tests.md taught [TestInitialize], whose example no longer compiles now that test projects build with nullable warnings as errors.
…der nullable Grand.Common.props appends nullable to WarningsAsErrors instead of replacing a value set before it. The admin configuration template declares ActiveStore as string?, as a plugin built from it otherwise fails with CS8618.
…omer GetStateProvincesByCountryId returns an empty list for a missing or unknown country, so its signature no longer says it may return null and the callers drop their `?? []`. DiscountRuleValidationRequest.Customer is required and not null, so the standard discount rules drop their `request.Customer == null` checks, and the test that passed a null customer is gone.
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
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.
Type: feature
Issue
#1131 enabled nullable reference types everywhere except the plugins (
src/Plugins) and the test projects (src/Tests). Those two still compiled without nullable, so a plugin could pass or return null where the core now says it cannot, and the tests did not show where a null was used.Solution
The 20 plugins and the 22 test projects compile with nullable enabled and nullable warnings as errors, and the setting moved into
Grand.Common.props: every project that imports it starts that way, a new plugin included. The per-project settings and the 27#nullable enabledirectives are gone. The two Aspire projects do not import the props and keep their own setting.The rules are those of #1131 (
.ai/knowledge/dotnet.md, Nullable Reference Types). Nothing is silenced, no!is left in the plugins, and a test passesnull!only where the null exercises the guard of the code under test.One commit per layer:
!BrainTree, OnAccount and Google Analytics carried from before are gone.[TestInitialize]became the constructor (MSTest builds an instance per test). An async initializer keeps only its awaits.Assert.IsNotNull,Assert.IsInstanceOfType<T>for a view model or JSON value,Firstwhere the test expects the element.Task<T?>useReturnsAsync."",[],new()), ornull!in a test about the missing value.Grand.Common.props.Contract changes
DiscountRuleValidationRequest:Discount,DiscountRule,CustomerandStorearerequiredand not null. The one place that creates it always set all four, so every discount rule now gets them non-null.PanelStoreId()moved fromGrand.Web.AdminSharedtoGrand.Web.Common. The plugins' Store-area controllers read the staff store the same wayGrand.Web.Storedoes, and throw when it is missing.IContactAttributeParser.FormatAttributes(… DomainHost? host …).LiquidCustomer,LiquidOrderandLiquidMerchandiseReturnhost. Each falls back to the store URL.DataSettingsManager.LoadDataSettings(DataSettings?): null forgets the loaded settings.PluginInfoconstructor (a plugin that failed to load has no assembly).List/HistoryPopup/HistoryListquery parameters.CustomerList searchCustomerTagIds, which the store panel passes as null.PrepareKnowledgebaseNodeGridModel(string? parentCategoryId), where null is the root.ICountryService.GetStateProvincesByCountryIdreturnsTask<IList<StateProvince>>: it already gave an empty list for a missing or unknown country, so the callers dropped their?? []. The standard discount rules dropped theirrequest.Customer == nullchecks, now that the customer is required.InsertMerchandiseReturnNoteCommand.Fileis no longerrequiredand the action takesIFormFile?. Enable nullable reference types #1131 had marked it required.Behaviour changes
All in the plugins, where develop threw a
NullReferenceExceptionor answered 500:NameIdentifierclaim goes back to the login page.Stripe-Signatureheader it answers 400 as before, now from an explicit check that says so.Breaking changes
Grand.Common.propsnow builds with nullable warnings as errors. A third-party plugin or module that imports it, and was built without nullable, has to fix its nullable warnings or turn the setting off in its own project file.DiscountRuleValidationRequest's members arerequired(CS9035 regardless of the nullable setting), so code that creates one must set all four. No plugin in this repository creates one.PanelStoreId()changed namespace: it is now inGrand.Web.Common.Extensions, no longer inGrand.Web.AdminShared.Extensions. It was added by Enable nullable reference types #1131 and has not been released.Grand.Common.propsappendsnullabletoWarningsAsErrors($(WarningsAsErrors);nullable), so a value set before the import is kept.Testing
PriceServiceTestsset the working currency on its mock before creating the currency, so the mock returned null. The currency is now created first.SeNameServiceTests(NUnit) runs an instance per test case, so its constructor replaces[SetUp].Found, not changed (develop has them too)
The review of this PR found more; each is fixed in its own PR from develop: #1146, #1147, #1148, #1149, #1150, #1151, #1152.
/DiscountRulesCustomerGroups/Configurewith an unknown discount answers 500 (fixed in Answer a discount rule window for a discount that does not exist #1144).{"success":false}on both builds in the test environment, so the ECB/NBP parsing was not exercised end to end.