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

Fix the ffi constructor's type case issue (#28) #103

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindgen/src/gen_cs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl CsCodeOracle {
FfiType::UInt8 => "byte".to_string(),
FfiType::Float32 => "float".to_string(),
FfiType::Float64 => "double".to_string(),
FfiType::RustArcPtr(name) => format!("{}SafeHandle", name),
FfiType::RustArcPtr(name) => format!("{}SafeHandle", self.class_name(name).as_str()),
FfiType::RustBuffer(_) => "RustBuffer".to_string(),
FfiType::ForeignBytes => "ForeignBytes".to_string(),
FfiType::ForeignCallback => "ForeignCallback".to_string(),
Expand Down
12 changes: 12 additions & 0 deletions dotnet-tests/UniffiCS.BindingTests/TestIssue28.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using uniffi.issue_28;

namespace UniffiCS.BindingTests;

public class ClassIssue28
{
[Fact]
public void TestIssue28()
{
new AsdfObject();
}
}
1 change: 1 addition & 0 deletions fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ crate-type = ["cdylib", "lib"]

[dependencies]
global-methods-class-name = { path = "global-methods-class-name" }
issue-28 = { path = "regressions/issue-28" }
issue-75 = { path = "regressions/issue-75" }
issue-76 = { path = "regressions/issue-76" }
null-to-empty-string = { path = "null-to-empty-string" }
Expand Down
17 changes: 17 additions & 0 deletions fixtures/regressions/issue-28/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "issue-28"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["lib", "cdylib"]
name = "issue_28"

[dependencies]
uniffi = {path = "../../../3rd-party/uniffi-rs/uniffi", features=["build"]}
uniffi_macros = {path = "../../../3rd-party/uniffi-rs/uniffi_macros"}

[build-dependencies]
uniffi = {path = "../../../3rd-party/uniffi-rs/uniffi", features=["bindgen-tests"]}
4 changes: 4 additions & 0 deletions fixtures/regressions/issue-28/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
https://github.com/NordSecurity/uniffi-bindgen-cs/issues/28

If the interface's name is like `ASDFObject`, typenames are not generated uniformly.
There will be a difference between the class name `AsdfObject` and the return type of the ffi constructor `ASDFObject`.
3 changes: 3 additions & 0 deletions fixtures/regressions/issue-28/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
uniffi::generate_scaffolding("src/issue-28.udl").unwrap();
}
7 changes: 7 additions & 0 deletions fixtures/regressions/issue-28/src/issue-28.udl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace issue_28 {

};

interface ASDFObject {
constructor();
};
9 changes: 9 additions & 0 deletions fixtures/regressions/issue-28/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub struct ASDFObject {}

impl ASDFObject {
fn new() -> ASDFObject {
ASDFObject {}
}
}

uniffi::include_scaffolding!("issue-28");
1 change: 1 addition & 0 deletions fixtures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod uniffi_fixtures {
uniffi_cs_disposable::uniffi_reexport_scaffolding!();
uniffi_cs_optional_parameters::uniffi_reexport_scaffolding!();
stringify::uniffi_reexport_scaffolding!();
issue_28::uniffi_reexport_scaffolding!();
issue_75::uniffi_reexport_scaffolding!();
issue_76::uniffi_reexport_scaffolding!();
}
Loading