Commit Graph
25 Commits
Author SHA1 Message Date
TayrtahnandGitHub a6adb884ba Add a Code Fix for converting EntitySystem event subscriptions to use attributes (#6909) 2026-08-07 00:15:52 +10:00
34ce2ba534 serv5 (#6496)
* Add source generator for DataDefinition validation

* Add source generator for reading

* Add source generator for writing

* Include prototypes and other meansdatadefinition types

* Target ISerializationGenerated in data definitions

* Murder

* Use array, struct, enum methods

* Source generate get field definitions

* serv5

* Fix and pray

* Fix release compile

* Tayrtahn review

* a

* Generator bugfix

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2026-07-08 22:18:35 +10:00
1322177e62 IEntitySystem Event Subscription Code Generation (#6227)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2026-07-01 13:30:23 +10:00
8508801670 Check that [Virtual] is not used on sealed/abstract/static classes (#6486)
* Add exclusivity check for virtual + analyzer test

* Cleanup

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2026-05-08 13:18:05 +02:00
b4eb85ad3c [Dependency] source generator (#6549)
* [Dependency] source generator

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

* Release notes

* Handle nullable dependencies

These are bad but gotta deal with it.

* Apply suggestions from code review

Co-authored-by: Moony <moony@hellomouse.net>

* Fine, let's not use collection expressions

---------

Co-authored-by: Moony <moony@hellomouse.net>
2026-05-08 12:38:02 +02:00
Pieter-Jan BriersandGitHub 9b595eb979 Analyzer to detect nullable dependency fields (#6553)
* Analyzer to detect nullable dependency fields

Does nothing, no point in it.

* Release notes
2026-05-07 21:44:11 +02:00
TayrtahnandGitHub fcc2c01d01 Revert "Revert "Add analyzer & fixer to detect when proxy methods are not used (ProxyForAttribute)"" (#6439)
Revert "Revert "Add analyzer & fixer to detect when proxy methods are not use…"

This reverts commit 1af32c3129.
2026-03-07 11:32:01 -05:00
TayrtahnandGitHub 1af32c3129 Revert "Add analyzer & fixer to detect when proxy methods are not used (ProxyForAttribute)" (#6430)
Revert "Add analyzer & fixer to detect when proxy methods are not used (`Prox…"

This reverts commit db1d3054ac.
2026-02-27 08:46:58 -05:00
TayrtahnandGitHub db1d3054ac Add analyzer & fixer to detect when proxy methods are not used (ProxyForAttribute) (#6026)
* Attribute, analyzer, and tests

* Add attribute to EntitySystem methods

* Code fixer for redundant method name

* Code fixer for proxy substitution

* Comments

* Improve error message when target method is not found

* Modify AddComp signature to match AddComponent (Component -> IComponent)

* Revert "Modify AddComp signature to match AddComponent (Component -> IComponent)"

This reverts commit 1939d11765.

* Check that proxy and target have matching type constraints

* Reapply "Modify AddComp signature to match AddComponent (Component -> IComponent)"

This reverts commit a65ea71b9b.

Might as well include this, since the file needs to be changed anyway.

* Boost efficiency by only searching for proxy methods once.
Previously we searched with each method invocation.
This also lets us skip analysis on classes with no proxy methods available.

* Revert unrelated change

* Fine, I'll do it properly

* Misleading method name

* Preserve trivia when when replacing method

* Prevent flagging method calls on non-member variables

* Prevent flagging method calls on other classes

* Switch to new HasAttribute helper

* comment fix

* Switch ProxyMethod from struct to class

* Kill TryGetAttributeSyntax

* Move member owner check to helper

* Use helper for proxy method search

* meh

* A little bit of documentation never hurt anybody

* Test attributes

* Convert AnalyzeDeclaration from SyntaxNodeAction to OperationAction

* You can keep the comment though
2026-02-27 08:22:41 -05:00
d7abbad717 Add validation for DirtyField strings (#5713)
* Add ValidateMemberAttribute, analyzer and test

* Use attribute on DirtyFields methods

* Defer member lookup

* Additional test case

* Add support for collection types

* Poke tests

* Revert "Add support for collection types"

This reverts commit 2b8f5534bd.

* break, not continue

* Cheaper attribute check with AttributeHelper

* Clean up unused helper method

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-12-17 19:32:34 +01:00
c1737a540f Analyzer & Fixer for redundant Prototype type strings (#5718)
* Add Prototype analyzer

* Add Prototype fixer

* Early return after finding prototype attribute

* Add PrototypeEndsWithPrototypeRule diagnostic

* Oops. Uncomment parallelizable.

* Rework to ignore redundancy for non-literal string values

* Allow redundancy when removal would expose class name not ending in "Prototype"

* Promote PrototypeEndsWithPrototypeRule from warning to error, since it causes a runtime error.

* No need to get the symbol to get the class identifier

* Minor cleanup

* A little more cleanup

* More specific location for redundant name

* Refactor redundant name fixer so argument order is no longer important

* Add failing test

* Use symbol analysis to fix alias handling

* Oops! We have to go back to the previous syntax-based approach.

Now it's a hybrid.

Also fixed tests to not copy the prototype definitions.

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-12-17 18:15:32 +01:00
Perry FraserandGitHub 1983734e2d feat: add analyzer for correct AfterAutoHandleStateEvent usage (#6117)
* feat: add analyzer for AfterAutoHandleStateEvent

* fix: correct TestOf attribute

Oopsieeeee.

Also weird newline plus unused import.

* Rerun content tests

* refactor: use ==, not .Contains

* feat: make AttributeHelper.HasAttribute looser

* refactor: use AttributeHelper.HasAttribute

* perf: cache AutoGenStateAttribute's type

* refactor: more pattern matching

ElementAtOrDefault with constant arg is bad; just use positional
matching.
2025-08-04 18:22:06 -04:00
c73b54862e Add analyzers to detect some prototype misuse (#6048)
* Add analyzers to detect some prototype misuse

Detects people marking prototype as NetSerializable.

Detects people creating new prototype instances themselves.

* Update Robust.Analyzers/PrototypeNetSerializableAnalyzer.cs

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
2025-06-26 22:24:23 +02:00
TayrtahnandGitHub b3cf427013 Catch NotYamlSerializable DataFields with analyzer (#5704)
* Catch NotYamlSerializable DataFields with analyzer

* Extract common defs into shared source
2025-05-10 21:36:33 +10:00
Pieter-Jan BriersandGitHub 72d893dec5 Add "obsolete inheritance" analyzer (#5858)
This allows us to make it obsolete to *inherit* from a class, and only that.

Intended so people stop inheriting UI controls for no good reason.

Fixes #5856
2025-04-19 17:29:17 +10:00
TayrtahnandGitHub 45bb8740a0 Add ForbidLiteralAttribute and analyzer (#5808)
* Add ForbidLiteral attribute, analyzer, and test

* Removed unused code

* Switch order of methods. It's better this way.
2025-04-08 16:39:38 +02:00
Pieter-Jan BriersandGitHub f0ed3537ee Duplicate dependency field analyzer (#5463)
* Duplicate dependency field analyzer

Detects cases of duplicate [Dependency] fields in a type. We apparently have 27 of these across RT + SS14.

* Fix duplicate dependencies in Robust
2024-09-28 15:35:18 +10:00
TayrtahnandGitHub b6548c870c Add analyzer/fixer for replacing ProtoId<EntityPrototype> with EntProtoId (#5312)
* Add PreferOtherTypeAttribute, analyzer, and test.

* nullable enable

* Add nuget package for CodeFix verifier

* Add fixer for PreferOtherType

* Rename arguments

* Adjust diagnostic message

* Move attribute lookup
2024-07-23 19:01:43 +02:00
c3d8080a8e Add PreferNonGenericVariantFor attribute and analyzer (#5190)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2024-07-10 12:33:56 +02:00
TayrtahnandGitHub 8e50924607 Add analyzer/fixer for DataFields with ReadWrite VV (#5164)
* Add analyzer/fixer for datafields with ReadWrite VV

* Nothing to see here
2024-07-10 02:04:55 +02:00
Pieter-Jan BriersandGitHub 75b3431ee6 New "must call base" analyzer. (#5266)
* New "must call base" analyzer.

This enforces that you actually call base when overriding stuff. This is intended for base methods like entity system's, where server/client systems overriding shared ones SHOULD call Initialize() and such.

* Add MustCallBase to entity system methods
2024-06-28 14:44:49 +10:00
TayrtahnandGitHub da7abc6580 Add analyzer and fixer for redundant DataField tag arguments (#5134)
* Add analyzer and fixer for redundant DataField tag arguments

* Share Tag autogeneration logic
2024-05-17 07:44:03 +02:00
Pieter-Jan BriersandGitHub 4d528dd577 Analyzer to ban uncached regexes (#5107)
Using static Regex functions that take in a pattern is bad, because they constantly have to be re-parsed. Cache the Regex instance.
2024-05-06 10:30:31 +10:00
Pieter-Jan Briers cd67c67a5c Add analyzer to warn for assignment to dependency fields. 2024-04-14 05:14:12 +02:00
Pieter-Jan BriersandGitHub ae6cebbfbb Source gen reorganizations + component unpause generator. (#4896)
* Source gen reorganizations + component unpause generator.

This commit (and subsequent commits) aims to clean up our Roslyn plugin (source gens + analyzers) stack to more sanely re-use common code

I also built a new source-gen that automatically generates unpausing implementations for components, incrementing attributed TimeSpan field when unpaused.

* Fix warnings in all Roslyn projects
2024-02-20 10:15:32 +01:00