Feature/redundant orderby static setting - #110
Merged
Merged
Conversation
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.
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.
No description provided.