Skip to content
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

feat: Process required keyword like MemberRequiredAttribute #2555

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

Eideren
Copy link
Collaborator

@Eideren Eideren commented Dec 11, 2024

PR Details

Now that required is an actual keyword, we can use it to notify users when some of their components have missing references, just like our MemberRequiredAttribute.

required is an essential part of projects using the nullable reference feature, using it in stride to benefit from null-state analysis from both the compiler and our asset builder requires writing a fairly redundant property definition:

[MemberRequired] public required MyRef myRef { get; set; }

When the intent of the attribute is already made clear through the use of the required keyword.

public required MyRef myRef { get; set; }

Related Issue

None

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

Hopefully you have some time to get back to me about this one @manio143 , would like to hear your thoughts given that this is your feature.

Copy link
Member

@manio143 manio143 left a comment

Choose a reason for hiding this comment

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

Looks good. Small suggestion would be to add a unit test for that case (as there already is one for the attributes) here https://github.com/stride3d/stride/blob/c2497b57eaba3ce84ea77a3ca14e5aeafafd3c88/sources/engine/Stride.Assets.Tests/TestMemberRequiredComponentChecks.cs

@Eideren
Copy link
Collaborator Author

Eideren commented Dec 12, 2024

There we go, covered both the keyword and the keyword with the attribute set to error. Can you check again @manio143 ?

@Eideren Eideren merged commit 9f56722 into stride3d:master Dec 12, 2024
2 checks passed
@Eideren Eideren deleted the required_keyword branch December 12, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants