allure-framework / allure-framework/allure-csharp
Compile-time IL weaver to replace harmony and aspect injector for allure-xunit
- Dominant language
- C#
- Stars
- 125
- Forks
- 76
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 18
Description
Starting from (most probably) 2.10.0-preview.1 we will be using [harmony] for the following tasks:
1. Report parameters of xunit theories that couldn't be pre enumerated during the discovery phase. (part of #366)
2. Selective run of tests in allure-xunit and allure-specflow (see #372)
Since harmony is a runtime IL weaver, it has some limitations:
1. generic methods can't be patched consistently
2. inlined methods can't be patched at all
3. breakpoints in patched methods don't work
Because of limitation 1 we can't use harmony to implement step attributes (step function may be a generic function).
Limitation 2 prevent harmony patches from working. That means the following stops working if the corresponding target method is inlined by the CLR:
- Argument reporting by allure-xunit when the pre-enumeration is disabled (either explicitly or implicitly by xunit)
- Selective run in allure-xunit
- Selective run in allure-specflow
Limitation 3 is confusing. A workaround is to put a breakpoint somewhere in a nested call instead, but it isn't obvious to a user.
We also can't use AspectInjector instead of harmony because AspectInjector lacks generic API to select methods to patch (it only provided attribute-based API).
Eventually we're stuck with using two IL weavers in a single project.
#### Proposed solution
We may replace harmony and aspect injector with hand-written IL weaver that is based on Mono.Cecil (the library harmony and aspect injector are both based on). The weaver should just allow us to hook into xunit theories, fixtures, and step functions.
#### Motivation
The are two key motivations:
1. To make allure-xunit behavior more straightforward and consistent with regard to debugging and report content.
2. To reduce the number of dependencies.
[harmony]: https://github.com/pardeike/Harmony
Contributor guide
Research direction
Start by mapping the existing Harmony and AspectInjector integration for allure-xunit and allure-specflow; the issue names no source files, tests, or entry points. Done would be a Mono.Cecil-based compile-time weaver replacing both dependencies and hooking xunit theories, fixtures, and step functions while addressing the listed reporting, selective-run, and debugging limitations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100