Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dennisdoomen
Copy link
Member

@dennisdoomen dennisdoomen commented Sep 3, 2023

This PR introduces FA's own "module initializer" through the new [AssertionEngineInitializer] attribute. It can be used multiple times.

For future reference, we're not using ModuleInitializerAttribute for two reasons:

  1. .NET Framework 4.x doesn't have that attribute.
  2. Module initializers are not invoked until the assembly containing the initializer is actually needed at run-time. As a consequence of that, a package like FluentAssertions.DataSets may not even get a chance to register its custom implementations of IEquivalencyStep when somebody invokes BeEquivalentTo without explicitly using code from that package first. To resolve this, you could have that package add a source file as content (in NuGet terms) that adds a module initializer. Then it would be invoked the first time the test project is loaded. But that would require that source file to define the ModuleInitializerAttribute for .NET 4.x, which is hard since you can't detect whether it is needed. non-SDK projects do not define attributes like NETFRAMEWORK and such. If that test project already defines that attribute in a different way (e.g. using Polysharp), it would cause compilation conflicts.

Also, while testing with FluentAssertions.DataSets, it turns out the caller identifier was misbehaving if Fluent Assertions code preceded the data set extensions code in the stack trace. This has been fixed as well.

Tested with the FluentAssertions.DataSets repository.

Note Review by commit

Closes #2290

@github-actions

This comment was marked as outdated.

@dennisdoomen dennisdoomen force-pushed the Feature/ExtensibilityDetection branch 8 times, most recently from 0e24df3 to 1e9b078 Compare September 17, 2023 19:25
@dennisdoomen dennisdoomen changed the title POC extension library initialization Introduced a new attribute to allow global initialization of the assertion options Sep 17, 2023
@dennisdoomen dennisdoomen force-pushed the Feature/ExtensibilityDetection branch from 1e9b078 to 7dc23f8 Compare September 17, 2023 19:30
@dennisdoomen dennisdoomen marked this pull request as ready for review September 17, 2023 19:32
@dennisdoomen dennisdoomen requested a review from jnyrup September 17, 2023 19:34
@dennisdoomen dennisdoomen force-pushed the Feature/ExtensibilityDetection branch from 7dc23f8 to 3e0e13d Compare September 18, 2023 19:37
Copy link
Contributor

@Corniel Corniel left a comment

Choose a reason for hiding this comment

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

Overall, it looks good. I think explaining what the effect is of 'using multiple times', v.s. 'called once' might be explained in more detail.

@dennisdoomen
Copy link
Member Author

Overall, it looks good. I think explaining what the effect is of 'using multiple times', v.s. 'called once' might be explained in more detail.

Good point. Will look a the description. Need to rebase anyway.

@dennisdoomen dennisdoomen force-pushed the Feature/ExtensibilityDetection branch from 3e0e13d to b5a3c2c Compare September 23, 2023 06:31
@dennisdoomen dennisdoomen force-pushed the Feature/ExtensibilityDetection branch 2 times, most recently from 51f8e09 to e533255 Compare October 14, 2023 14:47
@github-actions
Copy link

github-actions bot commented Oct 14, 2023

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

  1. Register at Qodana Cloud and configure the action
  2. Use GitHub Code Scanning with Qodana
  3. Host Qodana report at GitHub Pages
  4. Inspect and use qodana.sarif.json (see the Qodana SARIF format for details)

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/[email protected]
        with:
          upload-result: true
Contact Qodana team

Contact us at [email protected]

@coveralls
Copy link

coveralls commented Oct 14, 2023

Pull Request Test Coverage Report for Build 6652964260

  • 44 of 48 (91.67%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 97.388%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Src/FluentAssertions/Common/Services.cs 31 35 88.57%
Totals Coverage Status
Change from base Build 6651038722: -0.04%
Covered Lines: 11713
Relevant Lines: 11904

💛 - Coveralls

@dennisdoomen dennisdoomen marked this pull request as draft October 18, 2023 09:34
@dennisdoomen dennisdoomen force-pushed the Feature/ExtensibilityDetection branch 2 times, most recently from bc727d5 to c4aec36 Compare October 22, 2023 07:42
This was referenced Sep 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow extension libraries to alter options before the first assertion
5 participants