dotnet / dotnet/docfx

Nested region tags are stripped from imported C# code using `code-csharp`

Open
#1,899 1 comment 0 reactions 0 assignees View on GitHub
markdown
Dominant language
C#
Stars
4.4k
Forks
890
Avg merge
2h 11m
Merged PRs (30d)
10

Description

**DocFX Version Used**: 2.21.1

**Steps to Reproduce**:
1. Create C# file with nested regions such as:
```csharp
#region OUTER
public class Foo{
#region INNER
// hello
#endregion
}
#endregion
```

2. Import the cshrap into markdown using the DFM syntax, selecting the outer region.
`[!code-csharp[Main](testfile.cs#OUTER)]`

**Expected Behavior**:
Contents of the `OUTER` region are displayed.
```csharp
public class Foo{
#region INNER
// hello
#endregion
}
```

**Actual Behavior**:
The `INNER` region tags (both start and end) are dropped.
```csharp
public class Foo{
//hello
}
```

Including the whole file, or including the range with line numbers works as expected (regions are not dropped).

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.