Skip to content

Commit d314437

Browse files
github-actions[bot]Copilotdsyme
authored
[Repo Assist] Add regression test: type with same name as namespace appears in API docs (issue #944) (#1092)
* Add regression test: type with same name as namespace appears in API docs (issue #944) Adds a minimal test library `SameNameLib` with a single type named `SameNameLib.SameNameLib` (type name = namespace name), and a test that verifies the type is correctly included in the generated API docs. The test confirms that the bug reported in #944 is not present in the current codebase — the type appears in the namespace's entity list with a non-empty URL base name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger checks --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
1 parent f5f0b4a commit d314437

6 files changed

Lines changed: 69 additions & 0 deletions

File tree

FSharp.Formatting.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestLib2", "tests\FSharp.Ap
8383
EndProject
8484
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestLib3", "tests\FSharp.ApiDocs.Tests\files\TestLib3\TestLib3.fsproj", "{52B949AA-A3F7-4894-B713-804BAEB71118}"
8585
EndProject
86+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SameNameLib", "tests\FSharp.ApiDocs.Tests\files\SameNameLib\SameNameLib.fsproj", "{D1A2B3C4-E5F6-7890-ABCD-EF1234567890}"
87+
EndProject
8688
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csharpSupport", "tests\FSharp.ApiDocs.Tests\files\csharpSupport\csharpSupport.csproj", "{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}"
8789
EndProject
8890
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "crefLib1", "tests\FSharp.ApiDocs.Tests\files\crefLib1\crefLib1.fsproj", "{A0C8DD00-BD08-48D6-B257-5A838E5DA819}"
@@ -196,6 +198,10 @@ Global
196198
{52B949AA-A3F7-4894-B713-804BAEB71118}.Debug|Any CPU.Build.0 = Debug|Any CPU
197199
{52B949AA-A3F7-4894-B713-804BAEB71118}.Release|Any CPU.ActiveCfg = Release|Any CPU
198200
{52B949AA-A3F7-4894-B713-804BAEB71118}.Release|Any CPU.Build.0 = Release|Any CPU
201+
{D1A2B3C4-E5F6-7890-ABCD-EF1234567890}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
202+
{D1A2B3C4-E5F6-7890-ABCD-EF1234567890}.Debug|Any CPU.Build.0 = Debug|Any CPU
203+
{D1A2B3C4-E5F6-7890-ABCD-EF1234567890}.Release|Any CPU.ActiveCfg = Release|Any CPU
204+
{D1A2B3C4-E5F6-7890-ABCD-EF1234567890}.Release|Any CPU.Build.0 = Release|Any CPU
199205
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
200206
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
201207
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -271,6 +277,7 @@ Global
271277
{188DC91F-2202-4495-ACD2-542D7C30364E} = {C7804F57-7FC6-4CF6-BDF6-127D6F9EBEA6}
272278
{FAD5C374-4748-4A3D-A435-FFA425916F3A} = {312E452A-1068-4804-89E7-0AFBAD5F885F}
273279
{52B949AA-A3F7-4894-B713-804BAEB71118} = {4AE0198D-EDE5-40B0-A5CD-FC7B6F891D94}
280+
{D1A2B3C4-E5F6-7890-ABCD-EF1234567890} = {4AE0198D-EDE5-40B0-A5CD-FC7B6F891D94}
274281
{F748A965-C949-4FE7-BFE9-40449F3C58B8} = {8D44B659-E9F7-4CE4-B5DA-D37CDDCD2525}
275282
EndGlobalSection
276283
GlobalSection(ExtensibilityGlobals) = postSolution

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
* Add regression test confirming that types whose name matches their enclosing namespace are correctly included in generated API docs. [#944](https://github.com/fsprojects/FSharp.Formatting/issues/944)
7+
58
## 22.0.0-alpha.2 - 2026-03-13
69

710
### Added

tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,35 @@ CONTENT: All Namespaces"""
18231823
listOfNamespaces
18241824
)
18251825

1826+
[<Test>]
1827+
let ``ApiDocs includes type whose name matches its namespace (issue 944)`` () =
1828+
// Regression test: a type named 'SameNameLib.SameNameLib' was previously missing
1829+
// from the generated API docs when the type name equalled the namespace name.
1830+
let library = testBin </> "SameNameLib.dll"
1831+
let inputs = [ ApiDocInput.FromFile(library) ]
1832+
1833+
let model =
1834+
ApiDocs.GenerateModel(
1835+
inputs,
1836+
collectionName = "SameNameLib",
1837+
substitutions = substitutions,
1838+
libDirs = [ testBin ]
1839+
)
1840+
1841+
let ns = model.Collection.Namespaces |> List.tryFind (fun n -> n.Name = "SameNameLib")
1842+
ns |> Option.isSome |> shouldEqual true
1843+
1844+
let entities = ns.Value.Entities
1845+
1846+
let typeEntity = entities |> List.tryFind (fun e -> e.IsTypeDefinition && e.Name = "SameNameLib")
1847+
1848+
typeEntity |> Option.isSome |> shouldEqual true
1849+
1850+
let typeUrl = typeEntity.Value.UrlBaseName
1851+
1852+
// URL base name must NOT be empty; it distinguishes the type page from the namespace page
1853+
typeUrl |> shouldNotEqual ""
1854+
18261855
let runtest testfn =
18271856
try
18281857
testfn ()

tests/FSharp.ApiDocs.Tests/FSharp.ApiDocs.Tests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<ProjectReference Include="files\TestLib1\TestLib1.fsproj" />
2727
<ProjectReference Include="files\TestLib2\TestLib2.fsproj" />
2828
<ProjectReference Include="files\TestLib3\TestLib3.fsproj" />
29+
<ProjectReference Include="files\SameNameLib\SameNameLib.fsproj" />
2930
</ItemGroup>
3031
<ItemGroup>
3132
<PackageReference Include="FSharp.Core" />
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace SameNameLib
2+
3+
/// <summary>
4+
/// A type whose name is the same as its enclosing namespace.
5+
/// This is a regression test for https://github.com/fsprojects/FSharp.Formatting/issues/944
6+
/// </summary>
7+
type SameNameLib(value: string) =
8+
9+
/// The value stored in this instance
10+
member _.Value = value
11+
12+
/// A static factory method
13+
static member Create(v: string) = SameNameLib(v)
14+
15+
override _.ToString() = value
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<OutputPath>..\bin\$(Configuration)</OutputPath>
6+
<DocumentationFile>..\bin\$(Configuration)\SameNameLib.xml</DocumentationFile>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<Compile Include="Library.fs" />
10+
</ItemGroup>
11+
<ItemGroup>
12+
<PackageReference Include="FSharp.Core" />
13+
</ItemGroup>
14+
</Project>

0 commit comments

Comments
 (0)