* [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>
* 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
* 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>
* 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>
* 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.
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
We aren't going to fix these until #5610 is figured out, and these aren't even an indicator of an issue itself.
They indicate that we have code fixes in the same assembly as analyzers, meaning the analyzers COULD fail if we relied on some code fix libs - something we don't do.
* 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
* 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
* 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