Skip to content

[Repo Assist] Fix IONIDE-012 code scanning alerts: add [(Struct)] to discriminated unions#1053

Merged
dsyme merged 2 commits intomainfrom
repo-assist/fix-struct-du-code-scanning-alerts-f419fe2f4d4cd1b0
Feb 28, 2026
Merged

[Repo Assist] Fix IONIDE-012 code scanning alerts: add [(Struct)] to discriminated unions#1053
dsyme merged 2 commits intomainfrom
repo-assist/fix-struct-du-code-scanning-alerts-f419fe2f4d4cd1b0

Conversation

@github-actions
Copy link
Contributor

🤖 This pull request was created by Repo Assist, an automated AI assistant.

Summary

Fixes two open code scanning alerts (IONIDE-012) by adding the [(Struct)] attribute to two small discriminated unions in FSharp.Formatting.Literate.

Changes

src/FSharp.Formatting.Literate/Document.fs

  • Added [(Struct)] to LiterateCodeVisibility — a 3-case DU (VisibleCode, HiddenCode, NamedCode of string) that is a good fit for struct representation since it's small and used as a value.

src/FSharp.Formatting.Literate/Transformations.fs

  • Added [(Struct)] to EvalKey — a 2-case DU (OutputRef of string, ValueRef of string) used as keys in an F# Map. Named the fields explicitly (outputName, valueName) as required for struct DUs with fields.

Motivation

Struct DUs avoid heap allocations for small types, improving GC pressure. The Ionide.Analyzers IONIDE-012 rule flags DUs that meet the criteria for struct representation.

Test Status

✅ Build: dotnet build src/FSharp.Formatting.Literate/FSharp.Formatting.Literate.fsproj --configuration Releasepassed with 0 warnings, 0 errors

Full test suite was not run (build-only validation performed as the change is purely additive). CI will run the full suite.

Generated by Repo Assist

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@afb00b92a9514fee9a14c583f059a03d05738f70

…ions

Fix code scanning alerts IONIDE-012: add [<Struct>] attribute to improve
performance by avoiding heap allocations for small discriminated unions.

- LiterateCodeVisibility (Document.fs): simple enum-like DU with one
  case carrying a single string field, ideal for struct representation
- EvalKey (Transformations.fs): two-case DU used as Map keys, benefits
  from value semantics

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review February 28, 2026 11:50
@dsyme dsyme merged commit 32db0f5 into main Feb 28, 2026
4 checks passed
@dsyme dsyme deleted the repo-assist/fix-struct-du-code-scanning-alerts-f419fe2f4d4cd1b0 branch February 28, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant