FirstGearGames / FishNet

FishNet: Unity Networking Evolved.
Other
1.39k stars 150 forks source link

IL2CPP generation error for this[] operator override setter #621

Open Pfhoenix opened 8 months ago

Pfhoenix commented 8 months ago

Important

If General, Description, and Replication are not completed the issue will be closed immediately.

General Unity version: 2022.3.15f1 Fish-Networking version: 4.1.2R Discord link: https://discord.com/channels/424284635074134018/1034477094731784302/1218299786860695752

Description In my custom class, I override the array accessor operator, []. Getter works fine, but having a setter results in the error in the attached text file.

il2cpp build error.txt

The related code is as follows :

Dictionary<Guid, MyClass> Foo = new();

public MyClass this[Guid id]
{
  get
  {
    if (Foo.TryGetValue(id, out MyClass mc)) return mc;
    return null;
  }

  set
  {
    Foo[id] = value;
  }
}

Where serialization is happening for the broadcast struct:

public class ManageMyClass
{
  public List<MyClass> MyList;
}

struct BroadcastMe
{
  public ManageMyClass Manager;
}

Replication Steps to reproduce the behavior:

  1. Create a project with a class using the code above
  2. Build the project with IL2CPP target
  3. Observe error in log

Expected behavior I'd expect no error with building the code above. It's fundamental and simple C# code.

FirstGearGames commented 8 months ago

Are you serializing MyClass anywhere? EG: RPC, SyncVar, Broadcast

Pfhoenix commented 8 months ago

Yes, it's in a broadcast struct.

FirstGearGames commented 8 months ago

Please update original post to show the struct.

FirstGearGames commented 8 months ago

Thanks!

FirstGearGames commented 1 month ago

I'm going to mark this as wont fix but keep it open because Id like to see if our new serializer generation tech will fix this.