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

Implicit operator TValue allows comparison of two different ValueOf types. #14

Closed
Paul-Williams opened this issue May 4, 2021 · 4 comments

Comments

@Paul-Williams
Copy link
Contributor

Implicit operator back to TValue, added last year, allows for comparison of two different ValueOf object types.

Given :

class Something : ValueOf<string, Something> { }

class SomthingElse : ValueOf<string, SomthingElse> { }

...
void Test()
{
      var o1 = Something.From("test");
      var o2 = SomethingElse.From("test");
      var r = o1 == o2;
}

There is no compiler issue as there is an implicit convertion and the result 'r' will be true.
This may be by design, but it seems to do away with a lot of the potential safety which this class could provide.

If the implicit convertion is removed then the above comparison will create a compile-time error and so not be allowed.
I think that would be prefered.

@Paul-Williams
Copy link
Contributor Author

Sorry, just realized that this is almost a complete duplicate of issue #9

@Paul-Williams Paul-Williams reopened this May 4, 2021
@mcintyre321
Copy link
Owner

mcintyre321 commented May 5, 2021 via email

Paul-Williams added a commit to Paul-Williams/ValueOf that referenced this issue May 5, 2021
Equality test fixed due to breaking change.
@mattfrear
Copy link
Contributor

Hi @mcintyre321 sorry for introducing something which had to be reverted. It seemed like a good idea at the time.

@mcintyre321
Copy link
Owner

mcintyre321 commented Jun 11, 2021 via email

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

No branches or pull requests

3 participants