-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix enums/errors case names conflicting with parameters to top level …
…type names (#95) Signed-off-by: Kristupas Antanavičius <[email protected]>
- Loading branch information
Showing
11 changed files
with
127 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
using uniffi.issue_60; | ||
|
||
namespace UniffiCS.BindingTests; | ||
|
||
public class ClassIssue60 | ||
{ | ||
[Fact] | ||
public void TestIssue60() | ||
{ | ||
new Shape.Rectangle(new Rectangle(1f, 2f)); | ||
new ShapeException.Rectangle(new Rectangle(1f, 2f)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "issue-60" | ||
version = "1.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["lib", "cdylib"] | ||
name = "issue_60" | ||
|
||
[dependencies] | ||
thiserror = "1.0" | ||
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"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# https://github.com/NordSecurity/uniffi-bindgen-cs/issues/60 | ||
|
||
Associated enum class names conflict with top level type definitions. | ||
|
||
```C# | ||
public record Rectangle(double @width, double @height) { } | ||
public record Shape | ||
{ ____________ | ||
∨ ∧ | ||
public record Rectangle(Rectangle @s) : Shape { } | ||
public record Ellipse(Ellipse @s) : Shape { } | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use std::fmt; | ||
|
||
#[derive(uniffi::Enum)] | ||
pub enum Shape { | ||
Rectangle { s: Rectangle }, | ||
Ellipse { s: Ellipse }, | ||
} | ||
|
||
#[derive(Debug, thiserror::Error, uniffi::Error)] | ||
pub enum ShapeError { | ||
#[error("Rectangle: {s}")] | ||
Rectangle { s: Rectangle }, | ||
#[error("Ellipse: {s}")] | ||
Ellipse { s: Ellipse }, | ||
} | ||
|
||
#[derive(uniffi::Record, Debug)] | ||
pub struct Rectangle { | ||
width: f64, | ||
height: f64, | ||
} | ||
|
||
#[derive(uniffi::Record, Debug)] | ||
pub struct Ellipse { | ||
x_radius: f64, | ||
y_radius: f64, | ||
} | ||
|
||
impl fmt::Display for Rectangle { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "width: {}, height: {}", self.width, self.height) | ||
} | ||
} | ||
|
||
impl fmt::Display for Ellipse { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "x_radius: {}, y_radius: {}", self.x_radius, self.y_radius) | ||
} | ||
} | ||
|
||
uniffi::setup_scaffolding!(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters