-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: making weaver include public fields in base classes in auto gene…
…rated Read/Write (#1977) * adding test to check if data is sent * test for generating writer for inherited class * adding extension method for FindAllPublicFields
- Loading branch information
1 parent
df76cb6
commit 3db57e5
Showing
8 changed files
with
161 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using Mirror.Tests.RemoteAttrributeTest; | ||
using NUnit.Framework; | ||
|
||
namespace Mirror.Tests.GeneratedWriterTests | ||
{ | ||
public class BaseData | ||
{ | ||
public bool toggle; | ||
} | ||
public class SomeOtherData : BaseData | ||
{ | ||
public int usefulNumber; | ||
} | ||
|
||
public class DataSenderBehaviour : NetworkBehaviour | ||
{ | ||
public event Action<SomeOtherData> onData; | ||
[Command] | ||
public void CmdSendData(SomeOtherData otherData) | ||
{ | ||
onData?.Invoke(otherData); | ||
} | ||
} | ||
|
||
public class FieldsInBaseClasses : RemoteTestBase | ||
{ | ||
[Test] | ||
public void WriterShouldIncludeFieldsInBaseClass() | ||
{ | ||
DataSenderBehaviour hostBehaviour = CreateHostObject<DataSenderBehaviour>(true); | ||
|
||
const bool toggle = true; | ||
const int usefulNumber = 10; | ||
|
||
int callCount = 0; | ||
hostBehaviour.onData += data => | ||
{ | ||
callCount++; | ||
Assert.That(data.usefulNumber, Is.EqualTo(usefulNumber)); | ||
Assert.That(data.toggle, Is.EqualTo(toggle)); | ||
}; | ||
hostBehaviour.CmdSendData(new SomeOtherData | ||
{ | ||
usefulNumber = usefulNumber, | ||
toggle = toggle | ||
}); | ||
|
||
ProcessMessages(); | ||
Assert.That(callCount, Is.EqualTo(1)); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Assets/Mirror/Tests/Editor/Weaver/GeneratedReaderWriter~/CreatesForClassInherited.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Mirror; | ||
|
||
|
||
namespace GeneratedReaderWriter.CreatesForClassInherited | ||
{ | ||
public class CreatesForClassInherited : NetworkBehaviour | ||
{ | ||
[ClientRpc] | ||
public void RpcDoSomething(SomeOtherData data) | ||
{ | ||
// empty | ||
} | ||
} | ||
|
||
public class BaseData | ||
{ | ||
public bool yes; | ||
} | ||
public class SomeOtherData : BaseData | ||
{ | ||
public int usefulNumber; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters