Skip to content

Conversation

@pkamphuis
Copy link
Contributor

I did some major rework on the Generator and migrated all projects to .net 10 only.
This includes a.o,

  • improved type support
  • use polymorphic json serialization for e.g. Series
  • clearer separation of hand code and generated files
  • regenerated based on echarts 5.6.0

I know this is a major deviation of the current project state. Are you interested in these changes, and consider a merge? I prefer a continuation on your original project. My alternative is disconnect the fork and continue and publish my own version?

@bmotmans
Copy link
Contributor

bmotmans commented Jan 3, 2026

Thanks for your contributions. I'm very much interested in merging your work. I have 2 busy weeks at works, afterwards I have some free time to spend on this project.

If you are interested, I can give you access to the repository so that you can contribute directly.

pkamphuis and others added 29 commits January 3, 2026 16:33
* update projects to .net 10 and use global.json
* add improvements plan copilot instructions
* make vizor-echarts ES6 compliant
* add mstest project using microsoft test platform
* phase 1 of code generator improvement

* fixed warnings

* phase 2 of generator improvement

* phase 3 of generation improvement
* add editorconfig

* fix formatting tabs to spaces and utf-8 encoding
…eight NumberOrString support

- TypeCollection.MapArrayType: Added special cases for Series→ISeries and DataZoom→IDataZoom
  * Moved switch statement BEFORE ItemType check to ensure precedence
  * Uses parent.DotNetType for type matching (parent.Name is empty for root)
  * Eliminates List<object> in favor of typed interfaces

- BasePhase.MapType: Added special case for Detail.Width and Detail.Height
  * Maps to NumberOrString type to support both numeric and percentage values
  * Generator now produces correct types without manual post-generation fixes

- ChartOptions.cs: Regenerated with List<ISeries> and List<IDataZoom>
- Detail.cs: Regenerated with NumberOrString for Width/Height properties

Build errors reduced from 82 to 81.
Attempted #3 (conditional compilation) but discovered it doesn't work because:
- Generator needs typeof() on Vizor.ECharts utility types (Color, NumberOrString)
- Hand-coded series classes reference generated types (Emphasis, Blur, Select, etc.)
- Generated files are mixed across folders with hand-coded files

Recommends:
1. Accept #5 (git-checked files) - already the current state
2. Implement #6 (Abstractions layer) - clean architectural fix
3. Future #4 (standalone tool) - complete decoupling

See doc/Circular_Dependency_Solutions.md for full analysis.
…flow

- Updated Circular_Dependency_Solutions.md to clarify hand-tuned overrides are intentional
- Expanded BindingGenerator/Readme.md with detailed hand-tuning pattern explanation
- Enhanced copilot-instructions.md with:
  * Corrected folder names (GenOptions → Options/Generated, GenSeries → Series/Generated)
  * Updated command with proper dotnet run syntax
  * New 'Hand-Tuned Overrides Pattern' section explaining:
    - How generated vs. hand-maintained files differ
    - How to identify each type
    - When and why hand-tuning is necessary
    - Maintenance requirements

Example: Series/Sankey/SankeySeriesLevel.cs (singular, hand-coded) vs.
         Series/Generated/Sankey/SankeySeriesLevels.cs (plural, auto-generated)
…perty nullability

- Make Type property non-nullable and init-only across all series/options
  - Fixes all 24 CS8766 nullability warnings by matching ISeries/IDataZoom interfaces
  - Prevents accidental type changes post-initialization

- Automate enum-or-function pattern (FunnelSeries.Sort, SunburstSeries.Sort)
  - Generator creates three-property pattern: SortObject (internal backing), Sort (enum accessor), SortFunction (function accessor)
  - Matches existing Grid/GridList single-or-array pattern
  - Both patterns now use internal backing with [JsonInclude] for serialization

- Fix enum mapping lookup in type resolution
  - Use parent.DotNetType instead of parent.Name for context-aware enum resolution
  - Critical for patterns that accept multiple enum types (e.g., sort property)

- Refactor enum+function pattern detection order
  - Check enum+function BEFORE pattern registry (not after)
  - Ensures early enum mapping skip for complex patterns

- Use internal access modifier with InternalsVisibleTo for balanced API design
  - Clean public API (only typed accessors visible externally)
  - Testable internal structure (tests can verify backing fields)
  - Standard C# pattern for this use case

Changes:
- BasePhase.cs: Add enum+function early detection, fix enum lookup with parent.DotNetType
- TypeCollection.cs: Add sort property enum mappings for FunnelSeries/SunburstSeries
- ObjectTypeClassGenerator.cs: Change backing fields to internal with [JsonInclude]
- AssemblyInfo.cs: Add InternalsVisibleTo attribute for test assembly access
- All generated series/options: Regenerated with new patterns

Verification:
- Type property: Non-nullable, init-only (matches ISeries/IDataZoom contracts)
- FunnelSeries: Sort, SortObject, SortFunction properties auto-generated
- SunburstSeries: Sort, SortObject, SortFunction properties auto-generated
- ChartOptions: Grid, GridList; XAxis, XAxisList; YAxis, YAxisList (single-or-array pattern)
- ChartOptions: Parallel, ParallelList; Calendar, CalendarList; Dataset, DatasetList
- ChartOptions: SingleAxis, SingleAxisList (single-or-array pattern)

Metrics: 10 errors fixed (67 → 57), 24 CS8766 warnings eliminated
- Convert CellSize from class to record for immutability and cleaner syntax
- Add dual constructors: CellSize(both) for same dimensions, CellSize(width, height) for asymmetric
- Add implicit operator: NumberOrString → CellSize (single value applies to both)
- Add implicit operator: CellSize → NumberOrNumberArray (for property assignment)

Benefits:
- Immutable value type better represents dimension pairs
- Implicit converters eliminate 6 compilation errors
- More idiomatic C# using records
- Better documentation clarifying Width/Height semantics

Impact: 57 → 54 errors (CS0029: 84 → 78)
… names

- Added Helper.Singularize() method to convert plural property names to singular
- Updated BasePhase.cs to singularize property names when creating array item types
  - 'links' → 'link': GraphSeriesLink instead of GraphSeriesLinks
  - 'levels' → 'level': SankeySeriesLevel instead of SankeySeriesLevels
  - Special case: 'series' remains 'series' (invariant)
- Fixed TypeCollection.cs hard-coded mappings to use singular names
- Deleted old plural class files that are no longer generated
- Refactored generator tests to use direct property access instead of reflection
- Tests: 86 passing (up from 79), main library compiles with 2 warnings only

This fixes the root cause of the naming collision where generator was creating
'List of plurals' (List<GraphSeriesLinks>) instead of 'List of singulars'
(List<GraphSeriesLink>), aligning with ECharts spec and API expectations.
- Change Dataset.Dimensions and Series.Dimensions from List<object>? to string[]
- Change ContinuousVisualMap.Text and PiecewiseVisualMap.Text from List<object>? to string[]
- Change all Series.Data properties from strongly typed SeriesDataList<T> to flexible object?
  - Allows JavascriptFunction, dynamic arrays, and dataset references per ECharts spec
- Fix VisualMap implicit operators to avoid CS8603 null warnings
- Document future strong typing plan for dimensions in doc/Dimensions_Strong_Typing_Improvement.md
- Update generator TypeCollection to handle these special cases

Resolves issues with:
- Type safety for simple string array properties
- Flexibility for complex dynamic data scenarios
- Sample compilation errors from overly restrictive typing
…ren, and Geo.LayoutCenter

- ParallelAxis in ChartOptions: Generate as List<ParallelAxis> instead of singular property
- TreemapSeriesData.Children: Generate as List<TreemapSeriesData> for recursive structure
- Geo.LayoutCenter: Map to NumberOrStringArray instead of List<object>
- Selected: Restore as hand-tuned override inheriting from Dictionary<string, bool>

All special cases handled via BasePhase.cs property type resolution checks.
Selected uses hand-tuned override pattern (outside Generated folder) for sustainability.
- TreeSeries.Data property now accepts object? for flexibility with various data structures
- Matches TreemapSeries.Data pattern which also uses object?
- Reduces sample compilation errors by 1 (TreeLeftToRightChart error fixed)
…tern

- Dataset.transform now generates three properties like Grid/GridList:
  1. TransformObject - internal backing field for JSON serialization
  2. Transform - single IDatasetTransform accessor
  3. TransformList - list of IDatasetTransform accessor
- Follows same pattern as Grid/GridList for single-or-array semantics
- Reduces sample compilation errors from 11 → 10
- RadarSeriesData.Value can now accept int[], double[], or single numbers
- Matches radar chart's multi-dimensional data representation
- Reduces sample compilation errors from 10 → 8
- MagicType.Type should hold array of chart type names as string[]
- Matches toolbox magic type selection semantics
- Reduces sample compilation errors from 8 → 7
- Label.Rotate can now accept numeric rotation angles or string values like 'radial'
- Matches sunburst and other chart label rotation semantics
- Reduces sample compilation errors from 7 → 6
- Created generic PolymorphicInterfaceGenerator for auto-generating polymorphic interfaces
- Auto-generate IDataZoom with JsonPolymorphic and JsonDerivedType attributes
- Auto-generate ISeries using new generic generator
- Updated ObjectTypeClassGenerator to skip Type property for DataZoom classes
- Removed hand-coded IDataZoom and ISeriesInterfaceGenerator (replaced by generic version)
- Type discriminator automatically added during serialization by .NET 10

Both ISeries and IDataZoom now stay in sync with generated types on every regeneration.
@pkamphuis
Copy link
Contributor Author

I am glad to hear. I fixed up the PR so it could be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants