Skip to content

[Dependency] source generator#6549

Merged
PJB3005 merged 6 commits intospace-wizards:masterfrom
PJB3005:26-05-04-ioc-source-gen
May 8, 2026
Merged

[Dependency] source generator#6549
PJB3005 merged 6 commits intospace-wizards:masterfrom
PJB3005:26-05-04-ioc-source-gen

Conversation

@PJB3005
Copy link
Copy Markdown
Member

@PJB3005 PJB3005 commented May 5, 2026

No more reflection, no more codegen at runtime

Also various changes to Roslyn helpers to make this easier to write.

Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code for now as a fallback.

No fallback is available for [field: Dependency] properties, due to a Roslyn bug.

Code Fixes exist. We love Roslyn

@PJB3005 PJB3005 requested a review from DrSmugleaf as a code owner May 5, 2026 01:32
@PJB3005 PJB3005 added T: Performance Type: Performance problem or optimization T: Refactor Type: Code refactor labels May 5, 2026
No more reflection, no more codegen at runtime

Also various changes to Roslyn helpers to make this easier to write.

Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback.

No fallback is available for [field: Dependency] properties, due to a Roslyn bug.

Code Fixes exist. We love Roslyn
@PJB3005 PJB3005 force-pushed the 26-05-04-ioc-source-gen branch from a5f7a60 to 29a40e4 Compare May 5, 2026 03:17
@VerinSenpai
Copy link
Copy Markdown
Contributor

It's.. it's beautiful 😭


private static void WriteGetDependencies(ref IndentWriter sb, EquatableArray<FieldInfo> fields, bool isOverride)
{
sb.AppendLineIndented("return [");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the use of the new list initializer syntax is actually sandbox safe and until we guarantee that we should just avoid it.

Comment thread Robust.Analyzers/HasDependenciesAnalyzer.cs Outdated
Comment thread Robust.Shared/IoC/IHasDependencies.cs Outdated
PJB3005 and others added 3 commits May 5, 2026 15:57
These are bad but gotta deal with it.
Co-authored-by: Moony <moony@hellomouse.net>
@PJB3005 PJB3005 added A: Roslyn Components Roslyn analyzers, source generators, code fixes Priority: 2-Important labels May 5, 2026
@PJB3005 PJB3005 merged commit b4eb85a into space-wizards:master May 8, 2026
6 of 7 checks passed
@PJB3005 PJB3005 deleted the 26-05-04-ioc-source-gen branch May 8, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A: Roslyn Components Roslyn analyzers, source generators, code fixes Priority: 2-Important T: Performance Type: Performance problem or optimization T: Refactor Type: Code refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants