When opening a namespace that contains a type annotated with [<AutoOpen>], the open is identified as being unused even when the static members of the type are referenced.
Here is a test that triggers the diagnostic: main...joprice:fsharp:autoOpenType
From a quick inspection of the code, I would guess this has to do with this guard, which only checks for declarations in namespaces and modules, but not static type members:
|
| Some entity when entity.IsNamespace || entity.IsFSharpModule -> |
Expected behavior
Unused open analysis should behave with respect to [<AutoOpen>] for types as it does for modules.
Actual behavior
The open is marked as unused, even though removing it causes the file to fail to compile.
Known workarounds
Fully qualify the member access.
When opening a namespace that contains a type annotated with
[<AutoOpen>], the open is identified as being unused even when the static members of the type are referenced.Here is a test that triggers the diagnostic: main...joprice:fsharp:autoOpenType
From a quick inspection of the code, I would guess this has to do with this guard, which only checks for declarations in namespaces and modules, but not static type members:
fsharp/src/Compiler/Service/ServiceAnalysis.fs
Line 284 in a7b1303
Expected behavior
Unused open analysis should behave with respect to
[<AutoOpen>]for types as it does for modules.Actual behavior
The open is marked as unused, even though removing it causes the file to fail to compile.
Known workarounds
Fully qualify the member access.