Skip to content

Fix shared generator and serializer failure modes - #146

Merged
matt-edmondson merged 5 commits into
mainfrom
copilot/fix-shared-preamble-bug-cluster
Oct 2, 2026
Merged

matt-edmondson merged 5 commits into
mainfrom
copilot/fix-shared-preamble-bug-cluster

Conversation

Copilot AI commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Shared gaps in preamble handling, comment emission, YAML deserialization, and type inference caused declarations or values to be dropped, corrupted, or emitted as invalid code.

  • Serialization: Add typed YAML readers for blank and null scalars; serialize annotation arguments structurally while continuing to read legacy annotations; compare annotations structurally.
  • Generator consistency: Route declaration preambles through a conservation-checked writer, and split caller-supplied comment text into safe comment lines.
  • Literal vocabulary: Centralize supported literal storage types and use them across inspector fields, captions, serialization, and generation.
  • Python and JavaScript: Accept complete import statements; add Python’s enum import and move mutable instance initializers into constructors, synthesizing one when needed.
  • Go: Infer conditional result types from annotations, literals, constructions, branches, and function scopes; recursively lower nested statement conditionals.

Annotation arguments now serialize as structured YAML while argument-free annotations remain scalar:

annotations:
  - name: SuppressMessage
    arguments:
      - '"Usage"'
      - '"CA2225"'

Copilot AI and others added 2 commits October 1, 2026 10:08
Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
public void LanguageGeneratorsDoNotBuildCommentPrefixesAroundCallerText()
{
string directory = FindRepositoryRoot();
foreach (string path in Directory.GetFiles(Path.Combine(directory, "Coder", "Languages"), "*.cs"))
{
for (DirectoryInfo? directory = new(AppContext.BaseDirectory); directory is not null; directory = directory.Parent)
{
if (Directory.Exists(Path.Combine(directory.FullName, "Coder", "Languages")))
Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Comment on lines +610 to +617
foreach (string import in required)
{
if (SpellImport(import) is string spelled)
{
code.WriteLine(spelled);
wroteImport = true;
}
}
Comment on lines +86 to +92
foreach (Parameter parameter in function.Parameters)
{
if (parameter.Name is string name && parameter.Type is TypeReference type)
{
types[name] = type;
}
}
Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
}

if (field.InitialValue is not null)
if (field.InitialValue is not null && instanceInitialisedFields?.Contains(field) != true)
public void Deserializer_UsesTypedReadersForScalars()
{
string root = FindRepositoryRoot();
string source = File.ReadAllText(Path.Combine(root, "Coder", "Serialization", "YamlDeserializer.cs"));
{
for (DirectoryInfo? directory = new(start); directory is not null; directory = directory.Parent)
{
if (File.Exists(Path.Combine(directory.FullName, "Coder", "Serialization", "YamlDeserializer.cs")))
Copilot AI changed the title [WIP] Fix the #130–#137 generator/serializer cluster Fix shared generator and serializer failure modes Oct 1, 2026
Copilot AI requested a review from matt-edmondson October 1, 2026 10:43
@matt-edmondson
matt-edmondson marked this pull request as ready for review October 2, 2026 03:52
@matt-edmondson
matt-edmondson merged commit a9a8e47 into main Oct 2, 2026
7 checks passed
@matt-edmondson
matt-edmondson deleted the copilot/fix-shared-preamble-bug-cluster branch October 2, 2026 03:53
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

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.

Fix the #130–#137 generator/serializer cluster by cause: shared preamble, comment writer, typed YAML reads, and literal vocabulary

2 participants