Repository navigation
fix: CodeAnnotations builds its attribute constructions on use, not in static fields - #102
Merged
Merged
Conversation
…n static fields CodeAnnotations held seven AttributeConstruction objects in static readonly fields. An AttributeConstruction belongs to one compilation, and a static field outlives it: at design time, where the IDE keeps Metalama's process across edits, every compilation that filled the fields stays reachable. Gael Fraiteur of Metalama found it reviewing the project (metalama/Metalama discussion 2305); metalama/Metalama#2307 will detect the pattern, and is still open. Each is a static property with an expression body now, so the 78 call sites (AddAttribute(CodeAnnotations.CompilerGenerated) and the like) are unchanged, and so is the generated code: the generated-surface snapshot and the woven probes pass as before. CompileTimeStaticStateTests (conventions) holds every static field of .Generators, and every static auto-property with storage, to an allowlist of durable types: strings, Type, DiagnosticDefinition, and arrays, lists and tuples of those. [Template] members are introduced into the target and hold nothing. With the seven fields restored it fails, naming all seven. Input class: static storage in compile-time code. The test walks every source of .Generators; the other static storage there (the DiagnosticDefinitions, TypedConversionMethods, GeneratedMemberNames) is durable, so there was no sibling to fix. Defect class CRP: what it costs is memory over an IDE session, with no effect on what is generated. Closes #90 Defect-Class: CRP Found-By: OR Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #90
Problem
CodeAnnotationskept seven MetalamaAttributeConstructionobjects instatic readonlyfields. Such an object belongs to one compilation, and a static field outlives it. At design time the IDE keeps Metalama's process across edits, so every compilation that filled the fields stays reachable: a limited memory leak. Gaël Fraiteur of Metalama found it reviewing the project (discussion 2305).Change
CodeAnnotations: each of the seven is a static property with an expression body now, which builds the construction where it is used. The 78 call sites (AddAttribute(CodeAnnotations.CompilerGenerated)and the like) are unchanged.CompileTimeStaticStateTests(conventions): every static field of.Generators, and every static auto-property with storage, holds an allowlisted durable type: strings,Type,DiagnosticDefinition, and arrays, lists and tuples of those.[Template]members are skipped, since Metalama introduces them into the target.Metalama's own detector for the pattern (metalama/Metalama#2307) is still open, so the build cannot use it yet.
Tests
[Template]fields, constants, instance fields)..Generators. The other static storage there is durable, so there was no sibling to fix.🤖 Generated with Claude Code