-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Automatically generate properties for packet fields #21
base: dev
Are you sure you want to change the base?
Conversation
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.
Made some comments about possible improvements.
Also why are there multiple classes just called "TestPacket" or similiar?
In e.g.: RyuSocks.Generator.Test/data/PacketGenerator/Namespaces/TestPacket.cs
Thank you very much! I'll address your comments shortly. All the files in |
9633fd3
to
1972bb5
Compare
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.
lgtm
Hopefully it's easier to see how the different property types are handled now.
The generated code now invokes the correct endian-specific BinaryPrimitives Read/Write methods.
1972bb5
to
4d6bde7
Compare
The affected code is unreachable.
9a8e29f
to
c4c450b
Compare
With the latest commits, all We now support all string encodings which are exposed by System.Text.Encoding. The test coverage for the new encoding code is ~99%, the uncovered code is about exceptions, which I plan to add tests for soon. |
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.
two remarks, else lgtm
da5e41a
to
7f7c0e0
Compare
This PR adds a source generator to generate property implementations for packet fields.
C# 13 (.NET 9.0) adds support for partial properties and source generators are able to provide implementations for them.
This generator looks for the new
PacketField
attribute which can be applied to properties and generates the appropriate implementation based on the provided arguments and the property type.It handles every packet field that's currently implemented by RyuSOCKS.
The generator currently supports the following features:
byte
,sbyte
,ushort
,short
,ushort
,int
,uint
,long
,ulong
)There are a few things that I want to do before this gets merged:
AddVerificationMethodIfNecessary()
in a different way to make it less awkward to use