Skip to content

BUGFIX: Prevent EnumType() accessor vs EnumType.NULL_VALUE name clash#4

Open
michaelszymczak wants to merge 1 commit intoJPWatson:masterfrom
michaelszymczak:master
Open

BUGFIX: Prevent EnumType() accessor vs EnumType.NULL_VALUE name clash#4
michaelszymczak wants to merge 1 commit intoJPWatson:masterfrom
michaelszymczak:master

Conversation

@michaelszymczak
Copy link
Copy Markdown
Contributor

BUGFIX: Prevent EnumType() accessor vs EnumType.NULL_VALUE name clash when sinceVersion used.

C# uses an upper case notation for both method names and types. When the same name is used for the accessor and the type, it causes the following name clash.

public SomeEnum SomeEnum()
    {
        if (_actingVersion < 1) return SomeEnum.NULL_VALUE;

        return (SomeEnum)unchecked((sbyte)_buffer.GetByte(_offset + 29));
    }

This is a compilation error.

The solution is to use a fully qualified name in this case.

public SomeEnum SomeEnum()
    {
        if (_actingVersion < 1) return Com.Example.SomeEnum.NULL_VALUE;

        return (SomeEnum)unchecked((sbyte)_buffer.GetByte(_offset + 29));
    }

This fixed the problem.

… when sinceVersion used.

C# uses an upper case notation for both method names and types. When the same name is used for the accessor and the type, it causes the following  name clash.

```
public SomeEnum SomeEnum()
    {
        if (_actingVersion < 1) return SomeEnum.NULL_VALUE;

        return (SomeEnum)unchecked((sbyte)_buffer.GetByte(_offset + 29));
    }
```

This is a compilation error.

The solution is to use a fully qualified name in this case.

```
public SomeEnum SomeEnum()
    {
        if (_actingVersion < 1) return Com.Example.SomeEnum.NULL_VALUE;

        return (SomeEnum)unchecked((sbyte)_buffer.GetByte(_offset + 29));
    }
```

This fixed the problem.
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

Successfully merging this pull request may close these issues.

1 participant