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

[Neo Core Add] add char support #3441

Merged
merged 7 commits into from
Aug 1, 2024
Merged

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jul 27, 2024

Description

We allows user to use char type in contract, however, user can not use char as the parameter, thus having this pr.

Fixes #

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

src/Neo/VM/Helper.cs Outdated Show resolved Hide resolved
@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 29, 2024

@cschuchardt88 according to the test, existing code alrady work, do i still need to update?

@Jim8y Jim8y requested a review from cschuchardt88 July 29, 2024 14:39
@cschuchardt88
Copy link
Member

@cschuchardt88 according to the test, existing code alrady work, do i still need to update?

Doing it as (ushort)(object) is checked vs overflowing

@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 30, 2024

(ushort)(object)

I dont understand, how could char to ushort be overflow?

@cschuchardt88
Copy link
Member

cschuchardt88 commented Jul 30, 2024

(ushort)(object)

I dont understand, how could char to ushort be overflow?

UTF-32 can be 21-bits long for a single character. For an example emoji character.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 30, 2024

@cschuchardt88

@shargon
Copy link
Member

shargon commented Jul 31, 2024

(ushort)(object)

I dont understand, how could char to ushort be overflow?

UTF-32 can be 21-bits long for a single character. For an example emoji character.

Could you add a UT for this case?

@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 31, 2024

(ushort)(object)

I dont understand, how could char to ushort be overflow?

UTF-32 can be 21-bits long for a single character. For an example emoji character.

Could you add a UT for this case?

There is no such character that can be assigned to char making char longer than 2 bytes.

@cschuchardt88
Copy link
Member

cschuchardt88 commented Jul 31, 2024

(ushort)(object)

I dont understand, how could char to ushort be overflow?

UTF-32 can be 21-bits long for a single character. For an example emoji character.

Could you add a UT for this case?

char only supports UTF-16 in dotnet, ushort is ok

@shargon shargon merged commit 6278961 into neo-project:master Aug 1, 2024
6 of 7 checks passed
Jim8y added a commit to Jim8y/neo that referenced this pull request Aug 1, 2024
* master:
  [Neo Core Add] add char support (neo-project#3441)
  [rpc] Extend `getversion` RPC response with additional protocol settings (neo-project#3443)
  update benchmark system (neo-project#3442)
  [`Optimization`] Parsing Smart Contract Script Analysis (neo-project#3420)
  `[Move]` Part-3 Classes into Different Library - `Neo.Extensions` (neo-project#3400)

# Conflicts:
#	benchmarks/Neo.Benchmarks/Benchmarks.POC.cs
#	benchmarks/Neo.VM.Benchmarks/Benchmarks.POC.cs
#	benchmarks/Neo.VM.Benchmarks/Program.cs
Jim8y added a commit to Jim8y/neo that referenced this pull request Aug 2, 2024
…ndardize-exception

* 'standardize-exception' of github.com:Jim8y/neo:
  Clean using
  [Neo Core Add] add char support (neo-project#3441)
  [rpc] Extend `getversion` RPC response with additional protocol settings (neo-project#3443)
  update benchmark system (neo-project#3442)
  [`Optimization`] Parsing Smart Contract Script Analysis (neo-project#3420)
  `[Move]` Part-3 Classes into Different Library - `Neo.Extensions` (neo-project#3400)
@Jim8y Jim8y deleted the char-type branch August 5, 2024 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants