Allow [SharedDb] and [PooledDb] on classes and assemblies, add [NewDb] - #1065
Merged
Merged
Conversation
[SharedDb] and [PooledDb] could only be applied to test methods. They can now also be applied to a test class or the assembly. The nearest attribute wins: method over class over assembly. [NewDb] opts a method or class out of a class or assembly attribute and uses a new database per test, which is still the default when no attribute applies. Attribute resolution moves from the four framework test bases into DbAttributeReader in EfLocalDb. More than one of the three attributes on the same method, class, or assembly throws, and every level is checked even when a nearer level decides. DbAttributeReaderTests covers each level, the overrides, inheritance and the conflicts. Each framework gets tests for class-level [PooledDb] with method-level [SharedDb] and [NewDb] overrides, and for the throw when both [PooledDb] and [SharedDb] are on a method.
This was referenced Sep 15, 2026
Merged
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.
[SharedDb]and[PooledDb]could only be applied to test methods. They can now also be applied to a test class or the assembly ([assembly: PooledDb]).[NewDb]attribute (method or class) opts out of a class or assembly attribute and uses a new database per test. That is still the default when no attribute applies.[PooledDb],[SharedDb]and[NewDb]on the same method, class, or assembly throws. Every level is checked, even when a nearer level decides. The message is now "[PooledDb], [SharedDb] and [NewDb] are mutually exclusive. Use only one on a test method." (or "a test class" / "an assembly").DbAttributeReaderin EfLocalDb.Tests:
DbAttributeReaderTestscovers each level, the overrides, class attribute inheritance and the conflicts. The assembly cases use an in-memory assembly.ClassLevelPooledDbTests(class-level[PooledDb], with method-level[SharedDb]and[NewDb]overrides) andPooledAndSharedDbTests(the throw when both are on a method).The pooled-db and shared-db docs includes describe class and assembly use and
[NewDb], and the four usage pages are regenerated.