You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The project file is currently serialized and deserialized with JavaScriptSerializer from System.Web.Script.Serialization. This is an older library that lacks some features, which is why the SourceGen implementation does a series of text substitutions to add line breaks. These are useful because they make the file easier to read by humans, and provide better diffs in source code control systems.
System.Text.Json.JsonSerializer is the new & improved version; I've been using it in another project and it seems to work well. It appears to be available in .NET Framework. (Update: according to this, it must be added as a NuGet package until .NET Core 3.0, and may require 4.7.2.) It provides a WriteIndented property that produces nicely-formatted output without the clumsy text replacement.
While messing around with this it would also be good to investigate the "exclude default values" options, which would avoid storing unnecessary assignments, like null strings. This should be backward-compatible with older versions of SourceGen because the deserialization structs are initialized to defaults. Enabling this should make the project files slightly smaller. Start with JsonSerializerOptions.DefaultIgnoreCondition set to WhenWritingNull.
The JSON format is used in a number of places:
project files (*.dis65)
application settings (SourceGen-settings); values for some individual settings are serialized with JSON because it was a convenient way to store multiple items:
assembler configurations
list of recent projects
pseudo-op name overrides
the daily tips definition file
system definitions for new projects (RuntimeData/SystemDefs.json)
SGEC comment exports
The text was updated successfully, but these errors were encountered:
fadden
changed the title
Update javascript serializer
Update JSON serializer
Jun 1, 2024
The project file is currently serialized and deserialized with
JavaScriptSerializer
fromSystem.Web.Script.Serialization
. This is an older library that lacks some features, which is why the SourceGen implementation does a series of text substitutions to add line breaks. These are useful because they make the file easier to read by humans, and provide better diffs in source code control systems.System.Text.Json.JsonSerializer
is the new & improved version; I've been using it in another project and it seems to work well. It appears to be available in .NET Framework. (Update: according to this, it must be added as a NuGet package until .NET Core 3.0, and may require 4.7.2.) It provides aWriteIndented
property that produces nicely-formatted output without the clumsy text replacement.While messing around with this it would also be good to investigate the "exclude default values" options, which would avoid storing unnecessary assignments, like null strings. This should be backward-compatible with older versions of SourceGen because the deserialization structs are initialized to defaults. Enabling this should make the project files slightly smaller. Start with
JsonSerializerOptions.DefaultIgnoreCondition
set toWhenWritingNull
.The JSON format is used in a number of places:
*.dis65
)SourceGen-settings
); values for some individual settings are serialized with JSON because it was a convenient way to store multiple items:RuntimeData/SystemDefs.json
)The text was updated successfully, but these errors were encountered: