Skip to content

feat(clrcore): add implicit conversion from int to CString in Player #2822

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

geofmigliacci
Copy link

@geofmigliacci geofmigliacci commented Sep 27, 2024

Goal of this PR

This PR adds an implicit conversion from int to CString in the Player class as a quality of life (QoL) improvement on the server side. This allows for direct conversion without the need to explicitly call Handle.ToString().

See : thorium-cfx/mono_v2_get_started#37

It might be interesting to add this implicit conversion to other entities as well.

How is this PR achieving the goal

This PR adds an implicit operator CString(Player player).
With this change, you can now do the following:

Player p1 = new Player(1);
Natives.ThisCoolNative(p1, "hello", 1234); // ThisCoolNative(CString, CString, int)

This PR applies to the following area(s)

Server, ScRT: C#

Successfully tested on

Game builds: Latest

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

resolves thorium-cfx/mono_v2_get_started#37

@geofmigliacci geofmigliacci changed the title feat(clrcore-v2): add implicit conversion from int to CString in Player feat(clrcore): add implicit conversion from int to CString in Player Sep 27, 2024
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action ScRT: C# Issues/PRs related to either C# scripting runtimes invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Sep 27, 2024
@geofmigliacci geofmigliacci force-pushed the feat/add-int-to-cstring-conversion branch from 9f37748 to 1282ff8 Compare October 23, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged ScRT: C# Issues/PRs related to either C# scripting runtimes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have implicit conversion for int -> CString
1 participant