-
Notifications
You must be signed in to change notification settings - Fork 21
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
Generated code from Enum in Rust has errors #60
Comments
Hey, thanks for reporting this! I'm not exactly sure why this error happens. Need to look into this deeper, but don't have time right now. It seems like using the same identifier for both the struct and enum variant causes this issue. |
Oh, I think I understand. The inner record constructor
|
Thank you for the help! You are correct, the records sharing the same name was causing the error. As a work-around, I re-named my Rust variants by appending an #[derive(uniffi::Enum)]
pub enum Shape {
RectangleE { s: Rectangle },
EllipseE { s: Ellipse },
}
#[derive(uniffi::Record)]
pub struct Rectangle {
width: f64,
height: f64,
}
#[derive(uniffi::Record)]
pub struct Ellipse {
x_radius: f64,
y_radius: f64,
} This resolves the C# issues. Is this behavior that you expect to change? I don't see a good way to handle this conversion automatically, as it involves changing the names of the records. In either case, I think this should be a documented behavior, alongside the unsupported features. Personally, I am going to append |
My proposal for documenting this behavior is in #61 |
Gonna keep this issue open. I want to experiment with prefixing enum constructor parameters with |
Hello, and thank you very much for this crate! It is a big help for my project.
I have the following Rust code:
which generates the following C# code when using
--library
mode:The C#
Rectangle
andEllipse
records both contain the error: "The primary constructor conflicts with the synthesized copy constructor." Which is documented by Microsoft.There is also the following generated code:
which has the error "Cannot convert from 'uniffi.uniffi_lib.Rectangle' to 'uniffi.uniffi_lib.Shape.Rectangle" for all cases. The same in reverse conversion too. Have you seen this error before? Do you have suggestions to help remedy this issue? I have not seen any limitations on support for
Enum
s in this crate, just external types.Thank you!
The text was updated successfully, but these errors were encountered: