FishNet icon indicating copy to clipboard operation
FishNet copied to clipboard

IL2CPP generation error for this[] operator override setter

Open Pfhoenix opened this issue 1 year ago • 5 comments

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.

Pfhoenix avatar Mar 16 '24 17:03 Pfhoenix

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

FirstGearGames avatar Mar 20 '24 15:03 FirstGearGames

Yes, it's in a broadcast struct.

Pfhoenix avatar Mar 20 '24 16:03 Pfhoenix

Please update original post to show the struct.

FirstGearGames avatar Mar 20 '24 17:03 FirstGearGames

Thanks!

FirstGearGames avatar Mar 24 '24 23:03 FirstGearGames

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.

FirstGearGames avatar Oct 05 '24 20:10 FirstGearGames