Skip to content

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

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-struct-du-code-scanning-alerts-f419fe2f4d4cd1b0
Draft

[Repo Assist] Fix IONIDE-012 code scanning alerts: add [(Struct)] to discriminated unions#1053
github-actions[bot] wants to merge 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 <[email protected]>
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.

0 participants