-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add data to service extensions for services that lacks metadata #1093
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1093 +/- ##
====================================
Coverage 77% 77%
====================================
Files 186 186
Lines 5168 5168
Branches 660 660
====================================
+ Hits 3990 3993 +3
- Misses 1030 1032 +2
+ Partials 148 143 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Just after approving I thought that it would need some basic tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks easy enough, just needs one or two tests to check the code compiles with and without pasing an argument here
…ices without metadata
I agree I will do tests :) |
@@ -97,6 +97,8 @@ private static IEnumerable<MemberDeclarationSyntax> GenerateServiceMethod(string | |||
|
|||
if (serviceArguments is null) | |||
{ | |||
targetParam = "object? data"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think traget is the ServiceTarget, eg the Entitiy, Area, Floor etc. This can be present or not regardless of how many servcieArguments there are. So you need to join them like is done at the third yield. (maybe reorganize so the code does not need to be duplicated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the case when there are no service arguments, today it does not generate any input. Not sure I follow. I will check it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// method using arguments as separate parameters
yield return ParseMemberDeclaration($$"""
void {{serviceMethodName}}({{JoinList(targetParam, serviceArguments.GetParametersList())}})
that third yield is when there are service targets. This is the not the case here. I only want to add the data option if there are no targets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the correct case indeed, just that you now override the serviceTarget with the data parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added tests and the case you were talking about in Discord. Actually found the problem when I did the test 👍
Merged after Frank gave ok on discord |
Breaking change
Proposed change
By adding the possibility to add custom data for services generated as extension methods on entities we can support service calls for services that does not provide metadata.
Example:
Calling a script can be called with custom data but since it lacks metadata the codegenerator generates empty calls.
Before:
After:
Also the same changes to servicecall. We add a data to service calls with no metadata but keeps the one with metadata the same:
Example of new generated optional data provided.
The code should not be breaking because of the optional data parameter.
Type of change
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: