Skip to content

Can not define implicit cast operator #502

@aeb-dev

Description

@aeb-dev

Describe the bug

In the readme, it is stated that you can provide implicit operators manually. When I try to provide one I get a compilation error
Duplicate user-defined conversion in type 'MyValue' - https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0557

The problem seems like you can not provide both implicit and explicit cast operator at the same time. However, Vogen automatically generates explicit cast operators.

Related Issue: #206
Related PR: #208

Steps to reproduce

Add the following code to an empty project and compile.

[ValueObject<int>]
public partial struct MyValue
{
    public static implicit operator int(MyValue d) => 5;
}

Expected behaviour

I should be able to provide implicit cast operator

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions