Skip to content

perf: index reflection metadata and cache security lookups in TypeGenerator - #53

Merged
R-unic merged 1 commit into
masterfrom
perf/typegenerator-hotpaths
Jul 24, 2026
Merged

perf: index reflection metadata and cache security lookups in TypeGenerator#53
R-unic merged 1 commit into
masterfrom
perf/typegenerator-hotpaths

Conversation

@R-unic

@R-unic R-unic commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • ReflectionMetadataReader now indexes the metadata XML once (class name -> element, then member name -> element per class) instead of running a full-document XPath // scan on every class/member description lookup.
  • ClassUtility.GetSecurity results are now memoized per member instance instead of re-deserializing the same JSON on every CanRead/CanWrite call.
  • ClassGenerator.GenerateParameter's Instance-type candidate list is built once instead of re-running the Concat+Where LINQ chain against all ~400 class names per parameter.
  • Minor: HasMatchingSuperclass/HasTag avoid an extra LINQ allocation per call.

Test plan

  • dotnet build — succeeds, no warnings
  • dotnet test — 1778/1778 pass
  • Verified generated output is unchanged (this is a pure performance refactor)

🤖 Generated with Claude Code

…erator

Description lookups scanned the entire metadata XML document with an
unindexed XPath query per class/member; security lookups re-deserialized
the same JSON on every CanRead/CanWrite call. Both are now indexed/cached
once. Output is unchanged.
@R-unic
R-unic merged commit c7f4e84 into master Jul 24, 2026
1 of 2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Loom Release 1.0.0 Jul 24, 2026
@R-unic
R-unic deleted the perf/typegenerator-hotpaths branch July 24, 2026 08:46
@github-actions

Copy link
Copy Markdown

Qodana for .NET

257 new problems were found

Inspection name Severity Problems
Auto-property accessor is never used (private accessibility) 🔶 Warning 6
Auto-property accessor is never used (non-private accessibility) 🔶 Warning 5
Non-accessed positional property (non-private accessibility) 🔶 Warning 4
Redundant using directive 🔶 Warning 3
Redundant argument with default value 🔶 Warning 2
'??' condition is never null according to nullable reference types' annotations 🔶 Warning 1
Private field can be converted into local variable 🔶 Warning 1
Redundant name qualifier 🔶 Warning 1
Redundant nullable warning suppression expression 🔶 Warning 1
Type member is never used (private accessibility) 🔶 Warning 1
Unused parameter (private accessibility) 🔶 Warning 1
Unused local variable 🔶 Warning 1
Type member is never used (non-private accessibility) ◽️ Notice 93
Use preferred style of 'new' expression when created type is not evident ◽️ Notice 83
Member can be made private (non-private accessibility) ◽️ Notice 18
Class is never instantiated (non-private accessibility) ◽️ Notice 4
Some values of the enum are not processed inside 'switch' statement ◽️ Notice 4
Auto-property can be made get-only (non-private accessibility) ◽️ Notice 3
Invert 'if' statement to reduce nesting ◽️ Notice 3
RoslynAnalyzers The member referenced by the MemberData attribute returns untyped data rows ◽️ Notice 3
Use preferred style for trailing comma before new line in multiline lists ◽️ Notice 2
RoslynAnalyzers Do not use Enumerable methods on indexable collections ◽️ Notice 2
Dictionary lookup can be simplified with 'TryAdd' ◽️ Notice 2
Remove redundant parentheses ◽️ Notice 1
Auto-property can be made get-only (private accessibility) ◽️ Notice 1
RoslynAnalyzers Use concrete types when possible for improved performance ◽️ Notice 1
'if-return' statement can be rewritten as 'return' statement ◽️ Notice 1
Foreach loop can be converted into LINQ-expression but another 'GetEnumerator' method will be used ◽️ Notice 1
Merge null/pattern checks into complex pattern ◽️ Notice 1
Redundant string interpolation ◽️ Notice 1
Replace with 'field' keyword ◽️ Notice 1
Some values of the enum are not processed inside 'switch' statement and are handled via default section ◽️ Notice 1
Tail recursive call can be replaced with loop ◽️ Notice 1
Type member is never accessed via base type (non-private accessibility) ◽️ Notice 1
Method return value is never used (non-private accessibility) ◽️ Notice 1
Literal length can be reduced by using verbatim string ◽️ Notice 1

☁️ View the detailed Qodana report

Detected 1 dependency

Third-party software list

This page lists the third-party software dependencies used in Loom

Dependency Version Licenses
Tomlyn 2.6.0 BSD-2-Clause
Contact Qodana team

Contact us at qodana-support@jetbrains.com

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.

1 participant