Skip to content

Commit 0c463cd

Browse files
kMutageneclaude
andcommitted
refactor(FileFormats): clean up xscgen-generated type names via --tnsf
Auto-generated type names were verbose due to PascalCase + parent-chain concatenation (e.g. ProjectTypeRelatedProjectsRelatedProjectChildProject). Adopt a mechanical naming convention via xscgen --tnsf: A) Top-level <X>Type -> <X> (ProjectType -> Project) B) Set container <X>SetType -> <X>Set (ProjectSetType -> ProjectSet) C) Enum prefix Type<X> -> <X> (TypeIlluminaModel -> IlluminaModel) special: Type454Model -> Model454 (digit prefix would be invalid) D) Child <Parent>Type<rest> -> <Parent><rest> (mechanical infix strip) Three names skipped to avoid collisions with existing distinct classes (EntrySetType vs anonymous EntrySet root; TaxonSetType vs TaxonSet; IdExtIdType vs sibling IdExtId). The 267 substitutions are committed in src/BioFSharp.FileFormats.INSDC/schemas/typename-substitutions.txt and passed to xscgen via --tnsf from the regenerateInsdcTypes FAKE target. Regeneration produces the same 280 files, just under cleaner names; the EmblXrefType local XSD patch is still required (the PascalCase collision it resolves happens during schema merge, before --tns runs). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 86fdbb6 commit 0c463cd

414 files changed

Lines changed: 6128 additions & 5843 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎build/BasicTasks.fs‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,24 @@ let clean = BuildTask.create "Clean" [] {
2121
// Run after touching schemas/ (or after pinning a new dotnet-xscgen version in .config/dotnet-tools.json).
2222
//
2323
// Flag choices:
24-
// --separateFiles : one .cs per generated class (cleaner diffs than a single 15k-line file)
25-
// -n BioFSharp.FileFormats.INSDC : map the default XML namespace to the package's C# namespace
26-
// -0 (--nullable) : nullable adapter properties for optional elements w/o defaults (needed for roundtrips)
27-
// -i l : map xs:integer to System.Int64
28-
//
29-
// TODO: future polish — add --tns / --tnsf substitutions to clean up the cross-schema namespace surface
30-
// and remove the local rename hack in schemas/ENA.embl.xsd (see schemas/README.md).
24+
// --separateFiles : one .cs per generated class (cleaner diffs than a single 15k-line file)
25+
// -n <ns> : map the default XML namespace to the package's C# namespace
26+
// -0 (--nullable) : nullable adapter properties for optional elements w/o defaults (needed for roundtrips)
27+
// -i l : map xs:integer to System.Int64
28+
// --tnsf <file> : substitute generated type names per schemas/typename-substitutions.txt
29+
// (strips the Type infix from top-level + child types; cleans Type* enum prefixes)
3130
let regenerateInsdcTypes = BuildTask.create "regenerateInsdcTypes" [] {
32-
let schemasDir = "src/BioFSharp.FileFormats.INSDC/schemas"
33-
let generatedDir = "src/BioFSharp.FileFormats.INSDC/Generated"
31+
let schemasDir = "src/BioFSharp.FileFormats.INSDC/schemas"
32+
let generatedDir = "src/BioFSharp.FileFormats.INSDC/Generated"
33+
let substitutionFile = schemasDir + "/typename-substitutions.txt"
3434
Shell.cleanDir generatedDir
3535
let schemaArgs =
3636
!! (schemasDir + "/*.xsd")
3737
|> Seq.map (fun p -> sprintf "\"%s\"" p)
3838
|> String.concat " "
3939
let args =
40-
sprintf "--separateFiles -n BioFSharp.FileFormats.INSDC -0 -i l -o \"%s\" %s" generatedDir schemaArgs
40+
sprintf "--separateFiles -n BioFSharp.FileFormats.INSDC -0 -i l --tnsf \"%s\" -o \"%s\" %s"
41+
substitutionFile generatedDir schemaArgs
4142
let result = DotNet.exec id "xscgen" args
4243
if not result.OK then
4344
failwithf "dotnet xscgen failed (exit %d): %A" result.ExitCode result.Errors

‎plans/implementation.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This repo ships two packages that together give BioFSharp users an INSDC (Intern
99

1010
The naming mirrors the base `BioFSharp` namespace layout so both packages can be picked up directly as dependencies of `BioFSharp`. Both target `netstandard2.0` for parity with the rest of the BioFSharp ecosystem.
1111

12-
## 1. Pre-flight cleanup (template residue)
12+
## 1. [x] Pre-flight cleanup (template residue)
1313

1414
The repo was scaffolded from the `BioFSharp.XYZ` template and still carries placeholder content that must be cleared before the real work lands:
1515

@@ -20,7 +20,7 @@ The repo was scaffolded from the `BioFSharp.XYZ` template and still carries plac
2020
- `tests/BioFSharp.INSDC.Tests/Tests.fs` still references `BioFSharp.XYZ.BioTalk` — drop the test, replace with INSDC tests (section 5).
2121
- `docs/index.fsx` is left as-is (no docs site for this repo). Confirm `docs/img/icon.png` exists so `pack` does not fail.
2222

23-
## 2. `BioFSharp.FileFormats.INSDC` (C# type model)
23+
## 2. [x] `BioFSharp.FileFormats.INSDC` (C# type model)
2424

2525
### Project conversion (F# → C#)
2626

@@ -70,7 +70,7 @@ Do **not** wire generation into every build — the generated `.cs` files are co
7070

7171
Contributors run `build.cmd regenerateInsdcTypes` (or `build.sh regenerateInsdcTypes`) **only when schemas change**. `buildSolution` does *not* depend on this target.
7272

73-
## 3. `BioFSharp.IO.INSDC` (F# IO wrapper)
73+
## 3. [ ] `BioFSharp.IO.INSDC` (F# IO wrapper)
7474

7575
### Module files
7676

@@ -110,7 +110,7 @@ module BioProject =
110110
- `BioFSharp.IO.INSDC.fsproj` adds a `<ProjectReference>` to `BioFSharp.FileFormats.INSDC.csproj`.
111111
- Project metadata (`Authors`, `Description`, repo URLs) retargeted to `BioFSharp.INSDC`.
112112

113-
## 4. Tests (`BioFSharp.INSDC.Tests`)
113+
## 4. [ ] Tests (`BioFSharp.INSDC.Tests`)
114114

115115
### Test files
116116

@@ -137,13 +137,13 @@ Real ENA records, downloaded once and committed:
137137

138138
Tests load fixtures off disk via a small relative-path helper. No network at test time.
139139

140-
## 5. Build / CI touch-ups
140+
## 5. [ ] Build / CI touch-ups
141141

142142
- Confirm `build/ProjectInfo.fs` `solutionFile` resolves (already `BioFSharp.INSDC.slnx`).
143143
- Verify `build.cmd` / `build.sh` entry points still work after the `.fsproj` → `.csproj` swap in the slnx.
144144
- Add the `regenerateInsdcTypes` target. It must not be chained into the default build — generated code is committed precisely so contributors can build without the tool restored.
145145

146-
## 6. Verification
146+
## 6. [ ] Verification
147147

148148
Each step gates the next:
149149

src/BioFSharp.FileFormats.INSDC/Generated/BioFSharp.FileFormats.INSDC/TypeAbiSolidModel.cs renamed to src/BioFSharp.FileFormats.INSDC/Generated/BioFSharp.FileFormats.INSDC/AbiSolidModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
//------------------------------------------------------------------------------
99

1010
// This code was generated by XmlSchemaClassGenerator version 3.0.1270.0 using the following command:
11-
// xscgen --separateFiles -n BioFSharp.FileFormats.INSDC -0 -i l -o src/BioFSharp.FileFormats.INSDC/Generated G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\EGA.dac.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\EGA.dataset.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\EGA.policy.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.assembly.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.checklist.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.embl.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.project.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.root.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.sample_group.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.taxonomy.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.webin.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.analysis.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.common.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.experiment.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.receipt.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.run.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.sample.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.study.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.submission.xsd
11+
// xscgen --separateFiles -n BioFSharp.FileFormats.INSDC -0 -i l --tnsf src/BioFSharp.FileFormats.INSDC/schemas/typename-substitutions.txt -o src/BioFSharp.FileFormats.INSDC/Generated G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\EGA.dac.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\EGA.dataset.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\EGA.policy.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.assembly.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.checklist.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.embl.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.project.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.root.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.sample_group.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.taxonomy.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\ENA.webin.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.analysis.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.common.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.experiment.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.receipt.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.run.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.sample.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.study.xsd G:\source\repos\BioFSharp\BioFSharp.INSDC\src\BioFSharp.FileFormats.INSDC\schemas\SRA.submission.xsd
1212
namespace BioFSharp.FileFormats.INSDC
1313
{
1414

1515

1616
[System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator", "3.0.1270.0")]
1717
[System.SerializableAttribute()]
1818
[System.Xml.Serialization.XmlTypeAttribute("typeAbiSolidModel", Namespace="SRA.common")]
19-
public enum TypeAbiSolidModel
19+
public enum AbiSolidModel
2020
{
2121

2222
/// <summary>

0 commit comments

Comments
 (0)