kekekeks / XamlX

General purpose pluggable XAML compiler with no runtime dependencies.
MIT License
319 stars 55 forks source link

[Question] Serializze AST #97

Closed workgroupengineering closed 1 month ago

workgroupengineering commented 1 year ago

Do you have any examples of how to sterilize the AST? I tried with System.Text.Json but I get empty files.

workgroupengineering commented 1 year ago

Any suggestions?

I was thinking of creating a class that takes advantage of the Visitor pattern. Do you think it could work?

I would like to use the AST inside AvaloniaVS instead of Avalonia.Ide.CompletionEngine but keep the decoupling from the Avalonia version.

Using the ASTA in Avalonia VS would allow you to make the Itellisense more intelligent with:

kekekeks commented 1 year ago

Avalonia.Ide.CompletionEngine is supposed to be reusable between VS extension and VSCode extension. AvaloniaVS is supposed to only provide the glue between the engine and the IDE. So ideally the code has to be structured in a way that could be reused by a different IDE.

kekekeks commented 1 year ago

As of serialization, I think JSON.NET supports cyclic references.

workgroupengineering commented 1 year ago

As of serialization, I think JSON.NET supports cyclic references.

I already tried but tried, but it gives me OutOfMemoryException.

Avalonia.Ide.CompletionEngine is supposed to be reusable between VS extension and VSCode extension. AvaloniaVS is supposed to only provide the glue between the engine and the IDE. So ideally the code has to be structured in a way that could be reused by a different IDE.

The idea is to implement an LSP so that the logic can be shared with all IDEs that support this standard.

kekekeks commented 1 year ago

1) new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects } 2) special converters for types from IXamlTypeSystem