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

C#: Handle all response types. #3395

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Yury-Fridlyand
Copy link
Collaborator

Issue link

This Pull Request is linked to issue (URL): #216

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Commits will be squashed upon merging.

Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand added the C# C# wrapper label Mar 19, 2025
@Yury-Fridlyand Yury-Fridlyand requested a review from a team as a code owner March 19, 2025 23:57
@Yury-Fridlyand Yury-Fridlyand mentioned this pull request Mar 19, 2025
83 tasks
@Yury-Fridlyand
Copy link
Collaborator Author

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=47803776fd8c744bfe5d345232531aa8
Fix miri warning

error: unsupported operation: integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported with `-Zmiri-strict-provenance`
  --> src/main.rs:12:29
   |
12 |         Vec::from_raw_parts(val as *mut u8, size as usize, size as usize)
   |                             ^^^^^^^^^^^^^^ integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported with `-Zmiri-strict-provenance`
   |
   = help: use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead
   = note: BACKTRACE:
   = note: inside `free_memory` at src/main.rs:12:29: 12:43
note: inside `main`
  --> src/main.rs:22:13
   |
22 |     unsafe {free_memory(val, size)};
   |             ^^^^^^^^^^^^^^^^^^^^^^

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error

thanks @jonathanl-bq

return TraverseValue(value);
}

private static object? TraverseValue(GlideValue value)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use pattern matching switch here?

private static object? TraverseValue(GlideValue value) => value.Type switch
{
    ValueType.Null => null,
    ValueType.Int => (long)value.Value,
    ValueType.Float => (double)value.Value,
    ValueType.Bool => value.Value != 0,
    ValueType.BulkString or ValueType.String => CreateString(value),
    ValueType.Array => CreateArray(value),
    ValueType.Map => CreateMap(value),
    ValueType.Set => CreateSet(value),
    ValueType.OK => new GlideString("OK"),
    _ => throw new NotImplementedException()
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# C# wrapper
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants