Skip to content

NetworkSet does not have any public method Add. #1006

@luismasuelli

Description

@luismasuelli

Describe the bug
There is no public Add method for the NetworkSet!

To Reproduce
Just write code (it will NOT compile):

  1. Declare a NetworkSet variable, inside a behaviour or whatever class/file you want to declare. Ensure this new, test, code you are writing is NOT in the same assembly/directory of MLAPI, but in an external directory (e.g. a main Scripts directory in the project root, and the MLAPI in another directory, with its own assembly definition).
  2. Try invoking yourVariable.Add(anInstanceOfWatever).
  3. Try compiling.

Actual outcome
A compilation error: 'NetworkSet' does not contain a definition for 'Add' and no accessible extension method 'Add' accepting a first argument of type 'NetworkSet' could be found (are you missing a using directive or an assembly reference?)

Expected outcome
No compilation error.

Screenshots
Error

Environment:

  • OS: Windows 10
  • Unity Version: 2020.3.12f1
  • MLAPI Version: 0.1.1
  • MLAPI Commit: ee59d5f (corresponds literally to tag 0.1.1).

Additional context
I notice there are two implementations of Add. One coming from ICollection and one coming from ISet. Both have almost the same code (save for a dumb return true in the case of ISet implementation, but with no return false counterpart).
Error2
Error3

My suggestion is:

  1. Make them public. At least, one of them (by default they are internal).
  2. In the bool ISet<T>.Add case, at least, ask the result of the m_Set.Add operation. On false, the element is already present and nothing changed: avoid triggering dirtiness / OnSetChanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions