Commit c843603
[Repo Assist] fix: ProvidedTypeDefinition.Logger broken (new ref each call); add 5 tests for warning + enum round-trip (#501)
🤖 *This PR was created by [Repo
Assist](https://github.com/githubnext/agentics/blob/main/docs/repo-assist.md),
an automated AI assistant.*
## Summary
This PR bundles a **bug fix** and **new tests** (Task 9: Testing
Improvements).
### Bug fix: `ProvidedTypeDefinition.Logger` was silently broken
The static `Logger` member was implemented as a computed property:
```fsharp
// Before — creates a fresh ref cell on every access; impossible to set
static member Logger: (string -> unit) option ref = ref None
```
Every read of `ProvidedTypeDefinition.Logger` returned a *different*
`ref` object, so calling `ProvidedTypeDefinition.Logger := Some f` would
write into a temporary cell that is immediately discarded. The Logger
was effectively inoperative: the "all static parameters optional"
warning (added in 8.3.0 / PR #428) could never fire via the Logger, and
type-creation trace messages were silently dropped.
**Fix**: introduces a `static let loggerRef` field and makes `Logger`
return it:
```fsharp
static let loggerRef: (string -> unit) option ref = ref None
...
static member Logger: (string -> unit) option ref = loggerRef
```
### New tests (5 tests, 131 total)
**`BasicErasedProvisionTests.fs` — 3 new tests for the all-optional
warning:**
- `DefineStaticParameters warns when all static parameters have
defaults` — regression for the warning path (which was previously
unreachable due to the Logger bug)
- `DefineStaticParameters does not warn when at least one parameter has
no default`
- `DefineStaticParameters does not warn when there are no static
parameters`
**`GenerativeEnumsProvisionTests.fs` — 2 new tests for non-Int32 enum
round-trip via target context:**
- `Byte enum underlying type is correct when read via target context
(ReadRelatedAssembly)` — exercises
`TargetTypeDefinition.GetEnumUnderlyingType()` for a `byte`-backed enum
- `Int64 enum underlying type is correct when read via target context
(ReadRelatedAssembly)` — same for `int64`-backed enums
These complement the existing runtime-path enum tests (`Assembly.Load`)
by covering the design-time IL-reader path, which was fixed in PR
#470/#475.
## Trade-offs
- The Logger ref is now module-level shared state. Tests that manipulate
it should save/restore the previous value (all three new tests do this
via `try/finally`).
## Test Status
✅ All 131 tests pass (`dotnet test
tests/FSharp.TypeProviders.SDK.Tests.fsproj -c Release`)
> Generated by 🌈 Repo Assist, see [workflow
run](https://github.com/fsprojects/FSharp.TypeProviders.SDK/actions/runs/24270385678).
[Learn
more](https://github.com/githubnext/agentics/blob/main/docs/repo-assist.md).
>
> To install this [agentic
workflow](https://github.com/githubnext/agentics/blob/7ee2b60744abf71b985bead4599640f165edcd93/workflows/repo-assist.md),
run
> ```
> gh aw add
githubnext/agentics@7ee2b60
> ```
<!-- gh-aw-agentic-workflow: Repo Assist, engine: copilot, model: auto,
id: 24270385678, workflow_id: repo-assist, run:
https://github.com/fsprojects/FSharp.TypeProviders.SDK/actions/runs/24270385678
-->
<!-- gh-aw-workflow-id: repo-assist -->
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>1 parent b5323d0 commit c843603
3 files changed
Lines changed: 105 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1390 | 1390 | | |
1391 | 1391 | | |
1392 | 1392 | | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
1393 | 1396 | | |
1394 | 1397 | | |
1395 | 1398 | | |
| |||
1940 | 1943 | | |
1941 | 1944 | | |
1942 | 1945 | | |
1943 | | - | |
| 1946 | + | |
1944 | 1947 | | |
1945 | 1948 | | |
1946 | 1949 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| |||
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
0 commit comments