Skip to content

Failed to open project file larger than 2MiB #137

@absindx

Description

@absindx

Thank you for the great software.
I will report on my friend's findings instead.

JavaScriptSerializer is limited to string length equivalent to UTF-8 2MiB by default.
It checks if the JSON string fits within JavaScriptSerializer.MaxJsonLength and throws an exception if it exceeds. (Default value is DefaultMaxJsonLength = 2097152)
https://referencesource.microsoft.com/#System.Web.Extensions/Script/Serialization/JavaScriptSerializer.cs,76352a505a3d40a3,references

When outputting a file, line break is added after braces and commas,
but if this process exceeds 2MiB, a "project file that could be saved but cannot be opened" is created.

public static bool SerializeToFile(DisasmProject proj, string pathName,
out string errorMessage) {
try {
string serializedData = SerializableProjectFile1.SerializeProject(proj);
if (ADD_CRLF) {
// Add some line breaks. This looks awful, but it makes text diffs
// much more useful.
serializedData = TextUtil.NonQuoteReplace(serializedData, "{", "{\r\n");
serializedData = TextUtil.NonQuoteReplace(serializedData, "},", "},\r\n");
serializedData = TextUtil.NonQuoteReplace(serializedData, ",", ",\r\n");
}

SourceGen can currently open and analyze files as large as 1MiB,
so adding tags and comments to the whole area is likely to hit the limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions