Skip to content

Feature/redundant orderby static setting - #110

Merged
SimonCropp merged 3 commits into
mainfrom
feature/redundant-orderby-static-setting
Jul 24, 2026
Merged

Feature/redundant orderby static setting#110
SimonCropp merged 3 commits into
mainfrom
feature/redundant-orderby-static-setting

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

No description provided.

Enabling redundant ordering detection meant editing every
UseDefaultOrderBy call, which is tedious in a test project with several
DbContext types. OrderBySettings.ThrowOnRedundantOrderBy is a static that
a module initializer can set once for the whole assembly.

For a context to be able to opt out of that, the parameter has to
distinguish "not set" from "set to false", so it is now bool?. Null means
the setting decides, and any value passed wins over it.

The setting is read during query compilation rather than when the options
are built, so a module initializer still takes effect for options that
were built before it ran.
OrderBySettings is process wide, so it cannot be exercised in the
existing Tests assembly, where several tests expect redundant ordering to
be allowed. A second assembly sets it in a module initializer and covers
the three states: not set on the context so the setting applies, false on
the context so it overrides the setting, and true on the context.

Include ordering is covered too, since the flag is passed down to it.

Named Settings.Tests rather than SettingsTests because ProjectDefaults
only infers IsPackageProject=false for a project named Tests or ending in
.Tests, and otherwise requires XML docs on every public member.
The module initializer snippet is sourced from the real one in
Settings.Tests rather than a copy in Snippets.cs. A copy there would be a
live ModuleInitializer in the Tests assembly and would turn the setting on
for that whole project, which broke Disabled_DoesNotThrow.
@SimonCropp
SimonCropp merged commit 4eb3c9e into main Jul 24, 2026
3 of 5 checks passed
@SimonCropp
SimonCropp deleted the feature/redundant-orderby-static-setting branch July 24, 2026 08:22
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.

1 participant