Skip to content

Commit

Permalink
Disallow error type name "Error"
Browse files Browse the repository at this point in the history
Signed-off-by: Kristupas Antanavičius <[email protected]>
  • Loading branch information
arg0d committed Oct 4, 2024
1 parent f68639f commit e786851
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bindgen/src/gen_cs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ impl CsCodeOracle {
/// "Error" for any type of error, but in C# errors are implemented as exceptions, so the
/// naming should match that.
fn error_name(&self, nm: &str) -> String {
if nm == "Error" {
panic!("`Error` is not a valid error type name, rename it, e.g. `ExampleError`. https://github.com/NordSecurity/uniffi-bindgen-cs/issues/76")
}

// errors are a class in C#.
let name = self.class_name(nm);
match name.strip_suffix("Error") {
Expand Down

0 comments on commit e786851

Please sign in to comment.