allure-framework / allure-framework/allure-csharp

Allure attachments cannot be found due to `net8.0_*` filename prefix

Open
#689 0 comments 0 reactions 1 assignee Claimed by @delatrie View on GitHub
Dominant language
C#
Stars
125
Forks
76
Avg merge
1d 2h
Merged PRs (30d)
18

Description

### What happened?


var jsonBody = JsonConvert.SerializeObject(requestBody, Formatting.Indented);

request.AddJsonBody(jsonBody);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");

var response = Execute(request);

AllureApi.AddAttachment(name: $"Create Request {uri.Split('/').Last()}",
type: "application/json",
content: Encoding.UTF8.GetBytes(jsonBody),
fileExtension: ".json");

However, the actual file in allure-results is generated as:

net8.0_57_748a4650...-attachment.txt

The source in *-result.json does not contain the net8.0_57_ prefix, so Allure Report cannot find the attachment.

The same prefix is also added to *-result.json files.. but it is not a roblem fgor Allure report

Iuuse: the physical filename differs from the source stored in the result JSON

### How can we reproduce it?

1. Run an NUnit test using `Allure.NUnit` / `Allure.Net.Commons`.
2. Add an attachment during the test:

```csharp
AllureApi.AddAttachment(
name: "Request",
type: "application/json",
content: Encoding.UTF8.GetBytes(jsonBody),
fileExtension: ".json");
```

3. Check the generated `allure-results` folder.
4. The attachment is physically created with a prefix, for example:

```text
net8.0_57_748a4650...-attachment.json
```

5. Open the corresponding `*-result.json`.
6. The attachment `source` contains only:

```text
748a4650...-attachment.json
```

7. Generate/open the Allure report — the attachment cannot be found.

### What did you expect?

find the solution/workaround/fix

### Environment

.NET 8
NUnit 3
Allure.NUnit
Allure.Net.Commons
Windows
Azure DevOps pipeline
Allure Results directory: allure-results

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.